Add InvalidGroupIndex validation at create_shader_module

This commit is contained in:
Jinlei Li authored and Jim Blandy committed 2022-06-16 10:06:11 -07:00
1 parent 191537021e
commit f2c3d42818
2 files changed
+20

No files matched your search

+12
View File
@@ -1189,6 +1189,18 @@ impl<A: HalApi> Device<A> {
}
pipeline::ShaderModuleSource::Naga(module) => (module, String::new()),
};
for (_, var) in module.global_variables.iter() {
match var.binding {
Some(ref br) if br.group >= self.limits.max_bind_groups => {
return Err(pipeline::CreateShaderModuleError::InvalidGroupIndex {
bind: br.clone(),
group: br.group,
limit: self.limits.max_bind_groups,
});
}
_ => continue,
};
}
use naga::valid::Capabilities as Caps;
profiling::scope!("naga::validate");
+8
View File
@@ -124,6 +124,14 @@ pub enum CreateShaderModuleError {
Validation(#[from] ShaderError<naga::WithSpan<naga::valid::ValidationError>>),
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
#[error(
"shader global {bind:?} uses a group index {group} that exceeds the max_bind_groups limit of {limit}."
)]
InvalidGroupIndex {
bind: naga::ResourceBinding,
group: u32,
limit: u32,
},
}
impl CreateShaderModuleError {