Skip to content

Commit d41e43b

Browse files
authored
[wgpu-core] validate occlusion and pipeline statistics queries end (#8684)
1 parent 51490ea commit d41e43b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

cts_runner/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,4 @@ webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="l
180180
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="switch1"
181181
//FAIL: 9 invalid_statements subtests due to https://github.com/gfx-rs/wgpu/issues/7733
182182
webgpu:api,validation,render_pipeline,vertex_state:many_attributes_overlapping:*
183+
webgpu:api,validation,encoding,queries,begin_end:occlusion_query,*

wgpu-core/src/command/query.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ pub enum QueryUseError {
150150
set_type: SimplifiedQueryType,
151151
query_type: SimplifiedQueryType,
152152
},
153+
#[error("A query of type {query_type:?} was not ended before the encoder was finished")]
154+
MissingEnd { query_type: SimplifiedQueryType },
153155
}
154156

155157
impl WebGpuError for QueryUseError {
@@ -160,7 +162,8 @@ impl WebGpuError for QueryUseError {
160162
| Self::UsedTwiceInsideRenderpass { .. }
161163
| Self::AlreadyStarted { .. }
162164
| Self::AlreadyStopped
163-
| Self::IncompatibleType { .. } => ErrorType::Validation,
165+
| Self::IncompatibleType { .. }
166+
| Self::MissingEnd { .. } => ErrorType::Validation,
164167
}
165168
}
166169
}

wgpu-core/src/command/render.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,18 @@ pub(super) fn encode_render_pass(
22412241
.map_pass_err(pass_scope),
22422242
)?;
22432243
}
2244+
if state.active_occlusion_query.is_some() {
2245+
Err(RenderPassErrorInner::QueryUse(QueryUseError::MissingEnd {
2246+
query_type: super::SimplifiedQueryType::Occlusion,
2247+
})
2248+
.map_pass_err(pass_scope))?;
2249+
}
2250+
if state.active_pipeline_statistics_query.is_some() {
2251+
Err(RenderPassErrorInner::QueryUse(QueryUseError::MissingEnd {
2252+
query_type: super::SimplifiedQueryType::PipelineStatistics,
2253+
})
2254+
.map_pass_err(pass_scope))?;
2255+
}
22442256

22452257
state
22462258
.info

0 commit comments

Comments
 (0)