Skip to content

Commit 114be5e

Browse files
fix(core): validate that begin and end indices of pass timestamp writes are not equal
1 parent eb17b31 commit 114be5e

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

wgpu-core/src/command/compute.rs

+9
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ impl Global {
345345
}
346346
}
347347

348+
if let Some((begin, end)) = beginning_of_pass_write_index.zip(end_of_pass_write_index) {
349+
if begin == end {
350+
return make_err(
351+
CommandEncoderError::TimestampWriteIndicesEqual { idx: begin },
352+
arc_desc,
353+
);
354+
}
355+
}
356+
348357
Some(ArcPassTimestampWrites {
349358
query_set,
350359
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,

wgpu-core/src/command/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,10 @@ pub enum CommandEncoderError {
654654
InvalidResource(#[from] InvalidResourceError),
655655
#[error(transparent)]
656656
MissingFeatures(#[from] MissingFeatures),
657+
#[error(
658+
"begin and end indices of pass timestamp writes are both set to {idx}, which is not allowed"
659+
)]
660+
TimestampWriteIndicesEqual { idx: u32 },
657661
#[error(transparent)]
658662
TimestampWritesInvalid(#[from] QueryUseError),
659663
}

wgpu-core/src/command/render.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,14 @@ impl Global {
14121412
query_set.validate_query(SimplifiedQueryType::Timestamp, idx, None)?;
14131413
}
14141414

1415+
if let Some((begin, end)) =
1416+
beginning_of_pass_write_index.zip(end_of_pass_write_index)
1417+
{
1418+
if begin == end {
1419+
return Err(CommandEncoderError::TimestampWriteIndicesEqual { idx: begin });
1420+
}
1421+
}
1422+
14151423
Some(ArcPassTimestampWrites {
14161424
query_set,
14171425
beginning_of_pass_write_index: tw.beginning_of_pass_write_index,

0 commit comments

Comments
 (0)