From ea785355cd980765b60169621634d903440f6473 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 9 Oct 2026 10:22:01 -0400 Subject: [PATCH] GPU: note why Posterize's division correction is an fma (#405 follow-up) Co-Authored-By: Claude Opus 5.5 --- crates/gpu/src/shaders/fx_stylize.wgsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/gpu/src/shaders/fx_stylize.wgsl b/crates/gpu/src/shaders/fx_stylize.wgsl index b98c7474..3db44275 100644 --- a/crates/gpu/src/shaders/fx_stylize.wgsl +++ b/crates/gpu/src/shaders/fx_stylize.wgsl @@ -40,6 +40,8 @@ fn fxs_smoothstep(e0: f32, e1: f32, x: f32) -> f32 { fn fxs_qdiv(x: vec3, a: f32) -> vec3 { let q = x / a; let r = fma(-q, vec3(a), x); + // `q + r / a`, written as an fma so drivers (NVIDIA Vulkan) can't contract it another way + // and round differently from the CPU. return fma(r / a, vec3(1.0), q); }