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
2 changes: 1 addition & 1 deletion include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ namespace gpgmm::d3d12 {
Used to determine if resource categories (texture and buffers) can co-exist in the
same resource heap.

Required parameter. Use CheckFeatureSupport to get supported tier.
Optional parameter. By default, max tier. Use CheckFeatureSupport.
*/
D3D12_RESOURCE_HEAP_TIER ResourceHeapTier;

Expand Down
5 changes: 5 additions & 0 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ namespace gpgmm::d3d12 {
newDescriptor.SubAllocationAlgorithm = ALLOCATOR_ALGORITHM_SLAB;
}

// Resource heap tier is required but user didn't specify one.
if (newDescriptor.ResourceHeapTier == 0) {
newDescriptor.ResourceHeapTier = caps->GetMaxResourceHeapTierSupported();
}

// ID3D12Device::CreateCommittedResource and ID3D12Device::CreateHeap implicity
// call ID3D12Device::MakeResident, requiring resource heaps to be "created in budget".
// But this can be disabled if D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT is supported.
Expand Down
11 changes: 11 additions & 0 deletions src/tests/end2end/D3D12ResourceAllocatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ TEST_F(D3D12ResourceAllocatorTests, CreateResourceAllocator) {
EXPECT_EQ(resourceAllocator, nullptr);
}

// Creating an allocator without the resource heap tier specified should always succeed.
{
ALLOCATOR_DESC desc = {};
desc.Device = mDevice;
desc.Adapter = mAdapter;

ComPtr<IResourceAllocator> resourceAllocator;
EXPECT_SUCCEEDED(CreateResourceAllocator(desc, &resourceAllocator, nullptr));
EXPECT_NE(resourceAllocator, nullptr);
}

// Creating an allocator with the wrong resource heap tier should always fail.
{
// Tier 3 doesn't exist in D3D12.
Expand Down