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
21 changes: 21 additions & 0 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "gpgmm/common/SizeClass.h"
#include "gpgmm/common/TraceEvent.h"
#include "gpgmm/common/WorkerThread.h"
#include "gpgmm/d3d12/CapsD3D12.h"
#include "gpgmm/d3d12/ErrorD3D12.h"
#include "gpgmm/d3d12/FenceD3D12.h"
#include "gpgmm/d3d12/HeapD3D12.h"
Expand Down Expand Up @@ -150,6 +151,26 @@ namespace gpgmm::d3d12 {
// static
HRESULT ResidencyManager::CreateResidencyManager(const RESIDENCY_DESC& descriptor,
ResidencyManager** ppResidencyManagerOut) {
if (descriptor.Adapter == nullptr || descriptor.Device == nullptr) {
return E_INVALIDARG;
}

std::unique_ptr<Caps> caps;
{
Caps* ptr = nullptr;
ReturnIfFailed(
Caps::CreateCaps(descriptor.Device.Get(), descriptor.Adapter.Get(), &ptr));
caps.reset(ptr);
}

if (descriptor.IsUMA != caps->IsAdapterUMA()) {
gpgmm::WarningLog()
<< "Memory architecture does not match capabilities of the adapter (IsUMA:"
<< descriptor.IsUMA << " vs " << caps->IsAdapterUMA()
<< "). This is probably not what the developer intended. Please use "
"CheckFeatureSupport instead.";
}

// Residency manager needs it's own fence to know when heaps are no longer being used by the
// GPU.
std::unique_ptr<Fence> residencyFence;
Expand Down
10 changes: 10 additions & 0 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ namespace gpgmm::d3d12 {
caps.reset(ptr);
}

if (allocatorDescriptor.ResourceHeapTier != caps->GetMaxResourceHeapTierSupported()) {
gpgmm::WarningLog()
<< "Resource heap tier does not match capabilities of the adapter "
"(ResourceHeapTier:"
<< allocatorDescriptor.ResourceHeapTier << " vs "
<< caps->GetMaxResourceHeapTierSupported()
<< "). This is probably not what the developer intended. Please use "
"CheckFeatureSupport instead.";
}

ALLOCATOR_DESC newDescriptor = allocatorDescriptor;
newDescriptor.MemoryGrowthFactor = (allocatorDescriptor.MemoryGrowthFactor >= 1.0)
? allocatorDescriptor.MemoryGrowthFactor
Expand Down
23 changes: 23 additions & 0 deletions src/tests/end2end/D3D12ResidencyManagerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@ TEST_F(D3D12ResidencyManagerTests, CreateResidencyList) {
}

TEST_F(D3D12ResidencyManagerTests, CreateResidencyManager) {
// Create residency without adapter must always fail.
{
RESIDENCY_DESC residencyDesc = CreateBasicResidencyDesc(kDefaultBudget);
residencyDesc.Adapter = nullptr;

ASSERT_FAILED(ResidencyManager::CreateResidencyManager(residencyDesc, nullptr));
}

// Create residency without device must always fail.
{
RESIDENCY_DESC residencyDesc = CreateBasicResidencyDesc(kDefaultBudget);
residencyDesc.Device = nullptr;

ASSERT_FAILED(ResidencyManager::CreateResidencyManager(residencyDesc, nullptr));
}

// Create residency alone.
{
ComPtr<ResidencyManager> residencyManager;
ASSERT_SUCCEEDED(ResidencyManager::CreateResidencyManager(
CreateBasicResidencyDesc(kDefaultBudget), nullptr));
}

// Create allocator with residency support, together.
{
ComPtr<ResidencyManager> residencyManager;
Expand Down