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

This commit is contained in:
Erich Gubler authored and Connor Fitzgerald committed 2025-07-10 16:03:48 -04:00
1 parent dd324355e7
commit b22d123f98
3 files changed
+10 -7

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ Bottom level categories:
- Fixed build error inside `wgpu::util::initialize_adapter_from_env` when `std` feature is not enabled. By @kpreid in [#7918](https://github.com/gfx-rs/wgpu/pull/7918).
- 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)
+1
View File
@@ -43,6 +43,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:*
+8 -7
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(())
}