mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-in] support output interface block
This commit is contained in:
committed by
Dzmitry Malyshau
parent
c55bdf57bf
commit
e47ff2dc26
@@ -235,20 +235,47 @@ impl<I: Iterator<Item = u32>> super::Parser<I> {
|
||||
for &v_id in ep.variable_ids.iter() {
|
||||
let lvar = self.lookup_variable.lookup(v_id)?;
|
||||
if let super::Variable::Output(ref result) = lvar.inner {
|
||||
members.push(crate::StructMember {
|
||||
name: None,
|
||||
ty: result.ty,
|
||||
binding: result.binding.clone(),
|
||||
size: None,
|
||||
align: None,
|
||||
});
|
||||
// populate just the globals first, then do `Load` in a
|
||||
// separate step, so that we can get a range.
|
||||
components.push(
|
||||
function
|
||||
.expressions
|
||||
.append(crate::Expression::GlobalVariable(lvar.handle)),
|
||||
);
|
||||
let expr_handle = function
|
||||
.expressions
|
||||
.append(crate::Expression::GlobalVariable(lvar.handle));
|
||||
match module.types[result.ty].inner {
|
||||
crate::TypeInner::Struct {
|
||||
members: ref sub_members,
|
||||
..
|
||||
} => {
|
||||
for (index, sm) in sub_members.iter().enumerate() {
|
||||
if sm.binding.is_none() {
|
||||
// unrecognized binding, skip
|
||||
continue;
|
||||
}
|
||||
members.push(crate::StructMember {
|
||||
name: sm.name.clone(),
|
||||
ty: sm.ty,
|
||||
binding: sm.binding.clone(),
|
||||
size: None,
|
||||
align: None,
|
||||
});
|
||||
components.push(function.expressions.append(
|
||||
crate::Expression::AccessIndex {
|
||||
base: expr_handle,
|
||||
index: index as u32,
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
members.push(crate::StructMember {
|
||||
name: None,
|
||||
ty: result.ty,
|
||||
binding: result.binding.clone(),
|
||||
size: None,
|
||||
align: None,
|
||||
});
|
||||
// populate just the globals first, then do `Load` in a
|
||||
// separate step, so that we can get a range.
|
||||
components.push(expr_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2414,10 +2414,11 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
.future_member_decor
|
||||
.remove(&(id, i))
|
||||
.unwrap_or_default();
|
||||
let binding = decor.io_binding().ok();
|
||||
members.push(crate::StructMember {
|
||||
name: decor.name,
|
||||
ty,
|
||||
binding: None,
|
||||
binding,
|
||||
size: None, //TODO
|
||||
align: None,
|
||||
});
|
||||
@@ -2871,7 +2872,8 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
(inner, var)
|
||||
}
|
||||
ExtendedClass::Output => {
|
||||
let binding = dec.io_binding()?;
|
||||
// For output interface blocks. this would be a structure.
|
||||
let binding = dec.io_binding().ok();
|
||||
let var = crate::GlobalVariable {
|
||||
name: dec.name,
|
||||
class: crate::StorageClass::Private,
|
||||
@@ -2882,7 +2884,7 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
};
|
||||
let inner = Variable::Output(crate::FunctionResult {
|
||||
ty: effective_ty,
|
||||
binding: Some(binding),
|
||||
binding,
|
||||
});
|
||||
(inner, var)
|
||||
}
|
||||
|
||||
BIN
tests/in/quad-vert.spv
Normal file
BIN
tests/in/quad-vert.spv
Normal file
Binary file not shown.
@@ -283,6 +283,12 @@ fn convert_spv(name: &str, targets: Targets) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
#[test]
|
||||
fn convert_spv_quad_vert() {
|
||||
convert_spv("quad-vert", Targets::empty());
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
#[test]
|
||||
fn convert_spv_shadow() {
|
||||
|
||||
Reference in New Issue
Block a user