Fix WGSL variable storage classes, spv-out interface

This commit is contained in:
Dzmitry Malyshau 2020-12-11 14:48:32 -05:00 committed by Dzmitry Malyshau
parent 211bec44a1
commit 2d1006835a
2 changed files with 16 additions and 6 deletions

View File

@ -390,15 +390,16 @@ impl Writer {
let function_id = self.write_function(&entry_point.function, ir_module)?;
let mut interface_ids = vec![];
for ((handle, _), &usage) in ir_module
for ((handle, var), &usage) in ir_module
.global_variables
.iter()
.filter(|&(_, var)| {
var.class == crate::StorageClass::Input || var.class == crate::StorageClass::Output
})
.zip(&entry_point.function.global_usage)
{
if usage.contains(crate::GlobalUse::STORE) || usage.contains(crate::GlobalUse::LOAD) {
let is_io = match var.class {
crate::StorageClass::Input | crate::StorageClass::Output => !usage.is_empty(),
_ => false,
};
if is_io {
let id = self.get_global_variable_id(ir_module, handle)?;
interface_ids.push(id);
}

View File

@ -1960,7 +1960,16 @@ impl Parser {
crate::BuiltIn::Position => crate::StorageClass::Output,
_ => unimplemented!(),
},
_ => crate::StorageClass::Handle,
Some(crate::Binding::Resource { .. }) => {
match module.types[pvar.ty].inner {
crate::TypeInner::Struct { .. } if pvar.access.is_empty() => {
crate::StorageClass::Uniform
}
crate::TypeInner::Struct { .. } => crate::StorageClass::Storage,
_ => crate::StorageClass::Handle,
}
}
_ => crate::StorageClass::Private,
},
};
let var_handle = module.global_variables.append(crate::GlobalVariable {