Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[RFC] Add GlobalBuffer proposal #282
[RFC] Add GlobalBuffer proposal #282
Changes from 11 commits
c68dfda
2dda6b4
8f34f68
be7c3cd
390130f
4e233f8
b6dff2c
534bb08
d7f9d04
893d70d
5e76937
03e3753
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some slight trouble understanding this as written - does this mean that each thread gets 1024 items available to itself to iterate over, or does this mean that
N
here is the amount of total threads launched? In the latter case, shouldn't this beGlobalBuffer<[T]>
instead from a usability point of view? I see in your proposal that this is used to create a slice of N long; however this would prose problems for most use-cases as they won't know the size of theGlobalBuffer
at compile-time right?It's kind of unfortunate that we can't rely on vulkan's built in robust buffer access support since it just silently ignores out of bounds access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is to have both arrays and runtime arrays, with GlobalBuffer<[T; N]> and GlobalBuffer<[T]>. Right now, slices can't be used in entry parameters.
In this simple example, the buffers have 1024 f32's. I haven't proposed any way to validate that the buffers actually have that length. You are right that generally these would be runtime arrays with some runtime length.
The compute shader sees 1024 items in each buffer. It is up to GlobalBufferMut, through some safe interface, to ensure that each thread / invocation only sees some exclusive piece of it. In this case, the zip_mut_with function just indexes both buffers by the global index and applies the provided function, which operates on a single pair of scalars. If the global index is out of bounds, the function is not applied.
I think I will edit this to show using slices because the array is confusing.