diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 9b0026f504e..9f89dead1d1 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -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, diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index 6c7b26b7867..1f1cafaf5ef 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -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), } diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index f06249fc789..ff81e80370c 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -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,