mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 09:34:09 +01:00
[spv-in] default output builtins
This commit is contained in:
1 parent
9fe75ed7f1
commit
be00a05fa5
6 files changed
+241
-109
No files matched your search
+28
-27
@@ -296,33 +296,34 @@ impl<I: Iterator<Item = u32>> super::Parser<I> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.options.adjust_coordinate_space {
|
||||
let position_index = members.iter().position(|member| match member.binding {
|
||||
Some(crate::Binding::BuiltIn(crate::BuiltIn::Position)) => true,
|
||||
_ => false,
|
||||
});
|
||||
if let Some(component_index) = position_index {
|
||||
// The IR is Y-up, while SPIR-V is Y-down.
|
||||
let old_len = function.expressions.len();
|
||||
let global_expr = components[component_index];
|
||||
let access_expr = function.expressions.append(crate::Expression::AccessIndex {
|
||||
base: global_expr,
|
||||
index: 1,
|
||||
});
|
||||
let load_expr = function.expressions.append(crate::Expression::Load {
|
||||
pointer: access_expr,
|
||||
});
|
||||
let neg_expr = function.expressions.append(crate::Expression::Unary {
|
||||
op: crate::UnaryOperator::Negate,
|
||||
expr: load_expr,
|
||||
});
|
||||
function.body.push(crate::Statement::Emit(
|
||||
function.expressions.range_from(old_len),
|
||||
));
|
||||
function.body.push(crate::Statement::Store {
|
||||
pointer: access_expr,
|
||||
value: neg_expr,
|
||||
});
|
||||
for (member_index, member) in members.iter().enumerate() {
|
||||
match member.binding {
|
||||
Some(crate::Binding::BuiltIn(crate::BuiltIn::Position))
|
||||
if self.options.adjust_coordinate_space =>
|
||||
{
|
||||
let old_len = function.expressions.len();
|
||||
let global_expr = components[member_index];
|
||||
let access_expr =
|
||||
function.expressions.append(crate::Expression::AccessIndex {
|
||||
base: global_expr,
|
||||
index: 1,
|
||||
});
|
||||
let load_expr = function.expressions.append(crate::Expression::Load {
|
||||
pointer: access_expr,
|
||||
});
|
||||
let neg_expr = function.expressions.append(crate::Expression::Unary {
|
||||
op: crate::UnaryOperator::Negate,
|
||||
expr: load_expr,
|
||||
});
|
||||
function.body.push(crate::Statement::Emit(
|
||||
function.expressions.range_from(old_len),
|
||||
));
|
||||
function.body.push(crate::Statement::Store {
|
||||
pointer: access_expr,
|
||||
value: neg_expr,
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user