Expand description
§flashraw-gpu
Optional wgpu compute backend for FlashRaw (Vulkan, Metal, DX12, GL and WebGPU in the browser). It runs the post-decode pipeline on the GPU:
- unpack of uniformly bit-packed payloads (every
PackOrder, 1..16 bits) straight from the file bytes, so uncompressed RAWs never touch the CPU; - normalise (per-position black pattern, row/column deltas, white scaling);
- develop: one fused kernel for linearisation LUT → normalisation → bilinear / 3x3 same-colour demosaic (or 2x2 superpixel) → white balance → clip → colour matrix → sRGB + EXIF orientation → RGBA8 (or linear f32 RGB).
Results are GPU-resident GpuImages that can be bound by the application
(GpuImage::buffer, GpuImage::to_texture) or downloaded.
Frames of any size are supported: when a frame exceeds the adapter’s storage-binding
or buffer limits it is processed in pipelined horizontal bands, and outputs larger
than one buffer become tiled GpuImages (GpuImage::tiles).
Every kernel has a CPU scalar reference (flashraw::process,
flashraw_codecs::packed) and equivalence tests (tests/equivalence.rs).
WGSL sources live in this crate’s shaders/ directory.
use flashraw_gpu::{GpuFrame, GpuOp};
let ctx = flashraw_gpu::context()?;
println!("{}", ctx.info());
let run = ctx.run_blocking(&GpuFrame::from_u16(&data, 4, 4, 1), &info, &GpuOp::Normalize)?;
let (pixels, _ms) = run.image.download()?;Re-exports§
pub use wgpu;
Modules§
- policy
- CPU-vs-GPU backend selection.
- reference
- Scalar models of the GPU kernels’ addressing, written to mirror the WGSL line by
line. They let the bit-level semantics be tested on machines without a GPU
(against
flashraw_codecs::packed::unpack_row_scalar), and serve as executable documentation of the shader behaviour.
Structs§
- Develop
Spec - Parameters of the fused develop pass (mirror of
flashraw::process::DevelopParams). - GpuAdapter
Info - Description of the adapter in use.
- GpuContext
- A device plus everything FlashRaw needs to run its kernels on it.
- GpuCurve
- Encoder tables of a non-sRGB output curve (the CPU
CurveTables). - GpuFrame
- A frame to process: an input raster plus the window and coordinate anchors.
- GpuImage
- An image living in GPU storage buffers (
STORAGE | COPY_SRC, plusMAP_READon unified-memory adapters), on the device of theGpuContextthat produced it. - GpuRun
- Result of
GpuContext::run: a GPU-resident image plus timings. - GpuTile
- One band of a
GpuImage: the pixels ofrect(image coordinates), stored row-major withrect.width * channelssamples per row from byte 0 ofbuffer. - GpuTimings
- Per-stage timings of one run, in milliseconds.
Enums§
- Adapter
Class - Coarse adapter class used by backend selection.
- Develop
Output - Output of the develop kernel.
- GpuInput
- Input raster.
- GpuOp
- What to compute.
- GpuPixel
Format - Element format of a
GpuImagebuffer. - Host
Pixels - Host copy of a downloaded
GpuImage.
Functions§
- adapter_
info - Adapter description of the global context.
- available
- Whether a GPU adapter is available (initialises the context on native).
- block_
on - Block on a future (native only; used by the synchronous
flashrawAPI). - context
- The global GPU context, initialising it on first use (native: blocking).
In the browser this only returns a context after
inithas completed. - init
- Initialise the global GPU context (idempotent). Required before any GPU work in the browser, where initialisation cannot block.
- set_
context - Install an application-provided context (see
GpuContext::from_device) as the global one used by FlashRaw. - srgb16_
table - Linear -> sRGB curve scaled to 16 bits at 16385 evenly spaced points of
[0, 1](exact in f64, stored as f32; same table as the CPUflashraw::process::srgb16_lut). - try_
context - The global context if it has already been initialised (never initialises).
- wgsl_
sources - WGSL sources of every kernel module, for embedding in other runtimes (e.g. a
hand-written WebGPU pipeline in JavaScript). Each entry is
(name, source).