From 10ddafdcc1e0cd47acfa2858f0c32dc142d72a52 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 b78d7ed7..58eb0d86 100644 --- a/src/nvapi_d3d12.cpp +++ b/src/nvapi_d3d12.cpp @@ -302,12 +302,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, DeviceExt2 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; + } case NVAPI_D3D12_RAYTRACING_CAPS_TYPE_DISPLACEMENT_MICROMAP: if (dataSize != sizeof(NVAPI_D3D12_RAYTRACING_DISPLACEMENT_MICROMAP_CAPS))