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

ray_tracing_pipeline: Pass SBT regions as reference instead of slice #350

Conversation

MarijnS95
Copy link
Collaborator

The API for vkCmdTraceRaysKHR mandates a single non-null pointer per SBT region to a VkStridedDeviceAddressRegionKHR. While providing more than one such region isn't harmful, passing a slice of length 0 will cause reads in uninitialized memory and undefined behaviour.

Converting these parameters from slices to references rids the unnecessary confusion and prevents zero regions from being passed.

The API for vkCmdTraceRaysKHR mandates a single non-null pointer per SBT
region to a VkStridedDeviceAddressRegionKHR. While providing more than
one such region isn't harmful, passing a slice of length 0 will cause
reads in uninitialized memory and undefined behaviour.

Converting these parameters from slices to references rids the
unnecessary confusion and prevents zero regions from being passed.
@MaikKlein MaikKlein merged commit 84624fd into ash-rs:master Dec 29, 2020
@MarijnS95 MarijnS95 deleted the cmd-trace-rays-reference-per-sbt-region branch December 29, 2020 11:16
MarijnS95 added a commit that referenced this pull request Nov 23, 2023
…gle item

In an identical fashion to commit 84624fd ("ray_tracing_pipeline:
Pass SBT regions as reference instead of slice (#350)")
`cmd_trace_rays_indirect()` also only needs a pointer to a single
`StridedDeviceAddressRegionKHR` structure.  After all no length is ever
passed to the API anywhere, and this could also lead to users passing
empty slices, or passing too many elements that are never used.

Clear up the confusion by replacing the slice argument with a direct
borrow of the struct.
MarijnS95 added a commit that referenced this pull request Nov 23, 2023
…gle item

In an identical fashion to commit 84624fd ("ray_tracing_pipeline:
Pass SBT regions as reference instead of slice (#350)")
`cmd_trace_rays_indirect()` also only needs a pointer to a single
`StridedDeviceAddressRegionKHR` structure.  After all no length is ever
passed to the API anywhere, and this could also lead to users passing
empty slices, or passing too many elements that are never used.

Clear up the confusion by replacing the slice argument with a direct
borrow of the struct.
MarijnS95 added a commit that referenced this pull request Nov 25, 2023
…gle item (#829)

In an identical fashion to commit 84624fd ("ray_tracing_pipeline:
Pass SBT regions as reference instead of slice (#350)")
`cmd_trace_rays_indirect()` also only needs a pointer to a single
`StridedDeviceAddressRegionKHR` structure.  After all no length is ever
passed to the API anywhere, and this could also lead to users passing
empty slices, or passing too many elements that are never used.

Clear up the confusion by replacing the slice argument with a direct
borrow of the struct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants