Make double min/max follow DXIL FMin/FMax

dxc lowers double min/max to dx.op.binary.f64 opcodes 36/35 (FMin/FMax),
the same operations as float, so Math.Min/Math.Max (NaN-propagating) was the
wrong rule. Double min/max now use the float formulas, with NaN and signed-zero
assertions beside the float ones. Tracked Unity DLL rebuilt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-14 14:47:10 +02:00
commit 19e23db211
4 changed files with 11 additions and 2 deletions

View file

@ -402,8 +402,9 @@ public static partial class math
public static float3 atan2(float3 y, float3 x) => new(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z));
public static float4 atan2(float4 y, float4 x) => new(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w));
public static double min(double left, double right) => Math.Min(left, right);
public static double max(double left, double right) => Math.Max(left, right);
// DXIL FMin/FMax take double overloads with the same rules as float (see min/max above).
public static double min(double left, double right) => left < right || double.IsNaN(right) ? left : right;
public static double max(double left, double right) => left >= right || double.IsNaN(right) ? left : right;
public static bool any(bool2 value) => value.x || value.y;
public static bool any(bool3 value) => value.x || value.y || value.z;