From 169db7f16f67cd2ae710c924eaaa0d7329d8771c Mon Sep 17 00:00:00 2001 From: iris-ai <4+iris-ai@noreply.localhost> Date: Tue, 15 Sep 2026 12:31:31 -0400 Subject: [PATCH] Compose a position in the shader the way the CPU composes it The shader used mix() where UiScalar::within writes from + (to - from) * t, so the two associate the arithmetic differently and can put an edge on either side of an integer. Writing it out matches them, and is a multiplication cheaper. The five reference renders and the resize render are byte-identical either way. Co-Authored-By: Claude Opus 5 --- core/src/render/shader/prelude.wgsl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/render/shader/prelude.wgsl b/core/src/render/shader/prelude.wgsl index 2b98a50..469e231 100644 --- a/core/src/render/shader/prelude.wgsl +++ b/core/src/render/shader/prelude.wgsl @@ -37,10 +37,13 @@ const MOVE_NONE: u32 = 4294967295u; // resolve a deep one the same way. const CHAIN_LIMIT: u32 = 64u; +// Written the way `UiScalar::within` writes it rather than as `mix`, so the +// CPU and the shader compose a position with the same arithmetic and answer +// the same thing about where a widget is. fn scalar_within(s: UiScalar, p: UiSpan) -> UiScalar { return UiScalar( - mix(p.start.rel, p.end.rel, s.rel), - s.px + mix(p.start.px, p.end.px, s.rel), + p.start.rel + (p.end.rel - p.start.rel) * s.rel, + s.px + (p.start.px + (p.end.px - p.start.px) * s.rel), ); }