From 7e94dd1eaf4edbcf7f11646e5776b857632d5f3e Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Mon, 6 Feb 2023 15:12:24 -0800 Subject: [PATCH] Add error logging for E_POINTER. --- src/gpgmm/d3d12/ErrorD3D12.h | 15 ++++++++------- src/gpgmm/d3d12/HeapD3D12.cpp | 5 +---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gpgmm/d3d12/ErrorD3D12.h b/src/gpgmm/d3d12/ErrorD3D12.h index 5cc8a34b9..7c4896f9e 100644 --- a/src/gpgmm/d3d12/ErrorD3D12.h +++ b/src/gpgmm/d3d12/ErrorD3D12.h @@ -22,13 +22,14 @@ namespace gpgmm::d3d12 { -#define ReturnIfNullptr(expr) \ - { \ - if (GPGMM_UNLIKELY(expr == nullptr)) { \ - return E_POINTER; \ - } \ - } \ - for (;;) \ +#define ReturnIfNullptr(expr) \ + { \ + if (GPGMM_UNLIKELY(expr == nullptr)) { \ + gpgmm::ErrorLog() << #expr << ": " << GetErrorMessage(E_POINTER); \ + return E_POINTER; \ + } \ + } \ + for (;;) \ break #define ReturnIfFailed(expr) \ diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index fc74a8fc6..f009476a3 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -88,10 +88,7 @@ namespace gpgmm::d3d12 { ReturnIfFailed(createHeapFn(pCreateHeapContext, &pageable)); // Pageable-based type is required for residency-managed heaps. - if (pageable == nullptr) { - gpgmm::ErrorLog() << "Unable to create heap because memory does not exist."; - return E_POINTER; - } + ReturnIfNullptr(pageable); GPGMM_TRACE_EVENT_OBJECT_CALL("Heap.CreateHeap", (CREATE_HEAP_DESC{descriptor, pageable.Get()}));