Add InvalidGroupIndex validation at create_shader_module

This commit is contained in:
Jinlei Li
2022-06-15 16:43:02 +08:00
committed by Jim Blandy
parent 191537021e
commit f2c3d42818
2 changed files with 20 additions and 0 deletions

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");

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 {