Overview
Add storage buffer support for read-write GPU memory used by compute shaders.
Current State
No response
Scope
Goals:
- Storage buffer creation with read/write usage
- Binding to compute and render pipelines
- CPU readback support
- Dynamic resizing
Non-Goals:
- Atomic operations
- Indirect buffers
Proposed API
pub struct StorageBuffer {
buffer: wgpu::Buffer,
size: u64,
}
pub struct StorageBufferBuilder {
size: u64,
usage: StorageBufferUsage,
initial_data: Option<Vec<u8>>,
}
#[derive(Clone, Copy)]
pub struct StorageBufferUsage {
pub read: bool,
pub write: bool,
pub cpu_readable: bool,
}
impl StorageBufferBuilder {
pub fn new(size: u64) -> Self;
pub fn with_usage(self, usage: StorageBufferUsage) -> Self;
pub fn with_data<T: bytemuck::Pod>(self, data: &[T]) -> Self;
pub fn build(self, gpu: &Gpu) -> StorageBuffer;
}
impl StorageBuffer {
pub fn write<T: bytemuck::Pod>(&self, gpu: &Gpu, data: &[T]);
pub fn read<T: bytemuck::Pod>(&self, gpu: &Gpu) -> Vec<T>;
pub fn size(&self) -> u64;
pub fn as_binding(&self) -> BindingResource;
}
Acceptance Criteria
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- Read-back requires staging buffer and map_async
- STORAGE usage flag required
Overview
Add storage buffer support for read-write GPU memory used by compute shaders.
Current State
No response
Scope
Goals:
Non-Goals:
Proposed API
Acceptance Criteria
Affected Crates
lambda-rs, lambda-rs-platform
Notes