Skip to content

[Feature] Storage buffers #172

Description

@vmarcella

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

pubstructStorageBuffer{buffer: wgpu::Buffer,size:u64,}pubstructStorageBufferBuilder{size:u64,usage:StorageBufferUsage,initial_data:Option<Vec<u8>>,}#[derive(Clone,Copy)]pubstructStorageBufferUsage{pubread:bool,pubwrite:bool,pubcpu_readable:bool,}implStorageBufferBuilder{pubfnnew(size:u64) -> Self;pubfnwith_usage(self,usage:StorageBufferUsage) -> Self;pubfnwith_data<T: bytemuck::Pod>(self,data:&[T]) -> Self;pubfnbuild(self,gpu:&Gpu) -> StorageBuffer;}implStorageBuffer{pubfnwrite<T: bytemuck::Pod>(&self,gpu:&Gpu,data:&[T]);pubfnread<T: bytemuck::Pod>(&self,gpu:&Gpu) -> Vec<T>;pubfnsize(&self) -> u64;pubfnas_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    computeAll things compute relatedenhancementNew feature or requestlambda-rsIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions