Skip to content

Commit 166c2ea

Browse files
fix(core): check query set index before other validation (#7908)
1 parent b83c9cf commit 166c2ea

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ Bottom level categories:
4242

4343
### Bug Fixes
4444

45+
#### General
46+
4547
- 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).
48+
- 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).
4649

4750
## v26.0.0 (2025-07-09)
4851

cts_runner/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_grou
4747
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_groups_and_pipeline_layout_mismatch:encoderType="render%20pass";*
4848
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:buffer_binding,render_pipeline:*
4949
webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:sampler_binding,render_pipeline:*
50+
webgpu:api,validation,encoding,queries,general:occlusion_query,query_index:*
5051
webgpu:api,validation,image_copy,layout_related:copy_end_overflows_u64:*
5152
webgpu:api,validation,image_copy,texture_related:format:dimension="1d";*
5253
webgpu:api,validation,queue,submit:command_buffer,device_mismatch:*

wgpu-core/src/command/query.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ impl QuerySet {
210210
query_index: u32,
211211
reset_state: Option<&mut QueryResetMap>,
212212
) -> Result<(), QueryUseError> {
213+
// NOTE: Further code assumes the index is good, so do this first.
214+
if query_index >= self.desc.count {
215+
return Err(QueryUseError::OutOfBounds {
216+
query_index,
217+
query_set_size: self.desc.count,
218+
});
219+
}
220+
213221
// We need to defer our resets because we are in a renderpass,
214222
// add the usage to the reset map.
215223
if let Some(reset) = reset_state {
@@ -227,13 +235,6 @@ impl QuerySet {
227235
});
228236
}
229237

230-
if query_index >= self.desc.count {
231-
return Err(QueryUseError::OutOfBounds {
232-
query_index,
233-
query_set_size: self.desc.count,
234-
});
235-
}
236-
237238
Ok(())
238239
}
239240

0 commit comments

Comments
 (0)