Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions patches/gpgmm_dawn.diff
Original file line number Diff line number Diff line change
@@ -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 <bryan.bernhart@intel.com>
Date: Tue, 15 Feb 2022 17:25:29 -0800
Subject: [PATCH] Use GPGMM for D3D12 backend.
Expand Down Expand Up @@ -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 {
Expand All @@ -462,7 +462,7 @@ index 6b77b3a07..ab3854ea3 100644
+ }
+
+ if (IsToggleEnabled(Toggle::UseD3D12SmallResidencyBudgetForTesting)) {
+ allocatorDesc.TotalResourceBudgetLimit = 100000000; // 100MB
+ allocatorDesc.Budget = 100000000; // 100MB
+ }
+
+ if (IsToggleEnabled(Toggle::DumpResourceAllocator)) {
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/JSONSerializerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
14 changes: 8 additions & 6 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==
Expand Down