From 60a5d8e0dc3c1f45ef4e85512ad631b76d87a99e Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Mon, 6 Mar 2023 09:47:04 -0800 Subject: [PATCH] Apply HEAP_FLAG_ALWAYS_IN_RESIDENCY by default. --- src/gpgmm/d3d12/HeapD3D12.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index d941f0fc7..5edd9b0b0 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -47,11 +47,11 @@ namespace gpgmm::d3d12 { HEAP_FLAGS GetHeapFlags(D3D12_HEAP_FLAGS heapFlags, bool isResidencyEnabled) { if (heapFlags & D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT) { - return HEAP_FLAG_NONE; + return HEAP_FLAG_NONE | HEAP_FLAG_ALWAYS_IN_RESIDENCY; } if (isResidencyEnabled) { - return HEAP_FLAG_ALWAYS_IN_BUDGET; + return HEAP_FLAG_ALWAYS_IN_BUDGET | HEAP_FLAG_ALWAYS_IN_RESIDENCY; } return HEAP_FLAG_NONE; @@ -140,8 +140,16 @@ namespace gpgmm::d3d12 { if (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_RESIDENCY) { ReturnIfFailed(residencyManager->LockHeap(heap.get())); ReturnIfFailed(residencyManager->UnlockHeap(heap.get())); + ASSERT(heap->mState == RESIDENCY_STATUS_CURRENT_RESIDENT); } } + } else { + if (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_RESIDENCY) { + gpgmm::WarningLog(MessageId::kInvalidArgument) + << "HEAP_FLAG_ALWAYS_IN_RESIDENCY was specified but had no effect becauase " + "residency management is " + "not being used."; + } } ReturnIfFailed(heap->SetDebugName(descriptor.DebugName));