From 349f182966aff62e02f3ad7e29b375b9f477c93a Mon Sep 17 00:00:00 2001 From: Xiaopeng Li Date: Thu, 11 Jul 2024 19:07:30 +0800 Subject: [PATCH] [d3d12] Drop resource before free suballocation (#5943) --- wgpu-hal/src/dx12/device.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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,