CultLib/packages/cultmath/tests/CultMath.Tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Meta Vens 9407da0461 Match float min, max, clamp, and saturate to DXIL FMin/FMax/Saturate
dxc lowers float min/max/clamp to dx.op FMin/FMax (36/35) and saturate to
dx.op Saturate (7). DXIL.rst defines them: FMin(a, b) is a < b ? a : b,
FMax(a, b) is a >= b ? a : b, a NaN operand returns the other, and
Saturate is FMin(1, FMax(0, x)). C# used MathF.Min/Max, which pass NaN
through and order signed zeros, so saturate(NaN) was NaN instead of 0.

Every float overload now follows the spec, normalize uses the same max as
its mirror, and the mirror's saturate spells Saturate's operand order
(which maps -0 to +0, where clamp(x, 0, 1) keeps -0). Non-NaN results
change only in the sign of a zero. design.md records the rules and that
dxc marks float math fast, so GPU NaN results are not guaranteed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 14:32:19 +02:00
..
CultMath.Tests.csproj Compile the real HLSL mirror as C# and with dxc; fix its errors 2026-09-14 13:57:03 +02:00
CultMath.Tests.csproj.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
HlslMirrorTests.cs Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
HlslMirrorTests.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00
HlslSemanticsTests.cs Match float min, max, clamp, and saturate to DXIL FMin/FMax/Saturate 2026-09-14 14:32:19 +02:00
HlslSemanticsTests.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
HlslSourceCompatibilityTests.cs Compare every HLSL mirror function against C# math, bit for bit 2026-09-14 14:17:11 +02:00
HlslSourceCompatibilityTests.cs.meta Make CultMath HLSL-shaped: writable components, bool-vector comparisons 2026-09-14 13:29:59 +02:00
MathTests.cs Generate every HLSL swizzle and mixed constructor; fix intrinsic types 2026-09-14 13:57:02 +02:00
MathTests.cs.meta Move CultMath into the CultLib monorepo 2026-08-26 17:35:51 +02:00