From 47bfede63f82e09f5e50e9735c6d98dd19403d3c Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:49:47 +0100 Subject: [PATCH] Add `device_unregister_device_lost_closure` (#6588) Co-authored-by: Erich Gubler --- wgpu-core/src/device/global.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index f9b6794b4..42881f1bd 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -2102,6 +2102,14 @@ impl Global { } } + pub fn device_unregister_device_lost_closure(&self, device_id: DeviceId) { + let device = self.hub.devices.get(device_id); + let closure = device.device_lost_closure.lock().take(); + if let Some(closure) = closure { + closure.call(DeviceLostReason::ReplacedCallback, "".to_string()); + } + } + pub fn device_destroy(&self, device_id: DeviceId) { api_log!("Device::destroy {device_id:?}");