enhanced-determinism feature does not guarantee cross-platform determinism for 3D (missing glamx/scalar-math)#426
Open
RaphaelLEMAS wants to merge 2 commits into
Conversation
Ughuuu
pushed a commit
to appsinacup/godot-rapier-physics
that referenced
this pull request
Jun 20, 2026
…inism for 3D (#564) 3D version of this plugin is not really cross deterministic even with enhanced-determinism flag for these reasons: - Non cross platform deterministic math was used (sqrt, length, normalize, quaternion manipulations). - Parry dependency coming from Rapier3D dependency also has a bug with 3D cross platform determinism. What I did: - Used only cross platform deterministic maths - Added the glamx/scalar-math under the enhanced-determinism flag _Note:_ _The glamx/scalar-math is only a temporary fix. It can be removed once the [Rapier](https://github.com/dimforge/rapier) repository includes the [Parry](https://github.com/dimforge/parry) dependency with this [fix](dimforge/parry#426 - Fixes #562 --------- Co-authored-by: Raphael <raphael.lemas.e@thalesdigital.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The enhanced-determinism feature in parry3d enables glamx/libm to ensure transcendental functions (sin, cos, sqrt, etc.) produce identical results across platforms. However, it does not enable glamx/scalar-math, which means glam still uses architecture-specific SIMD backends for basic vector and quaternion operations.
This causes cross-platform divergence in 3D computations between arm64 and x86_64 due to floating-point non-associativity in the dot product implementation:
arm64 (NEON): Vec4::dot uses vmulq_f32 + vaddvq_f32 — sums all 4 products in one reduction
x86_64 (SSE2): Vec4::dot uses _mm_mul_ps + pairwise _mm_add_ps via shuffles
Since (a+b)+(c+d) ≠ ((a+b)+c)+d at the floating-point ULP level, any operation involving Vec3/Vec4/Quat normalization or dot products produces slightly different results on arm64 vs x86_64. This affects all parry3d consumers relying on enhanced-determinism for cross-platform reproducibility.
The 2D case (parry2d) is unaffected because Vec2 in glam always uses scalar code — there are no SIMD optimizations for 2-component vectors.