Skip to main content

Module storage_texture

Module storage_texture 

Source
Expand description

Storage-texture output kernel support for OxiGDAL GPU.

This module enables compute shaders to write their output directly to a 2-D storage texture (WGSL texture_storage_2d<format, write>), bypassing the round-trip to a CPU-visible staging buffer. The resulting texture lives on the GPU and can be consumed by subsequent render passes, image-processing pipelines, or downloaded via read_texture_to_vec_f32 when the host needs the data.

§Typical workflow

  1. Create a storage texture with new_storage_texture.
  2. Build a compute kernel from WGSL source with build_storage_texture_kernel.
  3. Upload input data as a GpuBuffer using the standard buffer API.
  4. Execute the kernel with StorageTextureKernel::dispatch_to_texture.
  5. Optionally download results with read_texture_to_vec_f32.

§Supported formats

wgpu::TextureFormatWGSL format string
Rgba32Floatrgba32float
Rgba8Unormrgba8unorm
R32Floatr32float

Other formats are rejected by new_storage_texture with GpuError::UnsupportedFormat.

Structs§

StorageTextureBinding
A 2-D GPU texture created with STORAGE_BINDING | COPY_SRC usage.
StorageTextureKernel
A compiled compute kernel that writes its output to a storage texture.

Functions§

build_storage_texture_kernel
Compile a WGSL compute shader into a StorageTextureKernel.
is_supported_storage_format
Returns true if format is accepted by new_storage_texture.
make_storage_texture_shader_source
Generate default WGSL source for a kernel that copies a flat f32 input buffer into a 2-D storage texture.
new_storage_texture
Create a new 2-D storage texture on the GPU.
read_texture_to_vec_f32
Copy a storage texture to host memory, returning a Vec<f32>.