From d6ca9462e4dea5d3989c66cdbae8d06e81fa128d Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Mon, 8 Dec 2025 18:17:52 -0800 Subject: [PATCH] Fix panic if indirect buffer has been destroyed (#8689) --- cts_runner/test.lst | 2 ++ wgpu-core/src/indirect_validation/draw.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cts_runner/test.lst b/cts_runner/test.lst index 287292429..e130d96f2 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -65,6 +65,8 @@ webgpu:api,validation,encoding,cmds,index_access:* webgpu:api,validation,encoding,cmds,render,draw:index_buffer_OOB:* webgpu:api,validation,encoding,cmds,render,draw:unused_buffer_bound:* webgpu:api,validation,encoding,cmds,render,dynamic_state:* +webgpu:api,validation,encoding,cmds,render,indirect_draw:indirect_buffer,device_mismatch:* +webgpu:api,validation,encoding,cmds,render,indirect_draw:indirect_buffer_usage:* webgpu:api,validation,encoding,cmds,render,setIndexBuffer:* webgpu:api,validation,encoding,cmds,render,setVertexBuffer:* webgpu:api,validation,encoding,encoder_state:* diff --git a/wgpu-core/src/indirect_validation/draw.rs b/wgpu-core/src/indirect_validation/draw.rs index 888d2d7f9..1d28da469 100644 --- a/wgpu-core/src/indirect_validation/draw.rs +++ b/wgpu-core/src/indirect_validation/draw.rs @@ -3,10 +3,11 @@ use super::{ CreateIndirectValidationPipelineError, }; use crate::{ + command::RenderPassErrorInner, device::{queue::TempResource, Device, DeviceError}, lock::{rank, Mutex}, pipeline::{CreateComputePipelineError, CreateShaderModuleError}, - resource::{StagingBuffer, Trackable}, + resource::{RawResourceAccess as _, StagingBuffer, Trackable}, snatch::SnatchGuard, track::TrackerIndex, FastHashMap, @@ -199,7 +200,7 @@ impl Draw { temp_resources: &mut Vec, encoder: &mut dyn hal::DynCommandEncoder, batcher: DrawBatcher, - ) -> Result<(), DeviceError> { + ) -> Result<(), RenderPassErrorInner> { let mut batches = batcher.batches; if batches.is_empty() { @@ -378,6 +379,9 @@ impl Draw { encoder.set_bind_group(pipeline_layout, 0, Some(metadata_bind_group), &[]); } + // Make sure the indirect buffer is still valid. + batch.src_buffer.try_raw(snatch_guard)?; + let src_bind_group = batch .src_buffer .indirect_validation_bind_groups