From ba3805c8d064269e73d520f3eb18aaedff64b8a3 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Mon, 18 Jul 2022 17:03:32 +0200 Subject: [PATCH] vkd3d: Use IndexFormat as a sentinel for indexed RTAS build. UE5 seems to only set IndexType to != UNKNOWN when querying RTAS sizes. This contradicts D3D12 docs, but this matches Vulkan behavior, so do the same thing. Adds a warn when IBO VA is NULL with non-null format to catch app bugs. Signed-off-by: Hans-Kristian Arntzen --- libs/vkd3d/acceleration_structure.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d/acceleration_structure.c b/libs/vkd3d/acceleration_structure.c index 952181e5..f83c9c1f 100644 --- a/libs/vkd3d/acceleration_structure.c +++ b/libs/vkd3d/acceleration_structure.c @@ -180,8 +180,11 @@ bool vkd3d_acceleration_structure_convert_inputs(const struct d3d12_device *devi triangles = &info->geometries[i].geometry.triangles; triangles->sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR; triangles->indexData.deviceAddress = geom_desc->Triangles.IndexBuffer; - if (geom_desc->Triangles.IndexBuffer) + if (geom_desc->Triangles.IndexFormat != DXGI_FORMAT_UNKNOWN) { + if (!geom_desc->Triangles.IndexBuffer) + WARN("Application is using IndexBuffer = 0 and IndexFormat != UNKNOWN. Likely application bug.\n"); + triangles->indexType = geom_desc->Triangles.IndexFormat == DXGI_FORMAT_R16_UINT ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32;