Skip to main content

Crate flashraw_gpu

Crate flashraw_gpu 

Source
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§

DevelopSpec
Parameters of the fused develop pass (mirror of flashraw::process::DevelopParams).
GpuAdapterInfo
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, plus MAP_READ on unified-memory adapters), on the device of the GpuContext that produced it.
GpuRun
Result of GpuContext::run: a GPU-resident image plus timings.
GpuTile
One band of a GpuImage: the pixels of rect (image coordinates), stored row-major with rect.width * channels samples per row from byte 0 of buffer.
GpuTimings
Per-stage timings of one run, in milliseconds.

Enums§

AdapterClass
Coarse adapter class used by backend selection.
DevelopOutput
Output of the develop kernel.
GpuInput
Input raster.
GpuOp
What to compute.
GpuPixelFormat
Element format of a GpuImage buffer.
HostPixels
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 flashraw API).
context
The global GPU context, initialising it on first use (native: blocking). In the browser this only returns a context after init has 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 CPU flashraw::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).