From 158515fec368025ec5e11431f2b984fee8fe2122 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 21 Nov 2024 10:22:58 -0500 Subject: [PATCH] fix(core): validate `dst_buffer` isn't destroyed when resolving query sets --- CHANGELOG.md | 1 + wgpu-core/src/command/query.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dee57f6e78..2526f58e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -131,6 +131,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148] - Lower `QUERY_SET_MAX_QUERIES` (and enforced limits) from 8192 to 4096 to match WebGPU spec. By @ErichDonGubler in [#6525](https://github.com/gfx-rs/wgpu/pull/6525). - Allow non-filterable float on texture bindings never used with samplers when using a derived bind group layout. By @ErichDonGubler in [#6531](https://github.com/gfx-rs/wgpu/pull/6531/). - Replace potentially unsound usage of `PreHashedMap` with `FastHashMap`. By @jamienicol in [#6541](https://github.com/gfx-rs/wgpu/pull/6541). +- Reject destroyed buffers in query set resolution. By @ErichDonGubler in [#6579](https://github.com/gfx-rs/wgpu/pull/6579). #### Naga diff --git a/wgpu-core/src/command/query.rs b/wgpu-core/src/command/query.rs index d783721fb4..d7e0b88f38 100644 --- a/wgpu-core/src/command/query.rs +++ b/wgpu-core/src/command/query.rs @@ -387,13 +387,14 @@ impl Global { dst_buffer.same_device_as(cmd_buf.as_ref())?; + let snatch_guard = dst_buffer.device.snatchable_lock.read(); + dst_buffer.check_destroyed(&snatch_guard)?; + let dst_pending = cmd_buf_data .trackers .buffers .set_single(&dst_buffer, hal::BufferUses::COPY_DST); - let snatch_guard = dst_buffer.device.snatchable_lock.read(); - let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer, &snatch_guard)); dst_buffer