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
9 changes: 9 additions & 0 deletions src/gpgmm/d3d12/CapsD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ namespace gpgmm::d3d12 {
ReturnIfFailed(
SetCreateHeapNotResidentSupported(device, &caps->mIsCreateHeapNotResidentSupported));

D3D12_FEATURE_DATA_ARCHITECTURE arch = {};
ReturnIfFailed(
device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &arch, sizeof(arch)));
caps->mIsAdapterUMA = arch.UMA;

// D3D12 has no feature to detect support and must be set manually.
if (adapterDesc.VendorId == kIntel_VkVendor) {
caps->mIsResourceAccessAlwaysCoherent = true;
Expand All @@ -102,4 +107,8 @@ namespace gpgmm::d3d12 {
return mIsResourceAccessAlwaysCoherent;
}

bool Caps::IsAdapterUMA() const {
return mIsAdapterUMA;
}

} // namespace gpgmm::d3d12
4 changes: 4 additions & 0 deletions src/gpgmm/d3d12/CapsD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ namespace gpgmm::d3d12 {
// Allows a resource to be shared between multiple command queues.
bool IsResourceAccessAlwaysCoherent() const;

// Specifies if the adapter uses a Unified Memory Architecture (UMA).
bool IsAdapterUMA() const;

private:
Caps() = default;

uint64_t mMaxResourceSize = 0;
uint64_t mMaxResourceHeapSize = 0;
bool mIsCreateHeapNotResidentSupported = false;
bool mIsResourceAccessAlwaysCoherent = false;
bool mIsAdapterUMA = false;
};

} // namespace gpgmm::d3d12
Expand Down
17 changes: 10 additions & 7 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,20 @@ namespace gpgmm::d3d12 {

ComPtr<ResidencyManager> residencyManager;
if (ppResidencyManagerOut != nullptr) {
std::unique_ptr<Caps> caps;
{
Caps* ptr = nullptr;
ReturnIfFailed(Caps::CreateCaps(allocatorDescriptor.Device.Get(),
allocatorDescriptor.Adapter.Get(), &ptr));
caps.reset(ptr);
}

RESIDENCY_DESC residencyDesc = {};
residencyDesc.Device = allocatorDescriptor.Device;

D3D12_FEATURE_DATA_ARCHITECTURE arch = {};
ReturnIfFailed(residencyDesc.Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE,
&arch, sizeof(arch)));
residencyDesc.IsUMA = arch.UMA;

ReturnIfFailed(allocatorDescriptor.Adapter.As(&residencyDesc.Adapter));
residencyDesc.IsUMA = caps->IsAdapterUMA();
residencyDesc.MinLogLevel = allocatorDescriptor.MinLogLevel;
residencyDesc.RecordOptions = allocatorDescriptor.RecordOptions;
ReturnIfFailed(allocatorDescriptor.Adapter.As(&residencyDesc.Adapter));

ReturnIfFailed(
ResidencyManager::CreateResidencyManager(residencyDesc, &residencyManager));
Expand Down