Skip to content
Discussion options

You must be logged in to vote

@FeatheredOrbit bevy's ShaderStorageBuffer::set_data() has no partial update support. looking at the source, it serializes the entire value via encase into a new Vec<u8>, then prepare_asset creates a brand new GPU buffer every call. none of bevy's built-in buffer types (StorageBuffer, DynamicStorageBuffer, RawBufferVec) support partial GPU writes with offsets either.

the fix: drop to the render world and use RenderQueue::write_buffer() directly

wgpu's Queue::write_buffer() supports offset-based partial writes natively, and bevy's RenderQueue derefs to it. GpuShaderStorageBuffer exposes the underlying buffer field as pub.

  1. pre-allocate the buffer at max size so it doesn't get recreated:
let

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FeatheredOrbit
Comment options

Answer selected by FeatheredOrbit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants