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
14 changes: 6 additions & 8 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,12 @@ namespace gpgmm::d3d12 {
*/
RESOURCE_ALLOCATOR_FLAG_ALWAYS_IN_BUDGET = 0x2,

/** \brief Disables pre-fetching of GPU memory.
/** \brief Allow pre-fetching of resource heaps on background thread.

Should be only used for debugging and testing purposes.
Allows GPGMM to trigger prefetching based on heurstics. Prefetching enables more
performance when allocating for contiguous allocations or many resources of the same size.
*/
RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH = 0x4,
RESOURCE_ALLOCATOR_FLAG_ALLOW_PREFETCH = 0x4,

/** \brief Disables recycling of GPU memory.

Expand Down Expand Up @@ -1057,12 +1058,9 @@ namespace gpgmm::d3d12 {
*/
ALLOCATION_FLAG_NEVER_SUBALLOCATE_HEAP = 0x4,

/** \brief Prefetch memory for the next resource allocation.
/** \brief Force pre-fetch for the next resource allocation.

The call to prefetch is deferred to a background thread by GPGMM which runs
when the current allocation requested is completed. By default, GPGMM will automatically
trigger prefetching based on heurstics. Prefetching enables more performance when
allocating for contiguous allocations or many resources of the same size.
This flag has no effect if RESOURCE_ALLOCATOR_FLAG_ALLOW_PREFETCH was not specified.

Should not be used with ALLOCATION_FLAG_NEVER_ALLOCATE_HEAP.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ namespace gpgmm::d3d12 {
descriptor.ResourceHeapFragmentationLimit,
descriptor.ResourceHeapGrowthFactor,
/*allowSlabPrefetch*/
!(descriptor.Flags & RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH),
(descriptor.Flags & RESOURCE_ALLOCATOR_FLAG_ALLOW_PREFETCH),
std::move(pooledOrNonPooledAllocator));
}

Expand Down
4 changes: 2 additions & 2 deletions src/tests/capture_replay_tests/D3D12MemoryTraceReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class D3D12MemoryTraceReplay : public D3D12TestBase, public CaptureReplayTestWit
baseAllocatorDesc.RecordOptions.EventScope = RECORD_SCOPE_PER_INSTANCE;
}

if (!envParams.IsPrefetchAllowed) {
baseAllocatorDesc.Flags |= RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH;
if (envParams.IsPrefetchAllowed) {
baseAllocatorDesc.Flags |= RESOURCE_ALLOCATOR_FLAG_ALLOW_PREFETCH;
}

RESIDENCY_MANAGER_DESC baseResidencyDesc = CreateBasicResidencyDesc();
Expand Down
2 changes: 0 additions & 2 deletions src/tests/end2end/D3D12ResidencyManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class D3D12ResidencyManagerTests : public D3D12TestBase, public ::testing::Test
RESOURCE_ALLOCATOR_DESC CreateBasicAllocatorDesc() const {
RESOURCE_ALLOCATOR_DESC desc = D3D12TestBase::CreateBasicAllocatorDesc();

// Disable pre-fetching since it will could cause over-committment unpredictably.
desc.Flags |= gpgmm::d3d12::RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH;

// Require MakeResident/Evict occur near CreateResource, for debugging purposes.
desc.Flags |= gpgmm::d3d12::RESOURCE_ALLOCATOR_FLAG_ALWAYS_IN_BUDGET;
Expand Down
8 changes: 1 addition & 7 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ class D3D12ResourceAllocatorTests : public D3D12TestBase, public ::testing::Test
RESOURCE_ALLOCATOR_DESC CreateBasicAllocatorDesc() const {
RESOURCE_ALLOCATOR_DESC desc = D3D12TestBase::CreateBasicAllocatorDesc();

// Pre-fetching is enabled by default. However for testing purposes, pre-fetching changes
// expectations that check GPU memory usage and needs to be tested in isolation.
desc.Flags |= RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH;

// Make sure leak detection is always enabled.
desc.Flags |= gpgmm::d3d12::RESOURCE_ALLOCATOR_FLAG_NEVER_LEAK;

Expand Down Expand Up @@ -1741,10 +1737,8 @@ TEST_F(D3D12ResourceAllocatorTests, CreateBufferManyPrefetch) {
GPGMM_SKIP_TEST_IF(true);
#endif

// Prefetching is explicitly disabled but otherwise allowed, re-enable it by clearing the
// disable flag.
RESOURCE_ALLOCATOR_DESC allocatorDesc = CreateBasicAllocatorDesc();
allocatorDesc.Flags ^= RESOURCE_ALLOCATOR_FLAG_DISABLE_PREFETCH;
allocatorDesc.Flags |= RESOURCE_ALLOCATOR_FLAG_ALLOW_PREFETCH;

ComPtr<IResourceAllocator> resourceAllocator;
ASSERT_SUCCEEDED(CreateResourceAllocator(allocatorDesc, mDevice.Get(), mAdapter.Get(),
Expand Down