Skip to content

Commit

Permalink
Add InvalidGroupIndex validation at create_shader_module
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili authored and jimblandy committed Jun 16, 2022
1 parent 1915370 commit f2c3d42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f2c3d42

Please sign in to comment.