-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
computeAll things compute relatedAll things compute relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersIssues pertaining to the dependency & platform wrappers
Description
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
- Storage buffer creates with specified size
- Data writes from CPU
- Data reads back to CPU
- Binds to compute pipeline
- Example with data processing
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- Read-back requires staging buffer and map_async
- STORAGE usage flag required
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
computeAll things compute relatedAll things compute relatedenhancementNew feature or requestNew feature or requestlambda-rsIssues pertaining to the core frameworkIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappersIssues pertaining to the dependency & platform wrappers