From 12fe0d430f4fad4df4f5b03ed91e0ee5b51aebb1 Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Fri, 20 Jan 2023 09:32:56 -0800 Subject: [PATCH] Improve error log messages. --- src/gpgmm/d3d12/HeapD3D12.cpp | 7 +++++-- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 13 +++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index 61fbdbaa6..df622b80a 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -77,8 +77,11 @@ namespace gpgmm::d3d12 { // Ensure enough budget exists before creating the heap to avoid an out-of-memory error. if (!isResidencyDisabled && (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_BUDGET)) { - ReturnIfFailed(residencyManager->EnsureInBudget(descriptor.SizeInBytes, - descriptor.MemorySegmentGroup)); + if (FAILED(residencyManager->EnsureInBudget(descriptor.SizeInBytes, + descriptor.MemorySegmentGroup))) { + gpgmm::ErrorLog() << "Unable to create heap because not enough budget exists."; + return E_OUTOFMEMORY; + } } ComPtr pageable; diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 2b4386d9b..8c7dbc967 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -926,6 +926,8 @@ namespace gpgmm::d3d12 { const D3D12_RESOURCE_ALLOCATION_INFO resourceInfo = GetResourceAllocationInfo(mDevice.Get(), newResourceDesc); if (resourceInfo.SizeInBytes > mCaps->GetMaxResourceSize()) { + gpgmm::ErrorLog() << "Unable to create resource allocation because the size exceeded " + "capabilities of the device."; return E_OUTOFMEMORY; } @@ -962,6 +964,9 @@ namespace gpgmm::d3d12 { const RESOURCE_HEAP_TYPE resourceHeapType = GetResourceHeapType( newResourceDesc.Dimension, heapType, newResourceDesc.Flags, mResourceHeapTier); if (resourceHeapType == RESOURCE_HEAP_TYPE_INVALID) { + gpgmm::ErrorLog() + << "Unable to create resource allocation because the resource type was invalid due " + "to the combination of resource flags, descriptor, and resource heap tier."; return E_INVALIDARG; } @@ -1193,12 +1198,15 @@ namespace gpgmm::d3d12 { // allocations where sub-allocation or pooling is otherwise ineffective. // The time and space complexity of committed resource is driver-defined. if (request.NeverAllocate) { + ErrorLog() << "Unable to allocate memory for resource because no memory was allowed to " + "be created."; return E_OUTOFMEMORY; } // Committed resources cannot specify resource heap size. if (GPGMM_UNLIKELY(requiresPadding)) { - ErrorLog() << "A padding was specified but no resource allocator could be used."; + ErrorLog() << "Unable to allocate memory for resource because a padding was specified " + "but no resource allocator could be used."; return E_FAIL; } @@ -1207,7 +1215,8 @@ namespace gpgmm::d3d12 { return E_FAIL; } InfoEvent(this, EventMessageId::kAllocatorFailed) - << "Unable to allocate by using a heap, falling back to a committed resource."; + << "Unable to allocate memory for a resource by using a heap, falling back to a " + "committed resource."; } ComPtr committedResource;