From 5d6ecc4237a86551bc33547ea4a452bef66d3a70 Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Thu, 24 Aug 2023 17:13:34 -0700 Subject: [PATCH] Always unlock released resource allocations. --- src/gpgmm/d3d12/ResourceAllocationD3D12.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp index bd0b4e138..270039c32 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp @@ -69,6 +69,17 @@ namespace gpgmm::d3d12 { "call Unmap the same number of times as Map before releasing the resource " "allocation."; } + + // If the developer forgots to unlock the heap, do so now so the heap can be made eligable + // for eviction. + if (mResidencyManager != nullptr) { + mResidencyManager->UnlockHeap(GetMemory()); + WarnLog(MessageId::kPerformanceWarning, this) + << "Destroying a locked resource allocation is allowed but discouraged. Please " + "call UnlockHeap the same number of times as LockHeap before releasing the " + "resource " + "allocation."; + } } void ResourceAllocation::DeleteThis() {