Files
craft-libs/docs/gpu-providers.md
T
dotCooCoo d9473fcefb craft-gpu-yuv: run as the craft.yuv provider on craft-gpu
YuvProvider implements craft-gpu's GpuProvider under the id craft.yuv.
YuvJob writes and strictly parses the job's key:value parameters. The
provider checks the source and output sides and the padded read-back
size against the context's DeviceCaps and the input's length before
reading it, so a job is refused the same way on craft-gpu-null and on
a device. YuvProvider::new() converts on the CPU on any context;
with_device runs the render passes on a device the host holds, inside
validation and out-of-memory error scopes.

Code values now round halves away from zero on the CPU and in WGSL, as
INT in BT.709 and BT.2020 and Round in BT.2100 do. Round-half-even gave
full-range cyan a Cr of 0 instead of 1.

oracle_tests.rs checks the conversion against sources outside the
crate: code values computed in f64 from each recommendation's Kr, Kb
and quantization, the nominal levels the recommendations state, the
yuv crate's conversion (a dev-dependency) for every format, matrix and
range, and a 4x4 frame against the byte offsets of the WebCodecs and
Linux media API format definitions.

The README documents the job parameters, the plane layout with its
sources, the rounding rule, and why the CPU scaler takes the shader's
taps. docs/gpu-providers.md lists craft.yuv.
2026-11-17 18:08:53 -08:00

2.3 KiB

GPU providers

Provider ids:

  • craft.*: shared ops in craft-gpu-providers (no app crate deps)
  • craft.noop, craft.test.echo, craft.mask, craft.composite.premul, craft.readback: registered by register_all() for worker/runtime init
    • craft.mask: CPU stand-in for FilmCraft mask composite until WGSL lands on wgpu
    • craft.composite.premul: CPU premultiplied "over" (Normal path from composite.wgsl) until WGSL lands on wgpu
    • craft.readback: CPU decode of staging buffers (f16 RGBA → f32, or fmt:u8 passthrough); uses chunk_buffer against device caps and f16_to_f32* from craft-gpu
  • craft.yuv: RGBA8 to NV12, P010 or I420 with scaling, registered from craft-gpu-yuv (YuvProvider, see its README). It is not in register_all(), since it depends on wgpu. YuvProvider::new() converts on the CPU on any context; YuvProvider::with_device runs its WGSL render passes on a device the host passes in.
  • {app}.*: registered by application wasm at init

Generic worker code must only call ProviderRegistry::dispatch: never import app gpu crates.

Dependency lint: craft-gpu-providers must not depend on effectcraft-*, filmcraft-*, or *-engine.

Readback is async underneath; these providers don't see it

GpuContext::read_buffer, the method every provider above calls, is a blocking convenience over the trait's real primitives, request_read + poll_reads (see gpu-backends.md). Nothing in this crate changed for that. craft-gpu-null still resolves read_buffer immediately. craft-gpu-wgpu's native path now does too, blocking on the device between polls. crates/gpu-wgpu/src/tests.rs runs these same providers (craft.test.echo, craft.composite.premul, craft.readback) against a real WgpuContext as well as the null one, when a real adapter is available (RFC-0022 requirement 2). A provider dispatching a real WGSL job will be the one that actually needs the non-blocking request_read/poll_reads shape directly. On wasm32 today read_buffer serves the staging read, the only backing on that target. A read that did not resolve synchronously faults. A future real device backing there will refuse blocking outright, per gpu-backends.md.