From ff226c69ad601544c4b783f439872cd24b399680 Mon Sep 17 00:00:00 2001 From: Stephen Date: Thu, 6 Jan 2022 18:05:26 -0500 Subject: [PATCH] Merged pull request "Fix invalid argument for DX12 CreateHeap": https://github.com/NVIDIAGameWorks/nvrhi/pull/8 --- src/d3d12/d3d12-backend.h | 1 + src/d3d12/d3d12-device.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/d3d12/d3d12-backend.h b/src/d3d12/d3d12-backend.h index 9bda5a6..723f50e 100644 --- a/src/d3d12/d3d12-backend.h +++ b/src/d3d12/d3d12-backend.h @@ -1094,6 +1094,7 @@ namespace nvrhi::d3d12 bool m_MeshletsSupported = false; bool m_VariableRateShadingSupported = false; + D3D12_FEATURE_DATA_D3D12_OPTIONS m_Options = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_Options5 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_Options6 = {}; D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_Options7 = {}; diff --git a/src/d3d12/d3d12-device.cpp b/src/d3d12/d3d12-device.cpp index 6fd7b71..945b4f4 100644 --- a/src/d3d12/d3d12-device.cpp +++ b/src/d3d12/d3d12-device.cpp @@ -102,6 +102,7 @@ namespace nvrhi::d3d12 m_Resources.shaderResourceViewHeap.allocateResources(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, desc.shaderResourceViewHeapSize, true); m_Resources.samplerHeap.allocateResources(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, desc.samplerHeapSize, true); + m_Context.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_Options, sizeof(m_Options)); bool hasOptions5 = SUCCEEDED(m_Context.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &m_Options5, sizeof(m_Options5))); bool hasOptions6 = SUCCEEDED(m_Context.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &m_Options6, sizeof(m_Options6))); bool hasOptions7 = SUCCEEDED(m_Context.device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &m_Options7, sizeof(m_Options7))); @@ -505,13 +506,17 @@ namespace nvrhi::d3d12 { D3D12_HEAP_DESC heapDesc; heapDesc.SizeInBytes = d.capacity; - heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES; heapDesc.Alignment = D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT; heapDesc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; heapDesc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; heapDesc.Properties.CreationNodeMask = 1; // no mGPU support in nvrhi so far heapDesc.Properties.VisibleNodeMask = 1; + if (m_Options.ResourceHeapTier == D3D12_RESOURCE_HEAP_TIER_1) + heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES; + else + heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES; + switch (d.type) { case HeapType::DeviceLocal: