LobstersBruno Croci17 min readintermediate
When adding a fractional part to a number fixes your shader
Summary
A Voronoi fragment shader stutters on an RTX 4070; the author discovers that replacing `fract()` with `x‑floor(x)` eliminates the glitch, suspects a driver miscompile, and documents a week‑long manual debugging process with code, device tests, and LLM‑assisted hypotheses.
- GPU driver bugs can manifest as subtle visual artifacts; even well‑tested GLSL functions like `fract` may misbehave on specific hardware/driver versions.
- When a shader behaves inconsistently across devices, isolate the offending code by stripping features and testing on multiple GPUs.
- Replacing `fract(x)` with the mathematically equivalent `x - floor(x)` can sidestep certain driver miscompilations because it forces a different instruction sequence.
- LLMs can suggest plausible fixes but may not reliably reproduce the underlying bug; manual inspection and minimal repro cases are still essential.
Shader developers often assume GLSL built‑ins are reliable across all GPUs. This post shows that driver‑level miscompilations can break that assumption, and that a tiny change in expression form can be a practical workaround. It also illustrates a disciplined debugging workflow that blends manual t…
6/10


