Skip to content

[ray-tracing] Vulkan uses strange first vertex field which core fails to uphold requirements of #9216

@Vecvec

Description

@Vecvec

Description
Vulkan's wgpu-hal uses a field called first_vertex to do its vertex offsets, but wgpu core does not uphold the requirements of this - specifically https://docs.vulkan.org/refpages/latest/refpages/source/VkAccelerationStructureBuildRangeInfoKHR.html#VUID-VkAccelerationStructureBuildRangeInfoKHR-maxVertex-10774

Both DX12 and metal use vertex buffer offsets instead of this, and vulkan seems to be able to - see https://docs.vulkan.org/refpages/latest/refpages/source/vkCmdBuildAccelerationStructuresKHR.html#VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03711, which would fix this and also allow a proper offset field.

Edit: actually metal requires the offset to be a multiple of the vertex stride

Repro steps
Apparently happens in bevy solari?

Expected vs observed behavior
Comes up with validation warnings when it shouldn't

Extra materials

Validation Error: [ VUID-VkAccelerationStructureBuildRangeInfoKHR-maxVertex-10774 ] | MessageID = 0x9730713e
vkCmdBuildAccelerationStructuresKHR(): Index out of bounds.
Index (616) + firstVertex (52281) = 52897 but VkAccelerationStructureGeometryTrianglesDataKHR::maxVertex is only 719.     
Index was found at VkDeviceAddress indexData (0x1a6eb800) + primitiveOffset (1069356) = 0x1a7f092c
Given index type of VK_INDEX_TYPE_UINT32, and that starting address, that's IndexBuffer[1824].
BLAS build command info:
VkAccelerationStructureBuildGeometryInfoKHR[6]::VkAccelerationStructureGeometryKHR[0]::VkAccelerationStructureGeometryTrianglesDataKHR was:
    vertexFormat: VK_FORMAT_R32G32B32_SFLOAT
    vertexData: 0x1aa2b800
    vertexStride: 48
    maxVertex: 719
    indexType: VK_INDEX_TYPE_UINT32
    indexData: 0x1a6eb800
    transformData: 0x0

Platform

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions