Skip to content
Systems· 2 min read

Why Deterministic CPU Reference Renderers Still Matter in GPU Pipelines

Notes from building real-time AGSL and WebGL2 imaging engines where visual parity across mobile drivers depends on a bit-verifiable CPU oracle.

#Graphics#Mobile#Testing#Shaders
Contents (4)

When shipping real-time image shaders—whether AGSL on Android or WebGL2 in the browser—the fastest way to accumulate subtle visual regressions is to trust driver-specific GPU math as your sole source of truth. Different mobile GPUs vary in half-precision (mediump) rounding, sRGB texture sampling, and edge clamping.

While building LiEffects and editorium, pairing every live GPU shader graph with a deterministic CPU reference renderer turned out to be the highest-leverage engineering decision in both codebases.

The Verification Contract#

We treat the GPU path as a fast approximation of a pure functional reference operator Fref:[0,1]H×W×3→[0,1]H×W×3F_{\text{ref}} : [0, 1]^{H \times W \times 3} \to [0, 1]^{H \times W \times 3}. For a test image II, we verify that the GPU output I^=Fgpu(I)\hat{I} = F_{\text{gpu}}(I) satisfies a strict perceptual and numeric envelope:

PSNR(Iref,I^)=10log⁡10 ⁣(113HW∥Iref−I^∥F2)≥48 dB,max⁡x,yΔE00(x,y)<0.8\mathrm{PSNR}(I_{\text{ref}}, \hat{I}) = 10 \log_{10}\!\left(\frac{1}{\frac{1}{3HW}\norm{I_{\text{ref}} - \hat{I}}_F^2}\right) \ge 48\,\text{dB}, \qquad \max_{x,y} \Delta E_{00}(x, y) < 0.8

Pipeline Parity Flow#

Diagram
Rendering diagram...
Dual-path verification: GPU preview vs. deterministic CPU export.
Deterministic frame-by-frame render comparison across pipeline stages.

Shared Transfer Function Math#

Both the shader and CPU reference execute identical piecewise sRGB linearization before any tone-mapping or film curve is applied:

kotlin
fun srgbToLinear(c: Float): Float {
    val clamped = c.coerceIn(0f, 1f)
    return if (clamped <= 0.04045f) {
        clamped / 12.92f
    } else {
        ((clamped + 0.055f) / 1.055f).pow(2.4f)
    }
}

Measured Trade-Offs#

Pipeline StageGPU Preview (1080p)CPU Reference (12 MP Export)Peak PSNR Parity
Tone Curve + White Balance0.9 ms118 ms56.2 dB
3D Hald LUT (33³ Tetrahedral)1.4 ms240 ms51.8 dB
Stateless Film Grain + Vignette1.1 ms164 ms54.0 dB

Footnotes#

  1. Stateless coordinate hashing also guarantees tiled high-resolution exports never exhibit visible seam discontinuities along tile boundaries. ↩

Cite this thought

Academic BibTeX entry for referencing this note.

@misc{ali2026_deterministic_image_pipelines,
  author       = {Ali, MD Ahad},
  title        = {{Why Deterministic CPU Reference Renderers Still Matter in GPU Pipelines}},
  howpublished = {aliahadmd.github.io},
  year         = {2026},
  month        = oct,
  url          = {https://aliahadmd.github.io/thoughts/2026-10-deterministic-image-pipelines/}
}