fix(core): check query set index before other validation (#7908)

This commit is contained in:
Erich Gubler
2025-07-10 15:04:37 -04:00
committed by GitHub
parent b83c9cfd57
commit 166c2ea2aa
3 changed files with 12 additions and 7 deletions

View File

@@ -42,7 +42,10 @@ Bottom level categories:
### Bug Fixes
#### General
- Fixed build error occurring when the `profiling` dependency is configured to have profiling active. By @kpreid in [#7916](https://github.com/gfx-rs/wgpu/pull/7916).
- Emit a validation error instead of panicking when a query set index is OOB. By @ErichDonGubler in [#7908](https://github.com/gfx-rs/wgpu/pull/7908).
## v26.0.0 (2025-07-09)

View File

@@ -47,6 +47,7 @@ webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_grou
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_groups_and_pipeline_layout_mismatch:encoderType="render%20pass";*
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:buffer_binding,render_pipeline:*
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:sampler_binding,render_pipeline:*
webgpu:api,validation,encoding,queries,general:occlusion_query,query_index:*
webgpu:api,validation,image_copy,layout_related:copy_end_overflows_u64:*
webgpu:api,validation,image_copy,texture_related:format:dimension="1d";*
webgpu:api,validation,queue,submit:command_buffer,device_mismatch:*

View File

@@ -210,6 +210,14 @@ impl QuerySet {
query_index: u32,
reset_state: Option<&mut QueryResetMap>,
) -> Result<(), QueryUseError> {
// NOTE: Further code assumes the index is good, so do this first.
if query_index >= self.desc.count {
return Err(QueryUseError::OutOfBounds {
query_index,
query_set_size: self.desc.count,
});
}
// We need to defer our resets because we are in a renderpass,
// add the usage to the reset map.
if let Some(reset) = reset_state {
@@ -227,13 +235,6 @@ impl QuerySet {
});
}
if query_index >= self.desc.count {
return Err(QueryUseError::OutOfBounds {
query_index,
query_set_size: self.desc.count,
});
}
Ok(())
}