Closed
Description
Many WebGPU CTS tests exercise validation of command encoders with error scopes used this way:
- Set up a device and a command encoder.
- Do something invalid during command encoding, like using an occlusion query in a
GPURenderPassDescriptor.timestampWrites
. - Push an error scope,
finish
the command encoder, and pop an error scope to check if there was a validation error.
WGPU emits errors for validation during command encoding before calling CommandEncoder::finish
, and it shouldn't. It's difficult to cite spec. text that is not present, but the easiest way to summarize is that "generate a validation error" does not show up in the validation steps performed by the various methods of GPUCommandEncoder
and {Compute,Render}PassEncoder
except for GPUCommandEncoder.finish
.
Steps to reproduce
[package]
name = "wgpu-cmd-enc-finish-validation-bruh"
version = "0.1.0"
edition = "2024"
[dependencies]
pollster = "0.4.0"
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "1e172b2e1461724eb7ded00b6520732db1c5ae92" }
use pollster::FutureExt as _;
fn main() {
let instance = wgpu::Instance::new(&Default::default());
let adapter = instance
.request_adapter(&Default::default())
.block_on()
.unwrap();
let (device, queue) = adapter
.request_device(&Default::default())
.block_on()
.unwrap();
let occlusion_query = device.create_query_set(&wgpu::QuerySetDescriptor {
label: None,
ty: wgpu::QueryType::Occlusion,
count: 1,
});
let mut command_encoder = device.create_command_encoder(&Default::default());
{
let mut _render_pass = command_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
timestamp_writes: Some(wgpu::RenderPassTimestampWrites {
query_set: &occlusion_query,
beginning_of_pass_write_index: Some(0),
end_of_pass_write_index: Some(1),
}),
..Default::default()
});
}
device.push_error_scope(wgpu::ErrorFilter::Validation);
let _cmd_buf = command_encoder.finish();
device.pop_error_scope().block_on().unwrap();
queue.submit([_cmd_buf]);
}
Suggested implementation design
- The MVP for this is to stop emitting validation errors on
CommandEncoder
,RenderPassEncoder
, andComputePassEncoder
methods. These methods already invalidate the associatedCommandEncoder
and other objects when failing validation, so no action should be needed there. - The above loses some significant diagnostic quality. We'll probably want to store the first validation error a command encoder encounters, to counter this.
This issue is likely to become a meta issue, since the API surface to which this issue applies is pretty broad.
Metadata
Metadata
Assignees
Type
Projects
Status
Done