Skip to content

Commit

Permalink
fix(core): validate that begin and end indices of pass timestamp writ…
Browse files Browse the repository at this point in the history
…es are not equal
  • Loading branch information
ErichDonGubler committed Nov 22, 2024
1 parent be50bdf commit f1ec934
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
- 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.
- Check that indices are in-bounds for the query set.
- Check that begin and end indices are not equal.

#### Naga

Expand Down
9 changes: 9 additions & 0 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ impl Global {
}
}

if let Some((begin, end)) = beginning_of_pass_write_index.zip(end_of_pass_write_index) {
if begin == end {
return make_err(
CommandEncoderError::TimestampWriteIndicesEqual { idx: begin },
arc_desc,
);
}
}

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index,
Expand Down
4 changes: 4 additions & 0 deletions wgpu-core/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,10 @@ pub enum CommandEncoderError {
InvalidResource(#[from] InvalidResourceError),
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
#[error(
"begin and end indices of pass timestamp writes are both set to {idx}, which is not allowed"
)]
TimestampWriteIndicesEqual { idx: u32 },
#[error(transparent)]
TimestampWritesInvalid(#[from] QueryUseError),
}
Expand Down
8 changes: 8 additions & 0 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,14 @@ impl Global {
query_set.validate_query(SimplifiedQueryType::Timestamp, idx, None)?;
}

if let Some((begin, end)) =
beginning_of_pass_write_index.zip(end_of_pass_write_index)
{
if begin == end {
return Err(CommandEncoderError::TimestampWriteIndicesEqual { idx: begin });
}
}

Some(ArcPassTimestampWrites {
query_set,
beginning_of_pass_write_index,
Expand Down

0 comments on commit f1ec934

Please sign in to comment.