feat(lambda-rs): Add write_slice and write_bytes to Buffer
#108
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.
Summary
Adds
write_sliceandwrite_bytesmethods toBufferinlambda-rs, providing more flexible ways to upload data to GPU buffers. These complement the existingwrite_valuemethod by supporting raw byte slices and typed slices of plain-old-data values.Related Issues
Changes
write_bytes(&self, gpu: &Gpu, offset: u64, data: &[u8])for writing raw byte slices directly to a bufferwrite_slice<T: Copy>(&self, gpu: &Gpu, offset: u64, data: &[T])for writing slices of POD values (vertices, indices, instance data, uniform blocks)value_as_bytesandslice_as_byteshelper functions to convert typed data to byte sliceswrite_valueto use the newwrite_bytesinternally for consistencyslice_as_byteswith a debug assertion for byte length overflowvalue_as_bytes_matches_native_bytes,slice_as_bytes_matches_native_bytes, andslice_as_bytes_empty_is_emptyType of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
Manual verification steps (if applicable):
write_valuecontinue to workScreenshots/Recordings
N/A - No visual changes.
Platform Testing
Additional Notes
T: Copybound ensures only trivially copyable types can be written, which is required for safe byte reinterpretationslice_as_bytesfunction includes overflow protection that returns an empty slice and triggers a debug assertion if the byte length calculation would overflow