Skip to content
Snippets Groups Projects
Commit 7c337f85 authored by Konstantin Seurer's avatar Konstantin Seurer Committed by Dylan Baker
Browse files

radv: Fix handling of primitiveOffset


VkAccelerationStructureBuildRangeInfoKHR spec:
If the geometry uses indices, primitiveCount × 3 indices are consumed from VkAccelerationStructureGeometryTrianglesDataKHR::indexData, starting at an offset of primitiveOffset. The value of firstVertex is added to the index values before fetching vertices.

If the geometry does not use indices, primitiveCount × 3 vertices are consumed from VkAccelerationStructureGeometryTrianglesDataKHR::vertexData, starting at an offset of primitiveOffset + VkAccelerationStructureGeometryTrianglesDataKHR::vertexStride × firstVertex.

Meaning: We always add firstVertex * vertexStride
to the vertex address and add primitiveOffset
either to the vertex address or the index address,
depending on wether indices are used.

Also add missing handling with instances.

Fixes: 0dad88b4 ("radv: Implement device-side BVH building.")
Signed-off-by: default avatarKonstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: default avatarBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <mesa/mesa!16719>
(cherry picked from commit 9be00573)

Conflicts:
	src/amd/vulkan/radv_acceleration_structure.c
parent 901d5b86
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment