Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation error when building acceleration structure without index buffer #6278

Closed
Vecvec opened this issue Sep 15, 2024 · 0 comments · Fixed by #6282
Closed

Validation error when building acceleration structure without index buffer #6278

Vecvec opened this issue Sep 15, 2024 · 0 comments · Fixed by #6282
Labels
api: vulkan Issues with Vulkan type: bug Something isn't working

Comments

@Vecvec
Copy link
Contributor

Vecvec commented Sep 15, 2024

Description
When building an acceleration structure on vulkan a vulkan validation layer error is printed

Validation Error: [ VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03806 ] Object 0: handle = 0x2bae8c8dec0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x76173dcc | vkCmdBuildAccelerationStructuresKHR(): pInfos[0].pGeometries[0].geometry.tria
ngles.indexData.deviceAddress (0x0) is not an address belonging to an existing buffer. pInfos[0].pGeometries[0].geometry.triangles.indexType is VK_INDEX_TYPE_UINT16. The Vulkan spec states: For any element of pInfos[i].pGeometries or pInfos[i].ppGeometries wit
h a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, if geometry.triangles.indexType is not VK_INDEX_TYPE_NONE_KHR, geometry.triangles.indexData.deviceAddress must be a valid device address obtained from vkGetBufferDeviceAddress (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03806)

this is because when calling AccelerationStructureGeometryTrianglesDataKHR::default() in

let mut triangle_data =
vk::AccelerationStructureGeometryTrianglesDataKHR::default()
.vertex_data(vk::DeviceOrHostAddressConstKHR {

IndexType is set to UINT16 (because apart from when building acceleration structures NONE_KHR is not valid) therefore this needs to be set by the code.

Repro steps
Call build_acceleration_structures on a vulkan device without providing a index buffer (by setting AccelerationStructureTriangles::indices to None`)

Expected vs observed behavior
There should be no validation error but one is generated

Extra materials
Screenshots to help explain your problem.
Validation logs can be attached in case there are warnings and errors.
Zip-compressed API traces and GPU captures can also land here.

Platform
N/a

Proposed Fix

impl crate::CommandEncoder for super::CommandEncoder {
                     for triangles in in_geometries {
                         let mut triangle_data =
                             vk::AccelerationStructureGeometryTrianglesDataKHR::default()
+                                .index_type(vk::IndexType::NONE_KHR)
                                 .vertex_data(vk::DeviceOrHostAddressConstKHR {
                                     device_address: get_device_address(triangles.vertex_buffer),
                                 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants