Skip to content

Commit

Permalink
d3d12: Implement EmitRaytracingOpacityMicromapArrayPostbuildInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Saancreed committed Nov 6, 2024
1 parent bb2fbe7 commit 691f3b8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/nvapi/nvapi_d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ namespace dxvk {
return static_cast<NvAPI_Status>(commandListVer.CommandListExt->RelocateRaytracingOpacityMicromapArray(params));
}

std::optional<NvAPI_Status> NvapiD3d12Device::EmitRaytracingOpacityMicromapArrayPostbuildInfo(ID3D12GraphicsCommandList4* commandList, const NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS* params) {
auto commandListExt = GetCommandListExt(commandList);
if (!commandListExt.has_value())
return std::nullopt;

auto commandListVer = commandListExt.value();
if (commandListVer.InterfaceVersion < 2)
return std::nullopt;

return static_cast<NvAPI_Status>(commandListVer.CommandListExt->EmitRaytracingOpacityMicromapArrayPostbuildInfo(params));
}

// We are going to have single map for storing devices with extensions D3D12_VK_NVX_BINARY_IMPORT & D3D12_VK_NVX_IMAGE_VIEW_HANDLE.
// These are specific to NVIDIA and both of these extensions goes together.
Com<ID3D12DeviceExt> NvapiD3d12Device::GetCubinDevice(ID3D12Device* device) {
Expand Down
1 change: 1 addition & 0 deletions src/nvapi/nvapi_d3d12_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace dxvk {
static std::optional<NvAPI_Status> BuildRaytracingAccelerationStructureEx(ID3D12GraphicsCommandList4* commandList, const NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS* params);
static std::optional<NvAPI_Status> BuildRaytracingOpacityMicromapArray(ID3D12GraphicsCommandList4* commandList, NVAPI_BUILD_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS* params);
static std::optional<NvAPI_Status> RelocateRaytracingOpacityMicromapArray(ID3D12GraphicsCommandList4* commandList, const NVAPI_RELOCATE_RAYTRACING_OPACITY_MICROMAP_ARRAY_PARAMS* params);
static std::optional<NvAPI_Status> EmitRaytracingOpacityMicromapArrayPostbuildInfo(ID3D12GraphicsCommandList4* commandList, const NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS* params);

static void ClearCacheMaps();

Expand Down
26 changes: 26 additions & 0 deletions src/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,32 @@ extern "C" {
return NotSupported(n);
}

NvAPI_Status __cdecl NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo(ID3D12GraphicsCommandList4* pCommandList, const NVAPI_EMIT_RAYTRACING_OPACITY_MICROMAP_ARRAY_POSTBUILD_INFO_PARAMS* pParams) {
constexpr auto n = __func__;
thread_local bool alreadyLoggedOk = false;

if (log::tracing())
log::trace(n, log::fmt::ptr(pCommandList), log::fmt::ptr(pParams));

if (pCommandList == nullptr || pParams == nullptr)
return InvalidArgument(n);

if (auto result = NvapiD3d12Device::EmitRaytracingOpacityMicromapArrayPostbuildInfo(pCommandList, pParams); result.has_value()) {
auto value = result.value();
switch (value) {
case NVAPI_OK:
return Ok(n, alreadyLoggedOk);
case NVAPI_INCOMPATIBLE_STRUCT_VERSION:
return IncompatibleStructVersion(n, pParams->version);
default:
log::info(str::format("<-", n, ": ", value));
return value;
}
}

return NotSupported(n);
}

NvAPI_Status __cdecl NvAPI_D3D12_BuildRaytracingAccelerationStructureEx(ID3D12GraphicsCommandList4* pCommandList, const NVAPI_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_EX_PARAMS* pParams) {
constexpr auto n = __func__;
thread_local bool alreadyLoggedOk = false;
Expand Down
1 change: 1 addition & 0 deletions src/nvapi_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extern "C" {
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_GetRaytracingAccelerationStructurePrebuildInfoEx)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_BuildRaytracingOpacityMicromapArray)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_RelocateRaytracingOpacityMicromapArray)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_EmitRaytracingOpacityMicromapArrayPostbuildInfo)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_BuildRaytracingAccelerationStructureEx)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_NotifyOutOfBandCommandQueue)
INSERT_AND_RETURN_WHEN_EQUALS(NvAPI_D3D12_SetAsyncFrameMarker)
Expand Down

0 comments on commit 691f3b8

Please sign in to comment.