Expose StagingBelt
allocation directly.
#6900
Open
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
Description
Added a method
StagingBelt::allocate()
. This allows usingStagingBelt
for copying to textures or any other operation where copying to an existing buffer is not the desired outcome.One unfortunate feature of the API is that
allocate()
returns the entire buffer and an offset, so applications could accidentally touch parts of the belt buffer outside the intended allocation. It might make more sense to returnwgpu::BufferSlice
, but that struct cannot be used in operations likecopy_buffer_to_texture
and does not have getters, so it is not currently suitable for that purpose.I also moved
Exclusive
into a module so that its unsafe-to-access field is properly private, and made various improvements to theStagingBelt
documentation, such as acknowledging thatwrite_buffer_with()
exists.Testing
I have manually tested the new function with my application which uses
StagingBelt
heavily. There are no unit-tests ofStagingBelt
and I did not add any.Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.