Skip to content

Commit 7722c34

Browse files
committed
Defer destroyed resource errors until cmdbuf submission
1 parent 41badae commit 7722c34

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

cts_runner/test.lst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ webgpu:api,operation,compute,basic:memcpy:*
55
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*
66
webgpu:api,operation,compute_pipeline,overrides:*
77
webgpu:api,operation,device,lost:*
8-
webgpu:api,validation,encoding,cmds,clearBuffer:out_of_bounds,*
8+
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="valid"
9+
//FAIL: webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="invalid"
10+
// https://github.com/gfx-rs/wgpu/issues/7796 (Mac only)
11+
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="destroyed"
12+
webgpu:api,validation,encoding,cmds,clearBuffer:buffer,device_mismatch:*
13+
webgpu:api,validation,encoding,cmds,clearBuffer:default_args:*
14+
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_usage:*
15+
webgpu:api,validation,encoding,cmds,clearBuffer:size_alignment:*
16+
webgpu:api,validation,encoding,cmds,clearBuffer:offset_alignment:*
17+
webgpu:api,validation,encoding,cmds,clearBuffer:overflow:*
18+
webgpu:api,validation,encoding,cmds,clearBuffer:out_of_bounds:*
919
webgpu:api,validation,encoding,cmds,compute_pass:set_pipeline:*
1020
webgpu:api,validation,encoding,cmds,compute_pass:dispatch_sizes:*
1121
webgpu:api,validation,encoding,cmds,copyTextureToTexture:copy_with_invalid_or_destroyed_texture:*

wgpu-core/src/command/mod.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,15 +803,16 @@ impl CommandBuffer {
803803
}
804804

805805
impl CommandBuffer {
806-
pub fn take_finished<'a>(&'a self) -> Result<CommandBufferMutable, InvalidResourceError> {
806+
pub fn take_finished(&self) -> Result<CommandBufferMutable, CommandEncoderError> {
807807
use CommandEncoderStatus as St;
808808
match mem::replace(
809809
&mut *self.data.lock(),
810810
CommandEncoderStatus::Error(EncoderStateError::Submitted.into()),
811811
) {
812812
St::Finished(command_buffer_mutable) => Ok(command_buffer_mutable),
813-
St::Recording(_) | St::Locked(_) | St::Error(_) => {
814-
Err(InvalidResourceError(self.error_ident()))
813+
St::Error(err) => Err(err),
814+
St::Recording(_) | St::Locked(_) => {
815+
Err(InvalidResourceError(self.error_ident()).into())
815816
}
816817
St::Transitioning => unreachable!(),
817818
}
@@ -1003,6 +1004,25 @@ pub enum CommandEncoderError {
10031004
RenderPass(#[from] RenderPassError),
10041005
}
10051006

1007+
impl CommandEncoderError {
1008+
fn is_destroyed_error(&self) -> bool {
1009+
matches!(
1010+
self,
1011+
Self::DestroyedResource(_)
1012+
| Self::Clear(ClearError::DestroyedResource(_))
1013+
| Self::Query(QueryError::DestroyedResource(_))
1014+
| Self::ComputePass(ComputePassError {
1015+
inner: ComputePassErrorInner::DestroyedResource(_),
1016+
..
1017+
})
1018+
| Self::RenderPass(RenderPassError {
1019+
inner: RenderPassErrorInner::DestroyedResource(_),
1020+
..
1021+
})
1022+
)
1023+
}
1024+
}
1025+
10061026
#[derive(Clone, Debug, Error)]
10071027
#[non_exhaustive]
10081028
pub enum TimestampWritesError {
@@ -1026,9 +1046,11 @@ impl Global {
10261046

10271047
let cmd_buf = hub.command_buffers.get(encoder_id.into_command_buffer_id());
10281048

1049+
// Errors related to destroyed resources are not reported until the
1050+
// command buffer is submitted.
10291051
let error = match cmd_buf.data.lock().finish() {
1030-
Ok(_) => None,
1031-
Err(e) => Some(e),
1052+
Err(e) if !e.is_destroyed_error() => Some(e),
1053+
_ => None,
10321054
};
10331055

10341056
(encoder_id.into_command_buffer_id(), error)

0 commit comments

Comments
 (0)