From 076ed868091720a1226921d053a36fb5eb3b516d Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Fri, 31 Mar 2023 09:31:25 -0700 Subject: [PATCH] Minor heap creation improvements. --- src/gpgmm/d3d12/DebugObjectD3D12.cpp | 4 ++++ src/gpgmm/d3d12/HeapD3D12.cpp | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gpgmm/d3d12/DebugObjectD3D12.cpp b/src/gpgmm/d3d12/DebugObjectD3D12.cpp index 1336d5e34..9bc0a22dc 100644 --- a/src/gpgmm/d3d12/DebugObjectD3D12.cpp +++ b/src/gpgmm/d3d12/DebugObjectD3D12.cpp @@ -19,6 +19,10 @@ namespace gpgmm::d3d12 { LPCWSTR DebugObject::GetDebugName() const { + if (mDebugName.empty()) { + return L"'Unknown'"; + } + return mDebugName.c_str(); } diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index a487bbf14..b73689fe0 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -68,6 +68,8 @@ namespace gpgmm::d3d12 { CreateHeapFn createHeapFn, void* pCreateHeapContext, IHeap** ppHeapOut) { + ReturnIfNullptr(pCreateHeapContext); + const bool isResidencyDisabled = (pResidencyManager == nullptr); ResidencyManager* residencyManager = static_cast(pResidencyManager); @@ -94,7 +96,8 @@ namespace gpgmm::d3d12 { } ComPtr pageable; - ReturnIfFailed(createHeapFn(pCreateHeapContext, &pageable)); + ReturnIfFailedDevice(createHeapFn(pCreateHeapContext, &pageable), + GetDevice(pageable.Get())); // Pageable-based type is required for residency-managed heaps. ReturnIfNullptr(pageable); @@ -148,16 +151,14 @@ namespace gpgmm::d3d12 { } } - const std::string debugName = - (heap->GetDebugName() == nullptr) ? WCharToUTF8(heap->GetDebugName()) : "'Unknown'"; + ReturnIfFailed(heap->SetDebugName(descriptor.DebugName)); + GPGMM_TRACE_EVENT_OBJECT_SNAPSHOT(heap.get(), descriptor); + gpgmm::DebugLog(MessageId::kMemoryAllocated) - << "Created heap (" << debugName << "=" << ToHexStr(heap.get()) + << "Created heap (" << WCharToUTF8(heap->GetDebugName()) << "=" << ToHexStr(heap.get()) << "), Size=" << heap->GetInfo().SizeInBytes << ", ID3D12Pageable=" << ToHexStr(heap->mPageable.Get()); - ReturnIfFailed(heap->SetDebugName(descriptor.DebugName)); - GPGMM_TRACE_EVENT_OBJECT_SNAPSHOT(heap.get(), descriptor); - if (ppHeapOut != nullptr) { *ppHeapOut = heap.release(); }