From 8aecb3ed58ce50484e7e4d0e40c46c481eeec0f8 Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Thu, 26 May 2022 16:38:56 +0200 Subject: [PATCH] radv: Ignore transformOffset if transformData is 0 There is also a hypothetical scenario where transformData is 0 and transformOffset is not 0 and we end up reading from transformOffset because transform_addr is not 0. VkAccelerationStructureBuildRangeInfoKHR spec: If VkAccelerationStructureGeometryTrianglesDataKHR::transformData is not NULL, a single VkTransformMatrixKHR structure is consumed from VkAccelerationStructureGeometryTrianglesDataKHR::transformData, at an offset of transformOffset. This matrix describes a transformation from the space in which the vertices for all triangles in this geometry are described to the space in which the acceleration structure is defined. Which I think means, that we should ignore transformOffset if transformData is NULL. Signed-off-by: Konstantin Seurer Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_acceleration_structure.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_acceleration_structure.c b/src/amd/vulkan/radv_acceleration_structure.c index 49e004fd995..d69f1e529d3 100644 --- a/src/amd/vulkan/radv_acceleration_structure.c +++ b/src/amd/vulkan/radv_acceleration_structure.c @@ -2102,8 +2102,10 @@ radv_CmdBuildAccelerationStructuresKHR( else prim_consts.index_addr += ppBuildRangeInfos[i][j].primitiveOffset; - prim_consts.transform_addr = geom->geometry.triangles.transformData.deviceAddress + - ppBuildRangeInfos[i][j].transformOffset; + prim_consts.transform_addr = geom->geometry.triangles.transformData.deviceAddress; + if (prim_consts.transform_addr) + prim_consts.transform_addr += ppBuildRangeInfos[i][j].transformOffset; + prim_consts.vertex_stride = geom->geometry.triangles.vertexStride; prim_consts.vertex_format = geom->geometry.triangles.vertexFormat; prim_consts.index_format = geom->geometry.triangles.indexType;