diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index eeb60acbf6..e8104abfbb 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -404,6 +404,9 @@ impl crate::Device for super::Device { unsafe fn destroy_buffer(&self, mut buffer: super::Buffer) { // Only happens when it's using the windows_rs feature and there's an allocation if let Some(alloc) = buffer.allocation.take() { + // Resource should be dropped before free suballocation + drop(buffer); + super::suballocation::free_buffer_allocation( self, alloc, @@ -494,6 +497,9 @@ impl crate::Device for super::Device { unsafe fn destroy_texture(&self, mut texture: super::Texture) { if let Some(alloc) = texture.allocation.take() { + // Resource should be dropped before free suballocation + drop(texture); + super::suballocation::free_texture_allocation( self, alloc,