From d3ea4172414ab2b1e73d4a2f1cc4ab68b02cea01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 30 Sep 2026 13:29:12 -0600 Subject: [PATCH] Unit tests: Allow rsqrt precision in spline normal lengths x86 normalizes with a bare _mm_rsqrt_ps, so normal lengths are only good to about 3.7e-4 there and the 1e-4 check failed on every x86 CI job. Compare direction after normalizing instead. Co-Authored-By: Claude Opus 5.5 (1M context) --- unittest/TestSplineTessellation.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unittest/TestSplineTessellation.cpp b/unittest/TestSplineTessellation.cpp index 91a6210d9f..084ca6e7ab 100644 --- a/unittest/TestSplineTessellation.cpp +++ b/unittest/TestSplineTessellation.cpp @@ -358,8 +358,10 @@ bool CheckVertex(const TestCase &tc, const RefSurface &ref, const SimpleVertex & } } const D3 gotN = { got.nrm.x, got.nrm.y, got.nrm.z }; - const double dot = gotN.x * wantN.x + gotN.y * wantN.y + gotN.z * wantN.z; - if (!(fabs(gotN.Length() - 1.0) < 1e-4 && dot > 0.9999)) { + // The length only to rsqrt precision: x86 normalizes with a bare _mm_rsqrt_ps (relative error up to 3.7e-4). + const double gotLen = gotN.Length(); + const double dot = (gotN.x * wantN.x + gotN.y * wantN.y + gotN.z * wantN.z) / gotLen; + if (!(fabs(gotLen - 1.0) < 5e-4 && dot > 0.9999)) { printf("%s: vertex %d at (%.3f, %.3f): normal %f %f %f, want %f %f %f\n", tc.name, index, u, v, gotN.x, gotN.y, gotN.z, wantN.x, wantN.y, wantN.z); return false;