Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Vulkan has a min alignment for buffer bindings, between 1 and 256 bytes. This makes it non trivial to pass an arbitrary slice as an argument, because it might not be aligned. For instance, the alignment might be 16 bytes, so slices that aren't multiples of 4 u32's would be invalid.
WebGPU has an identical restriction and works the same way.
This PR adds a pass at build time to add a buffer offset as a push constant for each buffer. This is computed as the remainder, the part of the offset that can't be passed via the offsets applied via Vulkan. The access chains and length ops are adjusted based on this offset.
v1 added push constants for both offsets and lengths via custom buffer / slice types. In v2, plain slices are supported, and offsets are added via manipulation of the resulting assembly at build time.
Because the offset can only be as large as 256, 4 could be packed into a single u32. Additionally, items could be computed directly from the lengths of arguments, and doesn't need to be passed as a push constant.