From e33de2b8e3dfa6048411137b827ea88eb3cf0612 Mon Sep 17 00:00:00 2001 From: Krzysztof Bogacki Date: Fri, 19 May 2023 21:53:05 +0200 Subject: [PATCH] nvapi-d3d12: Report OMM as supported if device ext and interface are found --- src/nvapi_d3d12.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/nvapi_d3d12.cpp b/src/nvapi_d3d12.cpp index 74a1427d..a7bab17f 100644 --- a/src/nvapi_d3d12.cpp +++ b/src/nvapi_d3d12.cpp @@ -256,12 +256,21 @@ extern "C" { *(NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAPS*)pData = NVAPI_D3D12_RAYTRACING_THREAD_REORDERING_CAP_NONE; break; - case NVAPI_D3D12_RAYTRACING_CAPS_TYPE_OPACITY_MICROMAP: + case NVAPI_D3D12_RAYTRACING_CAPS_TYPE_OPACITY_MICROMAP: { if (dataSize != sizeof(NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAPS)) return InvalidArgument(n); - *(NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAPS*)pData = NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAP_NONE; + auto ommCaps = reinterpret_cast(pData); + // even though we can check extension support with DeviceExt(0) interface, DeviceExt1 is needed for actual OMM functions + Com deviceExt; + + if (!FAILED(pDevice->QueryInterface(IID_PPV_ARGS(&deviceExt))) && deviceExt->GetExtensionSupport(D3D12_VK_EXT_OPACITY_MICROMAP)) + *ommCaps = NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAP_STANDARD; + else + *ommCaps = NVAPI_D3D12_RAYTRACING_OPACITY_MICROMAP_CAP_NONE; + break; + } default: return InvalidArgument(n);