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 21, 2024
1 parent eb17b31 commit 114be5e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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: tw.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: tw.beginning_of_pass_write_index,
Expand Down

0 comments on commit 114be5e

Please sign in to comment.