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 <noreply@anthropic.com>
This commit is contained in:
1 parent
4063635f39
commit
169db7f16f
1 file changed
+5
-2
@@ -37,10 +37,13 @@ const MOVE_NONE: u32 = 4294967295u;
|
|||||||
// resolve a deep one the same way.
|
// resolve a deep one the same way.
|
||||||
const CHAIN_LIMIT: u32 = 64u;
|
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 {
|
fn scalar_within(s: UiScalar, p: UiSpan) -> UiScalar {
|
||||||
return UiScalar(
|
return UiScalar(
|
||||||
mix(p.start.rel, p.end.rel, s.rel),
|
p.start.rel + (p.end.rel - p.start.rel) * s.rel,
|
||||||
s.px + mix(p.start.px, p.end.px, s.rel),
|
s.px + (p.start.px + (p.end.px - p.start.px) * s.rel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user