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>
This commit is contained in:
Corentin Wallez 2020-05-12 17:44:23 +00:00 committed by Commit Bot service account
parent 4fa5ad4bf0
commit b6eeee0aa3
1 changed files with 6 additions and 3 deletions

View File

@ -152,10 +152,13 @@ namespace dawn_native { namespace vulkan {
// 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.