From 6db4f599956eb778aa6f638f07a2c136b31a20d0 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Mon, 18 Apr 2022 13:36:19 -0700 Subject: [PATCH] Rename ResourceFragmentationLimit => MemoryFragmentationLimit. Resources will fragment (ie. use a size larger then requested) independently of the underlying memory they use. To distingish this, ResourceFragmentationLimit has been renamed to MemoryFragmentationLimit. --- src/gpgmm/d3d12/JSONSerializerD3D12.cpp | 2 +- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 8 ++++---- src/gpgmm/d3d12/ResourceAllocatorD3D12.h | 6 +++--- src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp index 0b66ce485..47962e8b2 100644 --- a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp +++ b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp @@ -44,7 +44,7 @@ namespace gpgmm { namespace d3d12 { dict.AddItem("MaxVideoMemoryBudget", desc.MaxVideoMemoryBudget); dict.AddItem("TotalResourceBudgetLimit", desc.TotalResourceBudgetLimit); dict.AddItem("VideoMemoryEvictSize", desc.VideoMemoryEvictSize); - dict.AddItem("ResourceFragmentationLimit", desc.ResourceFragmentationLimit); + dict.AddItem("MemoryFragmentationLimit", desc.MemoryFragmentationLimit); return dict; } diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index f1a1bbfe2..a01c29257 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -347,9 +347,9 @@ namespace gpgmm { namespace d3d12 { ? std::min(descriptor.MaxResourceHeapSize, caps->GetMaxResourceHeapSize()) : caps->GetMaxResourceHeapSize(); - newDescriptor.ResourceFragmentationLimit = (descriptor.ResourceFragmentationLimit > 0) - ? descriptor.ResourceFragmentationLimit - : kDefaultFragmentationLimit; + newDescriptor.MemoryFragmentationLimit = (descriptor.MemoryFragmentationLimit > 0) + ? descriptor.MemoryFragmentationLimit + : kDefaultFragmentationLimit; if (newDescriptor.PreferredResourceHeapSize > newDescriptor.MaxResourceHeapSize) { return E_INVALIDARG; @@ -459,7 +459,7 @@ namespace gpgmm { namespace d3d12 { /*maxSlabSize*/ PrevPowerOfTwo(mMaxResourceHeapSize), /*slabSize*/ descriptor.PreferredResourceHeapSize, /*slabAlignment*/ heapAlignment, - /*slabFragmentationLimit*/ descriptor.ResourceFragmentationLimit, + /*slabFragmentationLimit*/ descriptor.MemoryFragmentationLimit, /*enablePrefetch*/ !(descriptor.Flags & ALLOCATOR_FLAG_DISABLE_MEMORY_PREFETCH), std::move(buddyAllocator)); } diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index d0b1b90f8..7d6454b29 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -190,7 +190,7 @@ namespace gpgmm { namespace d3d12 { // evict size to 50MB. uint64_t VideoMemoryEvictSize; - // Resource fragmentation limit, expressed as a percentage of the resource heap size, that + // Memory fragmentation limit, expressed as a percentage of the resource heap size, that // is acceptable to be wasted due to internal fragmentation. // // Internal fragmentation is when the resource allocation size is larger then the resource @@ -198,12 +198,12 @@ namespace gpgmm { namespace d3d12 { // sub-allocation algorithm (buddy, slab, etc) have different alignment requirements. For // example, a 192KB page-aligned resource may need to allocate 256KB of binary-allocated // space, which if allowed, has a fragmentation limit of 1/3rd. - // When |PreferredResourceHeapSize| is non-zero, |ResourceFragmentationLimit| could be + // When |PreferredResourceHeapSize| is non-zero, |MemoryFragmentationLimit| could be // exceeded. // // Optional parameter. When 0 is specified, the API will automatically set the resource // fragmentation limit to 1/8th the resource heap size. - double ResourceFragmentationLimit; + double MemoryFragmentationLimit; }; enum ALLOCATION_FLAGS { diff --git a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp index c3b76959a..bad9dfd53 100644 --- a/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp +++ b/src/tests/capture_replay_tests/D3D12EventTraceReplay.cpp @@ -312,16 +312,16 @@ class D3D12EventTraceReplay : public D3D12TestBase, public CaptureReplayTestWith snapshot["TotalResourceBudgetLimit"].asUInt64(); allocatorDesc.VideoMemoryEvictSize = snapshot["VideoMemoryEvictSize"].asUInt64(); - allocatorDesc.ResourceFragmentationLimit = - snapshot["ResourceFragmentationLimit"].asDouble(); + allocatorDesc.MemoryFragmentationLimit = + snapshot["MemoryFragmentationLimit"].asDouble(); } else if (envParams.AllocatorProfile == AllocatorProfile::ALLOCATOR_PROFILE_MAX_PERFORMANCE) { // Any amount of (internal) fragmentation is acceptable. - allocatorDesc.ResourceFragmentationLimit = 1.0f; + allocatorDesc.MemoryFragmentationLimit = 1.0f; } else if (envParams.AllocatorProfile == AllocatorProfile::ALLOCATOR_PROFILE_LOW_MEMORY) { allocatorDesc.Flags |= ALLOCATOR_FLAG_ALWAYS_ON_DEMAND; - allocatorDesc.ResourceFragmentationLimit = 0.125; // 1/8th of 4MB + allocatorDesc.MemoryFragmentationLimit = 0.125; // 1/8th of 4MB } if (envParams.IsStandaloneOnly) {