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) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-30 13:29:12 -06:00
1 parent 0715f43ab8
commit d3ea417241
1 file changed
+4 -2
+4 -2
View File
@@ -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 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; // The length only to rsqrt precision: x86 normalizes with a bare _mm_rsqrt_ps (relative error up to 3.7e-4).
if (!(fabs(gotN.Length() - 1.0) < 1e-4 && dot > 0.9999)) { 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, 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); gotN.x, gotN.y, gotN.z, wantN.x, wantN.y, wantN.z);
return false; return false;