-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area: validationIssues related to validation, diagnostics, and error handlingIssues related to validation, diagnostics, and error handlingtype: bugSomething isn't workingSomething isn't working
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
Labels
area: validationIssues related to validation, diagnostics, and error handlingIssues related to validation, diagnostics, and error handlingtype: bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done
Milestone
Relationships
Development
Select code repository
Activity
teoxoy commentedon Apr 14, 2025
For
DestroyedResourceError
, we also need to accumulate those and only report them onqueue.submit()
.sagudev commentedon Apr 14, 2025
In servo we have hashmap of encoders and their errors:
https://github.com/servo/servo/blob/440739090f85a6d5ba2e26978ad9c77771e7f4af/components/webgpu/wgpu_thread.rs#L102-L105
so we store errors and raise them in finish. It's ugly, but that's what we've been using way before I touched webgpu.
Related bug is #5854.
CommandEncoder.finish()
#7679size
parameter optional #7659andyleiserson commentedon Jun 9, 2025
To give a sense of what I am planning, here is the changelog entry I have drafted for this:
4 remaining items
andyleiserson commentedon Jun 10, 2025
This branch has most of the upcoming error reporting changes (I still need to do render bundles). Note that link has
w=1
to suppress whitespace in the diff, which makes it a lot smaller. I don't see a suppress whitespace option in the UI for GitHub's non-PR compare view; I addedw=1
to the URL manually.mappable-primary-buffers
feature #7796cannot remove a vacant resource
panics running in deno #7797CommandEncoder.finish
is called #7820