From 723ce3480f2433b4f070a046782e400fa7ec0b1a Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 20 Sep 2022 15:31:48 -0700 Subject: [PATCH] Clean-up and improve debug messages. --- src/gpgmm/d3d12/ResidencyManagerD3D12.cpp | 9 ++++--- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 30 +++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp index c7bc7135a..190e3208e 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp @@ -165,7 +165,7 @@ namespace gpgmm::d3d12 { if (descriptor.IsUMA != caps->IsAdapterUMA()) { gpgmm::WarningLog() - << "Memory architecture does not match capabilities of the adapter (IsUMA:" + << "Memory architecture did not match capabilities of the adapter (IsUMA:" << descriptor.IsUMA << " vs " << caps->IsAdapterUMA() << "). This is probably not what the developer intended. Please use " "CheckFeatureSupport instead."; @@ -182,8 +182,9 @@ namespace gpgmm::d3d12 { } if (descriptor.MaxPctOfVideoMemoryToBudget != 0 && descriptor.MaxBudgetInBytes != 0) { - gpgmm::WarningLog() - << "OS based memory budget was ignored since a budget was specified."; + gpgmm::ErrorLog() << "Both the OS based memory budget and restricted budget were " + "specified but cannot be used at the same time."; + return E_UNEXPECTED; } if (descriptor.RecordOptions.Flags != EVENT_RECORD_FLAG_NONE) { @@ -201,7 +202,7 @@ namespace gpgmm::d3d12 { // Require automatic video memory budget updates. if (!(descriptor.Flags & RESIDENCY_FLAG_NEVER_UPDATE_BUDGET_ON_WORKER_THREAD)) { ReturnIfFailed(residencyManager->StartBudgetNotificationUpdates()); - gpgmm::DebugLog() << "OS event based budget updates enabled."; + gpgmm::DebugLog() << "OS based memory budget updates were successfully enabled."; } // Set the initial video memory limits. diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index d07884cf1..72ddebb1b 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -420,13 +420,21 @@ namespace gpgmm::d3d12 { } if (allocatorDescriptor.ResourceHeapTier > caps->GetMaxResourceHeapTierSupported()) { - gpgmm::ErrorLog() << "Resource heap tier does not match capabilities of the adapter " + gpgmm::ErrorLog() << "Resource heap tier exceeds the capabilities of the adapter " "(ResourceHeapTier:" << allocatorDescriptor.ResourceHeapTier << " vs " - << caps->GetMaxResourceHeapTierSupported() << ")."; + << caps->GetMaxResourceHeapTierSupported() + << "). Please consider using a lower resource heap tier."; return E_FAIL; } + if (allocatorDescriptor.ResourceHeapTier < caps->GetMaxResourceHeapTierSupported()) { + gpgmm::DebugLog() + << "Resource heap tier requested was lower than what the adapter " + "supports. This is allowed but not recommended because it prevents " + "resources of different categories from sharing the same heap."; + } + ALLOCATOR_DESC newDescriptor = allocatorDescriptor; newDescriptor.MemoryGrowthFactor = (allocatorDescriptor.MemoryGrowthFactor >= 1.0) ? allocatorDescriptor.MemoryGrowthFactor @@ -447,6 +455,10 @@ namespace gpgmm::d3d12 { if (!(allocatorDescriptor.Flags & ALLOCATOR_FLAG_ALWAYS_IN_BUDGET) && !caps->IsCreateHeapNotResidentSupported()) { newDescriptor.Flags |= ALLOCATOR_FLAG_ALWAYS_IN_BUDGET; + + gpgmm::DebugLog() + << "ALLOCATOR_FLAG_ALWAYS_IN_BUDGET was not requested but enabled " + "anyway because the adapter did not support creating non-resident heaps."; } newDescriptor.MaxResourceHeapSize = @@ -464,6 +476,9 @@ namespace gpgmm::d3d12 { : kDefaultFragmentationLimit; if (newDescriptor.PreferredResourceHeapSize > newDescriptor.MaxResourceHeapSize) { + gpgmm::ErrorLog() << "Requested oreferred resource heap size exceeded the capabilities " + "of the adapter. This is probably not what the developer intended " + "to do. Please consider using a smaller resource heap size."; return E_INVALIDARG; } @@ -491,14 +506,17 @@ namespace gpgmm::d3d12 { ReturnIfFailed(leakMessageQueue->PushRetrievalFilter(&emptyFilter)); } else { gpgmm::WarningLog() - << "GPGMM_ENABLE_DEVICE_LEAK_CHECKS was specified but the D3D12 debug " - "layer was either not installed or enabled."; + << "GPGMM_ENABLE_DEVICE_LEAK_CHECKS has not effect because the D3D12 debug " + "layer was either not installed or enabled. This is probably not what the " + "developer intended to do."; } #endif if (newDescriptor.Flags & ALLOCATOR_FLAG_ALWAYS_IN_BUDGET && !pResidencyManager) { - gpgmm::WarningLog() << "ALLOCATOR_FLAG_ALWAYS_IN_BUDGET was specified but residency " - "management was not enabled."; + gpgmm::WarningLog() << "ALLOCATOR_FLAG_ALWAYS_IN_BUDGET has no effect when residency " + "management does not exist. This is probably not what the " + "developer intended to do. Please consider creating a residency " + "manager with this resource allocator before using this flag."; } std::unique_ptr resourceAllocator = std::unique_ptr(