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
38 changes: 38 additions & 0 deletions src/gpgmm/d3d12/CapsD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

#include "gpgmm/d3d12/CapsD3D12.h"

#include "gpgmm/common/SizeClass.h"
#include "gpgmm/d3d12/ErrorD3D12.h"
#include "gpgmm/utils/Limits.h"
#include "gpgmm/utils/Log.h"
#include "gpgmm/utils/Utils.h"
#include "gpgmm/utils/WindowsUtils.h"

#include <memory>

Expand Down Expand Up @@ -66,6 +70,15 @@ namespace gpgmm::d3d12 {
return S_OK;
}

HRESULT GetMaxResourceHeapTierSupported(ID3D12Device* device,
D3D12_RESOURCE_HEAP_TIER* maxResourceHeapTierOut) {
D3D12_FEATURE_DATA_D3D12_OPTIONS options = {};
ReturnIfFailed(
device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)));
*maxResourceHeapTierOut = options.ResourceHeapTier;
return S_OK;
}

// static
HRESULT Caps::CreateCaps(ID3D12Device* device, IDXGIAdapter* adapter, Caps** capsOut) {
DXGI_ADAPTER_DESC adapterDesc;
Expand All @@ -87,6 +100,27 @@ namespace gpgmm::d3d12 {
caps->mIsResourceAccessAlwaysCoherent = true;
}

// Dump log for debugging purposes.
DebugLog() << "GPU: " << WCharToUTF8(adapterDesc.Description)
<< " (device: " << ToHexStr(adapterDesc.DeviceId)
<< ", vendor: " << ToHexStr(adapterDesc.VendorId) << ")";
DebugLog() << "System memory: "
<< GPGMM_BYTES_TO_GB(adapterDesc.SharedSystemMemory +
adapterDesc.DedicatedSystemMemory)
<< " GBs"
<< " (" << GPGMM_BYTES_TO_GB(adapterDesc.DedicatedSystemMemory)
<< " dedicated) ";

DebugLog() << "Unified memory architecture: " << ((arch.UMA) ? "yes" : "no")
<< ((arch.CacheCoherentUMA) ? " (cache-coherent)" : "");
DebugLog() << "Max resource size: " << GPGMM_BYTES_TO_MB(caps->GetMaxResourceSize())
<< " MBs";
DebugLog() << "Max resource heap tier: " << caps->GetMaxResourceHeapTierSupported();
DebugLog() << "Max resource heap size: "
<< GPGMM_BYTES_TO_GB(caps->GetMaxResourceHeapSize()) << " GBs";
DebugLog() << "Creation of non-resident heaps: "
<< ((caps->IsCreateHeapNotResidentSupported()) ? "Supported" : "Not supported");

*capsOut = caps.release();
return S_OK;
}
Expand All @@ -111,4 +145,8 @@ namespace gpgmm::d3d12 {
return mIsAdapterUMA;
}

bool Caps::GetMaxResourceHeapTierSupported() const {
return mMaxResourceHeapTier;
}

} // 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 @@ -41,11 +41,15 @@ namespace gpgmm::d3d12 {
// Specifies if the adapter uses a Unified Memory Architecture (UMA).
bool IsAdapterUMA() const;

// Specifies if a texture and buffer can belong in the same heap.
bool GetMaxResourceHeapTierSupported() const;

private:
Caps() = default;

uint64_t mMaxResourceSize = 0;
uint64_t mMaxResourceHeapSize = 0;
D3D12_RESOURCE_HEAP_TIER mMaxResourceHeapTier;
bool mIsCreateHeapNotResidentSupported = false;
bool mIsResourceAccessAlwaysCoherent = false;
bool mIsAdapterUMA = false;
Expand Down