Vulkan: Fix ResourceHeap leak for direct-allocated resources.

Bug: chromium:1081051
Change-Id: I1f68ebf21033fb9cf925b5cbc3915667b61290fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21460
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn_native/vulkan/ResourceMemoryAllocatorVk.cpp b/src/dawn_native/vulkan/ResourceMemoryAllocatorVk.cpp
index e038d02..cff7434 100644
--- a/src/dawn_native/vulkan/ResourceMemoryAllocatorVk.cpp
+++ b/src/dawn_native/vulkan/ResourceMemoryAllocatorVk.cpp
@@ -152,10 +152,13 @@
 
             // For direct allocation we can put the memory for deletion immediately and the fence
             // deleter will make sure the resources are freed before the memory.
-            case AllocationMethod::kDirect:
-                mDevice->GetFencedDeleter()->DeleteWhenUnused(
-                    ToBackend(allocation->GetResourceHeap())->GetMemory());
+            case AllocationMethod::kDirect: {
+                ResourceHeap* heap = ToBackend(allocation->GetResourceHeap());
+                allocation->Invalidate();
+                mDevice->GetFencedDeleter()->DeleteWhenUnused(heap->GetMemory());
+                delete heap;
                 break;
+            }
 
             // Suballocations aren't freed immediately, otherwise another resource allocation could
             // happen just after that aliases the old one and would require a barrier.