Skip to main content

Module gpu_colour_kernel

Module gpu_colour_kernel 

Source
Expand description

P7.4 — GPU colour-projection / gamut batch kernel + CPU oracle. P7.4 — GPU colour-projection / gamut batch kernel + CPU oracle.

The GPU kernel processes batches of EMF payloads [α, μ, σ] through the full colour pipeline (SPD → XYZ → linear sRGB → gamut map → display sRGB) in parallel. This module provides:

  1. CPU oracle: the reference implementation for correctness checks.
  2. GPU kernel spec: the WGSL shader source and buffer layout specification for the GPU implementation.
  3. Differential check: compares CPU vs GPU output for a given batch.

§Buffer layout (GPU)

Bind group 0:
  - storage buffer: EMF input  [f32×3 × N]  (α, μ, σ per element)
  - storage buffer: RGB output [u8×3 × N]   (r, g, b per element)
  - uniform buffer: params { sample_count: u32 }

§Determinism

The CPU oracle is fully deterministic. The GPU kernel must produce bit-identical output to the CPU oracle for the same input (within f32 rounding tolerance).

Structs§

GpuBufferLayout
Buffer layout specification for the GPU kernel.

Constants§

DIFF_TOLERANCE_U8
Tolerance for CPU vs GPU differential comparison. f32 rounding in the GPU kernel may produce ±1 LSB differences in the 8-bit output.
GPU_COLOUR_KERNEL_WGSL
WGSL shader source for the GPU colour-projection batch kernel.

Functions§

cpu_batch_emf_to_display_gamut_mapped
CPU oracle: process a batch of EMF payloads through the full colour pipeline and produce gamut-mapped 8-bit display RGB.
cpu_batch_emf_to_xyz
CPU oracle: process a batch of EMF payloads and produce XYZ values.
diff_cpu_gpu
Compare CPU oracle output with GPU output.