Skip to content

Commit

Permalink
fix(core): validate TIMESTAMP_QUERY feature before other query set …
Browse files Browse the repository at this point in the history
…validation in pass creation
  • Loading branch information
ErichDonGubler committed Nov 22, 2024
1 parent 5ca92bf commit b17c303
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
- Lower `QUERY_SET_MAX_QUERIES` (and enforced limits) from 8192 to 4096 to match WebGPU spec. By @ErichDonGubler in [#6525](https://github.com/gfx-rs/wgpu/pull/6525).
- Allow non-filterable float on texture bindings never used with samplers when using a derived bind group layout. By @ErichDonGubler in [#6531](https://github.com/gfx-rs/wgpu/pull/6531/).
- Replace potentially unsound usage of `PreHashedMap` with `FastHashMap`. By @jamienicol in [#6541](https://github.com/gfx-rs/wgpu/pull/6541).
- Add missing validation for timestamp writes in compute and render passes. By @ErichDonGubler in [#6578](https://github.com/gfx-rs/wgpu/pull/6578).
- Check the status of the `TIMESTAMP_QUERY` feature before other validation.

#### Naga

Expand Down
16 changes: 9 additions & 7 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,23 @@ impl Global {
};

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
match cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY)
{
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}

let query_set = match hub.query_sets.get(tw.query_set).get() {
Ok(query_set) => query_set,
Err(e) => return make_err(e.into(), arc_desc),
};

match query_set.same_device(&cmd_buf.device) {
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}
match cmd_buf
.device
.require_features(wgt::Features::TIMESTAMP_QUERY)
{
Ok(()) => (),
Err(e) => return make_err(e.into(), arc_desc),
}

Some(ArcPassTimestampWrites {
query_set,
Expand Down
3 changes: 2 additions & 1 deletion wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,10 +1393,11 @@ impl Global {

arc_desc.timestamp_writes = if let Some(tw) = desc.timestamp_writes {
let query_set = query_sets.get(tw.query_set).get()?;
query_set.same_device(device)?;

device.require_features(wgt::Features::TIMESTAMP_QUERY)?;

query_set.same_device(device)?;

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,
Expand Down

0 comments on commit b17c303

Please sign in to comment.