Skip to content

Commit

Permalink
[d3d12] Drop resource before free suballocation (#5943)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopengli89 authored Jul 11, 2024
1 parent 750f72a commit 349f182
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions wgpu-hal/src/dx12/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 349f182

Please sign in to comment.