[mtl] detect binding incomatibility

This commit is contained in:
Dzmitry Malyshau
2021-07-01 23:52:36 -04:00
committed by Dzmitry Malyshau
parent 6e9410c056
commit a92f7689f2
2 changed files with 18 additions and 7 deletions

View File

@@ -2007,15 +2007,27 @@ impl<W: Write> Writer<W> {
let mut ep_error = None;
let mut supports_array_length = false;
// skip this entry point if any global bindings are missing
// skip this entry point if any global bindings are missing,
// or their types are incompatible.
if !options.fake_missing_bindings {
for (var_handle, var) in module.global_variables.iter() {
if fun_info[var_handle].is_empty() {
continue;
}
if let Some(ref br) = var.binding {
if let Err(e) = options.resolve_resource_binding(ep.stage, br) {
ep_error = Some(e);
let good = match options.per_stage_map[ep.stage].resources.get(br) {
Some(target) => match module.types[var.ty].inner {
crate::TypeInner::Struct {
top_level: true, ..
} => target.buffer.is_some(),
crate::TypeInner::Image { .. } => target.texture.is_some(),
crate::TypeInner::Sampler { .. } => target.sampler.is_some(),
_ => false,
},
None => false,
};
if !good {
ep_error = Some(super::EntryPointError::MissingBinding(br.clone()));
break;
}
}

View File

@@ -898,10 +898,9 @@ impl<'function> Context<'function> {
let expr_type = program.resolve_type(self, *expr, meta)?;
if let (&TypeInner::Scalar { .. }, Some(size)) = (expr_type, vector_size) {
*expr = self.expressions.append(Expression::Splat {
size,
value: *expr,
})
*expr = self
.expressions
.append(Expression::Splat { size, value: *expr })
}
Ok(())