diff --git a/deno_webgpu/buffer.rs b/deno_webgpu/buffer.rs index e0b0e50d3..9a4900112 100644 --- a/deno_webgpu/buffer.rs +++ b/deno_webgpu/buffer.rs @@ -27,7 +27,7 @@ impl Resource for WebGpuBuffer { } fn close(self: Rc) { - gfx_select!(self.1 => self.0.buffer_drop(self.1, true)); + gfx_select!(self.1 => self.0.buffer_drop(self.1)); } } diff --git a/deno_webgpu/texture.rs b/deno_webgpu/texture.rs index 2dc1a740a..8acba2499 100644 --- a/deno_webgpu/texture.rs +++ b/deno_webgpu/texture.rs @@ -24,7 +24,7 @@ impl Resource for WebGpuTexture { fn close(self: Rc) { if self.owned { let instance = &self.instance; - gfx_select!(self.id => instance.texture_drop(self.id, true)); + gfx_select!(self.id => instance.texture_drop(self.id)); } } } @@ -39,7 +39,7 @@ impl Resource for WebGpuTextureView { } fn close(self: Rc) { - gfx_select!(self.1 => self.0.texture_view_drop(self.1, true)).unwrap(); + gfx_select!(self.1 => self.0.texture_view_drop(self.1)).unwrap(); } } diff --git a/player/src/lib.rs b/player/src/lib.rs index cf89b2469..3bbcbfdb1 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -157,7 +157,7 @@ impl GlobalPlay for wgc::global::Global { self.buffer_destroy::(id).unwrap(); } Action::DestroyBuffer(id) => { - self.buffer_drop::(id, true); + self.buffer_drop::(id); } Action::CreateTexture(id, desc) => { let (_, error) = self.device_create_texture::(device, &desc, Some(id)); @@ -169,7 +169,7 @@ impl GlobalPlay for wgc::global::Global { self.texture_destroy::(id).unwrap(); } Action::DestroyTexture(id) => { - self.texture_drop::(id, true); + self.texture_drop::(id); } Action::CreateTextureView { id, @@ -182,7 +182,7 @@ impl GlobalPlay for wgc::global::Global { } } Action::DestroyTextureView(id) => { - self.texture_view_drop::(id, true).unwrap(); + self.texture_view_drop::(id).unwrap(); } Action::CreateSampler(id, desc) => { let (_, error) = self.device_create_sampler::(device, &desc, Some(id)); diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 96727b04f..1e5db459c 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -409,7 +409,7 @@ impl Global { buffer.destroy() } - pub fn buffer_drop(&self, buffer_id: id::BufferId, wait: bool) { + pub fn buffer_drop(&self, buffer_id: id::BufferId) { profiling::scope!("Buffer::drop"); api_log!("Buffer::drop {buffer_id:?}"); @@ -431,20 +431,6 @@ impl Global { #[cfg(feature = "trace")] buffer_id, ); - - if wait { - let Some(last_submit_index) = buffer - .device - .lock_life() - .get_buffer_latest_submission_index(&buffer) - else { - return; - }; - match buffer.device.wait_for_submit(last_submit_index) { - Ok(()) => (), - Err(e) => log::error!("Failed to wait for buffer {:?}: {}", buffer_id, e), - } - } } pub fn device_create_texture( @@ -601,31 +587,17 @@ impl Global { texture.destroy() } - pub fn texture_drop(&self, texture_id: id::TextureId, wait: bool) { + pub fn texture_drop(&self, texture_id: id::TextureId) { profiling::scope!("Texture::drop"); api_log!("Texture::drop {texture_id:?}"); let hub = A::hub(self); - if let Some(texture) = hub.textures.unregister(texture_id) { + if let Some(_texture) = hub.textures.unregister(texture_id) { #[cfg(feature = "trace")] - if let Some(t) = texture.device.trace.lock().as_mut() { + if let Some(t) = _texture.device.trace.lock().as_mut() { t.add(trace::Action::DestroyTexture(texture_id)); } - - if wait { - let Some(last_submit_index) = texture - .device - .lock_life() - .get_texture_latest_submission_index(&texture) - else { - return; - }; - match texture.device.wait_for_submit(last_submit_index) { - Ok(()) => (), - Err(e) => log::error!("Failed to wait for texture {texture_id:?}: {e}"), - } - } } } @@ -679,34 +651,17 @@ impl Global { pub fn texture_view_drop( &self, texture_view_id: id::TextureViewId, - wait: bool, ) -> Result<(), resource::TextureViewDestroyError> { profiling::scope!("TextureView::drop"); api_log!("TextureView::drop {texture_view_id:?}"); let hub = A::hub(self); - if let Some(view) = hub.texture_views.unregister(texture_view_id) { + if let Some(_view) = hub.texture_views.unregister(texture_view_id) { #[cfg(feature = "trace")] - if let Some(t) = view.device.trace.lock().as_mut() { + if let Some(t) = _view.device.trace.lock().as_mut() { t.add(trace::Action::DestroyTextureView(texture_view_id)); } - - if wait { - let Some(last_submit_index) = view - .device - .lock_life() - .get_texture_latest_submission_index(&view.parent) - else { - return Ok(()); - }; - match view.device.wait_for_submit(last_submit_index) { - Ok(()) => (), - Err(e) => { - log::error!("Failed to wait for texture view {texture_view_id:?}: {e}") - } - } - } } Ok(()) } diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 9f8f48e56..8f9f5022d 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -32,7 +32,7 @@ use crate::{ UsageScopePool, }, validation::{self, validate_color_attachment_bytes_per_sample}, - FastHashMap, LabelHelpers as _, PreHashedKey, PreHashedMap, SubmissionIndex, + FastHashMap, LabelHelpers as _, PreHashedKey, PreHashedMap, }; use arrayvec::ArrayVec; @@ -3474,9 +3474,10 @@ impl Device { } } + #[cfg(feature = "replay")] pub(crate) fn wait_for_submit( &self, - submission_index: SubmissionIndex, + submission_index: crate::SubmissionIndex, ) -> Result<(), WaitIdleError> { let guard = self.fence.read(); let fence = guard.as_ref().unwrap(); diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index cc4ad9b99..780655249 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -1651,7 +1651,7 @@ impl crate::Context for ContextWgpuCore { } fn buffer_drop(&self, buffer: &Self::BufferId, _buffer_data: &Self::BufferData) { - wgc::gfx_select!(buffer => self.0.buffer_drop(*buffer, false)) + wgc::gfx_select!(buffer => self.0.buffer_drop(*buffer)) } fn texture_destroy(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) { @@ -1660,7 +1660,7 @@ impl crate::Context for ContextWgpuCore { } fn texture_drop(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) { - wgc::gfx_select!(texture => self.0.texture_drop(*texture, false)) + wgc::gfx_select!(texture => self.0.texture_drop(*texture)) } fn texture_view_drop( @@ -1668,7 +1668,7 @@ impl crate::Context for ContextWgpuCore { texture_view: &Self::TextureViewId, __texture_view_data: &Self::TextureViewData, ) { - let _ = wgc::gfx_select!(*texture_view => self.0.texture_view_drop(*texture_view, false)); + let _ = wgc::gfx_select!(*texture_view => self.0.texture_view_drop(*texture_view)); } fn sampler_drop(&self, sampler: &Self::SamplerId, _sampler_data: &Self::SamplerData) {