CNA-VGAP-002: BoundingSphere::CreateFromBoundingBox and the SmoothStep/Hermite/CatmullRom helpers use different arithmetic from XNA 4.0, and no oracle measures last-bit agreement

CNA snapshot 009d40f5  ·  Known Issues › Verification gaps  ·  source links pinned to 009d40f5

✓

Evidence basis: source-verified at the pinned commit; tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.

CreateFromBoundingBox and the SmoothStep/Hermite/CatmullRom helpers compute with formulas or precision that differ from XNA's, and only CreateFromPoints has an XNA oracle.

Identifier
CNA-VGAP-002
Category
Verification gap
Subsystem
Math & geometry
Status
Open
Verified against
CNA 009d40f5 (009d40f5dd085c4e674d3479675fac84b12b3e0a)
Evidence basis
Source-verified: read at TARGET, not executed
Tests touching this area
Yes: see Current tests
Affected contract
BoundingSphere::CreateFromBoundingBox; MathHelper::SmoothStep, Hermite, CatmullRom; Vector2/3/4::SmoothStep and Hermite

Expected behaviour

CNA's math module aims at XNA-exact results where they are cheap to reach, and backs that with oracle tests (BoundingSphereOracleTests.cpp, MatrixOracleTests.cpp).

Actual behaviour at TARGET

BoundingSphere::CreateFromBoundingBox in BoundingSphere.cpp computes the centre as (Min + Max) / 2 and the radius as Distance(center, Max); XNA uses Vector3.Lerp(Min, Max, 0.5f) and Vector3.Distance(Min, Max) * 0.5f. MathHelper.cpp evaluates Hermite and CatmullRom in double (Hermite with endpoint shortcuts for amounts within machine epsilon of 0 or 1) and SmoothStep through that Hermite, whereas XNA's MathHelper computes all three in float: Lerp(value1, value2, t*t*(3 - 2t)) for SmoothStep and its own float polynomials for Hermite and CatmullRom. The vector SmoothStep forms (SmoothStepScalar in Vector2.cpp, Vector3.cpp and Vector4.cpp) evaluate the float Hermite basis with zero tangents, where XNA computes value1 + (value2 - value1) * (t*t*(3 - 2t)). The vector Hermite forms (HermiteScalar) use the same float polynomial and operation order as XNA's Vector2/3/4.Hermite, so there only the evaluation precision of the 32-bit x87 runtime could differ. Agreement in the last bit is plausible for many inputs but unmeasured.

Source locations

Evidence

Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. XNA formulas as recorded by the chapter package from the XNA 4.0 IL; the numerical difference was not measured.

Independent re-verification: Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. XNA formulas were compared with the decompiled XNA 4.0 MathHelper, Vector2, Vector3, Vector4 and BoundingSphere; the public contract should list the vector SmoothStep helpers rather than the vector Hermite helpers as the ones with different arithmetic. The numerical difference was not measured.

Focused reproduction

No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.

Current tests

Behavioural tests exist (for example CreateFromBoundingBoxEnclosesBox and CreateFromBoundingBoxCenterIsBoxCenter in BoundingSphereTests.cpp); none compares bits with XNA.

Regression test

Oracle tables generated on the XNA runtime for CreateFromBoundingBox and for SmoothStep/Hermite/CatmullRom at a sweep of amounts, compared bit for bit.

Blast radius

Code that needs XNA-reproducible numerics (replays, lockstep simulations); ordinary games are unaffected.

Workaround

No workaround is known.

The same subject is explained at several altitudes. These are the neighbouring pages at each one.