From c530ac3bff3c25e0a80ec8f2d74dc280b65e7810 Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Tue, 14 Feb 2023 09:29:53 -0800 Subject: [PATCH] Improve Heap::CreateHeap out-of-memory error messages. --- src/gpgmm/d3d12/HeapD3D12.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index f009476a3..81c731a56 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -15,6 +15,7 @@ #include "gpgmm/d3d12/HeapD3D12.h" +#include "gpgmm/common/SizeClass.h" #include "gpgmm/common/TraceEvent.h" #include "gpgmm/d3d12/ErrorD3D12.h" #include "gpgmm/d3d12/JSONSerializerD3D12.h" @@ -79,7 +80,19 @@ namespace gpgmm::d3d12 { if (!isResidencyDisabled && (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_BUDGET)) { if (FAILED(residencyManager->EnsureInBudget(descriptor.SizeInBytes, descriptor.MemorySegmentGroup))) { - gpgmm::ErrorLog() << "Unable to create heap because not enough budget exists."; + DXGI_QUERY_VIDEO_MEMORY_INFO currentVideoInfo = {}; + ReturnIfFailed(residencyManager->QueryVideoMemoryInfo(descriptor.MemorySegmentGroup, + ¤tVideoInfo)); + + gpgmm::ErrorLog(MessageId::kBudgetExceeded) + << "Unable to create heap because not enough budget exists (" + << GPGMM_BYTES_TO_MB(descriptor.SizeInBytes) << " vs " + << GPGMM_BYTES_TO_MB((currentVideoInfo.Budget > currentVideoInfo.CurrentUsage) + ? currentVideoInfo.Budget - + currentVideoInfo.CurrentUsage + : 0) + << " MBs) and HEAP_FLAG_ALWAYS_IN_BUDGET was specified."; + return E_OUTOFMEMORY; } }