staging belt: allow creation with custom buffer usages #8580
+117 −2
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.
Connections
This addresses #8575.
allocatewas introduced in #6900Description
StagingBeltcan give you the buffer slice for more advanced usecases. The documentation incorrectly states that you could e.g. use it in a compute pass. Because the buffers are created withMAP_WRITE | COPY_SRCthis is incorrect.Creating buffers with custom buffer usages is possible, although
MAPPABLE_PRIMARY_BUFFERSmust be enabled.This PR adds a
new_with_buffer_usagesmethod with a third argument for the intended buffer usages. We could also just extend the currentnewmethod, if API breakage is possible. The new method verifies that the combination ofBufferUsages is possible depending on theMAPPABLE_PRIMARY_BUFFERSfeature.The
MAP_WRITEusage is always added to the supplied buffer usages.I've also stripped the mention of using this with a compute pass from the documentation of
allocate. In my opinion using the staging belt with mappable primary buffers is really a niece case.Testing
I've added 2 test:
staging_belt_panics_with_invalid_buffer_usagesgoes through all buffer usages exceptCOPY_SRCandMAP_WRITEand checks that the constructor panics.staging_belt_works_with_non_exclusive_buffer_usagesthat the new constructor works withCOPY_SRC,COPY_SRC | MAP_WRITEandMAP_WRITE.Furthermore
staging_belt_random_testverifies that any previous functionality isn't lost.Merge or Squash
This should be squashed.
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.