diff --git a/patches/gpgmm_dawn.diff b/patches/gpgmm_dawn.diff index 0c8c7baaf..49d05bcbf 100644 --- a/patches/gpgmm_dawn.diff +++ b/patches/gpgmm_dawn.diff @@ -1,4 +1,4 @@ -From 1ff3f00bfd33a2b4c8a4181c1165d1fd653204e2 Mon Sep 17 00:00:00 2001 +From beb21d1d2baa8e0147d4d8ef6a0c46e44e89b811 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 15 Feb 2022 17:25:29 -0800 Subject: [PATCH] Use GPGMM for D3D12 backend. @@ -437,7 +437,7 @@ index 18d7145c8..098254e5c 100644 AdapterDiscoveryOptions::AdapterDiscoveryOptions() diff --git a/src/dawn/native/d3d12/DeviceD3D12.cpp b/src/dawn/native/d3d12/DeviceD3D12.cpp -index 6b77b3a07..ab3854ea3 100644 +index 6b77b3a07..b06def815 100644 --- a/src/dawn/native/d3d12/DeviceD3D12.cpp +++ b/src/dawn/native/d3d12/DeviceD3D12.cpp @@ -127,8 +127,33 @@ namespace dawn::native::d3d12 { @@ -462,7 +462,7 @@ index 6b77b3a07..ab3854ea3 100644 + } + + if (IsToggleEnabled(Toggle::UseD3D12SmallResidencyBudgetForTesting)) { -+ allocatorDesc.TotalResourceBudgetLimit = 100000000; // 100MB ++ allocatorDesc.Budget = 100000000; // 100MB + } + + if (IsToggleEnabled(Toggle::DumpResourceAllocator)) { diff --git a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp index 791a30839..5f53e3107 100644 --- a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp +++ b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp @@ -42,8 +42,8 @@ namespace gpgmm { namespace d3d12 { dict.AddItem("PreferredResourceHeapSize", desc.PreferredResourceHeapSize); dict.AddItem("MaxResourceHeapSize", desc.MaxResourceHeapSize); dict.AddItem("MaxVideoMemoryBudget", desc.MaxVideoMemoryBudget); - dict.AddItem("TotalResourceBudgetLimit", desc.TotalResourceBudgetLimit); - dict.AddItem("EvictLimit", desc.EvictLimit); + dict.AddItem("Budget", desc.Budget); + dict.AddItem("EvictBatchSize", desc.EvictBatchSize); dict.AddItem("MemoryFragmentationLimit", desc.MemoryFragmentationLimit); return dict; } diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp index 3ad91ca7f..e483d74b7 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp @@ -28,7 +28,7 @@ namespace gpgmm { namespace d3d12 { - static constexpr uint32_t kDefaultEvictLimit = 50ll * 1024ll * 1024ll; // 50MB + static constexpr uint32_t kDefaultEvictBatchSize = 50ll * 1024ll * 1024ll; // 50MB static constexpr float kDefaultVideoMemoryBudget = 0.95f; // 95% // static @@ -62,7 +62,8 @@ namespace gpgmm { namespace d3d12 { mVideoMemoryBudget(descriptor.VideoMemoryBudget == 0 ? kDefaultVideoMemoryBudget : descriptor.VideoMemoryBudget), mBudget(descriptor.Budget), - mEvictLimit(descriptor.EvictLimit == 0 ? kDefaultEvictLimit : descriptor.EvictLimit), + mEvictBatchSize(descriptor.EvictBatchSize == 0 ? kDefaultEvictBatchSize + : descriptor.EvictBatchSize), mIsUMA(descriptor.IsUMA) { GPGMM_TRACE_EVENT_OBJECT_NEW(this); @@ -484,7 +485,7 @@ namespace gpgmm { namespace d3d12 { // If nothing can be evicted after MakeResident has failed, we cannot continue // execution and must throw a fatal error. uint64_t evictedSizeInBytes = 0; - ReturnIfFailed(EvictInternal(mEvictLimit, memorySegmentGroup, &evictedSizeInBytes)); + ReturnIfFailed(EvictInternal(mEvictBatchSize, memorySegmentGroup, &evictedSizeInBytes)); if (evictedSizeInBytes == 0) { return E_OUTOFMEMORY; } diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.h b/src/gpgmm/d3d12/ResidencyManagerD3D12.h index 04d38389b..7182502cd 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.h +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.h @@ -62,22 +62,22 @@ namespace gpgmm { namespace d3d12 { */ float VideoMemoryBudget; - /** \brief Specify budget for residency manager. + /** \brief Specify the budget, in bytes, for residency. - Mostly used for debugging and testing purposes because it allows a fixed budget to be - artifically set. + Allows a fixed budget to be artifically set for testing purposes. Optional parameter. When 0 is specified, the API will not restrict the residency manager budget. */ uint64_t Budget; - /** \brief Amount of memory to evict, in bytes, should there not be enough budget left. + /** \brief Specifies the amount of memory, in bytes, to evict from residency at once, + should there not be enough budget left. Optional parameter. When 0 is specified, the API will automatically set the video memory evict size to 50MB. */ - uint64_t EvictLimit; + uint64_t EvictBatchSize; }; class GPGMM_EXPORT ResidencyManager final : public IUnknownImpl { @@ -200,7 +200,7 @@ namespace gpgmm { namespace d3d12 { const float mVideoMemoryBudget; const uint64_t mBudget; - const uint64_t mEvictLimit; + const uint64_t mEvictBatchSize; const bool mIsUMA; VideoMemorySegment mLocalVideoMemorySegment; diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 2f7df6015..191ab127a 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -400,8 +400,8 @@ namespace gpgmm { namespace d3d12 { residencyDesc.Device = newDescriptor.Device; residencyDesc.IsUMA = newDescriptor.IsUMA; residencyDesc.VideoMemoryBudget = newDescriptor.MaxVideoMemoryBudget; - residencyDesc.Budget = newDescriptor.TotalResourceBudgetLimit; - residencyDesc.EvictLimit = newDescriptor.EvictLimit; + residencyDesc.Budget = newDescriptor.Budget; + residencyDesc.EvictBatchSize = newDescriptor.EvictBatchSize; ReturnIfFailed(newDescriptor.Adapter.As(&residencyDesc.Adapter)); ReturnIfFailed( diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index ba6722b3f..31b55d287 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -244,19 +244,21 @@ namespace gpgmm { namespace d3d12 { */ float MaxVideoMemoryBudget; - /** \brief Total memory available to budget for resources. + /** \brief Specify the budget, in bytes, for residency. - Optional parameter. When 0 is specified, the API will not restrict the resource budget. + Allows a fixed budget to be artifically set for testing purposes. + + Optional parameter. When 0 is specified, the API will not restrict the budget. */ - uint64_t TotalResourceBudgetLimit; + uint64_t Budget; - /** \brief Total memory to evict from residency at once, should there not be enough budget - left. + /** \brief Specifies the amount of resource heaps, in bytes, to evict from residency at + once, should there not be enough budget left. Optional parameter. When 0 is specified, the API will automatically set the video memory evict size to 50MB. */ - uint64_t EvictLimit; + uint64_t EvictBatchSize; /** \brief Memory fragmentation limit, expressed as a percentage of the resource heap size, that is acceptable to be wasted due to internal fragmentation. diff --git a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp index 9769ba4a6..c1ec6869b 100644 --- a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp +++ b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp @@ -303,9 +303,8 @@ class D3D12EventTraceReplay : public D3D12TestBase, public CaptureReplayTestWith snapshot["MaxResourceHeapSize"].asUInt64(); allocatorDesc.MaxVideoMemoryBudget = snapshot["MaxVideoMemoryBudget"].asFloat(); - allocatorDesc.TotalResourceBudgetLimit = - snapshot["TotalResourceBudgetLimit"].asUInt64(); - allocatorDesc.EvictLimit = snapshot["EvictLimit"].asUInt64(); + allocatorDesc.Budget = snapshot["Budget"].asUInt64(); + allocatorDesc.EvictBatchSize = snapshot["EvictBatchSize"].asUInt64(); allocatorDesc.MemoryFragmentationLimit = snapshot["MemoryFragmentationLimit"].asDouble(); } else if (envParams.AllocatorProfile ==