Fix cross-platform math determinism (Mac/Linux)#217
Draft
fbraz3 wants to merge 12 commits into
Draft
Conversation
…determinism fixes - Replaced division by zero traps in float logic with Div_FixNaN - Included Div_FixNaN helper in wwmath.h - Added deterministic BezierMath (D3DXVec4Transform & D3DXVec4Dot) - Downcasted Atan2 double arguments to float - Backported PR #3 and #4 from Zero Hour to the base Generals game Ref: TheSuperHackers#3 Ref: TheSuperHackers#4
fbraz3
force-pushed
the
fix-mac-linux-math-determinism
branch
from
July 15, 2026 22:22
47f292e to
23f9aa6
Compare
…_availableOnFrame fix to Generals Missed during PR #3 backport: Remove RETAIL_COMPATIBLE_CRC guard around m_availableOnFrame initialization. Always set to 0 to prevent special powers from being stuck when RETAIL_COMPATIBLE_CRC is off.
- Force double-precision variants of SqrtOrigin and PowOrigin to downcast and use single-precision gm_*f implementations. - This prevents a known 1-ULP drift on ARM64 NEON vs x86 x87 FPU when evaluating double-precision transcendentals. - Documented NaN and double-precision determinism guidelines in AGENTS.md.
- Disabled FMA contraction globally in MSVC via /fp:precise - Added ScopedFPUGuard at the entry point of GameLogic::update - Added ScopedFPUGuard to MiniAudioManager and W3DView pickDrawable - Backported GameLogic::update FPU guard to Generals base game - Created scripts/qa/sync/run-determinism-harness.sh to automate cross-platform desync debugging This completes the execution of steps 1, 5, and 6 of the FP determinism analysis to prevent FP-environment state leaks from OS/Audio threads into simulation math and guarantees MSVC produces bit-exact IEEE-754 semantics matching ARM64/Linux.
…ging support Implement in-memory deep CRC frame buffering to identify mismatch causes. - Buffers 64 frames in memory using std::vector<UnsignedByte> behind DEEP_CRC_TO_MEMORY. - Dumps buffers to logs/deep_crc_YYYY-MM-DD-HH-MM-SS.bin only upon a mismatch. - Adds OS/Arch header for cross-platform debugging telemetry. - Enhances mismatch string passed to setSawCRCMismatch with frame details and player-level mismatches. - Fixes issue where disconnected/defeated players would cause false-positive CRC quorum failures. - Enabled for both Generals and GeneralsMD.
…ory creation - Ensure the 'logs' directory is created automatically before dumping CRC payload. Previously silently failed because the 'logs' folder didn't exist in the user data directory.
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.
Description
Fixes cross-platform math determinism between Mac (ARM64), Linux (x86_64) and Windows.
This addresses the math precision and ambiguity issues related to
SqrtOrigin,Atan2Origin, andPowOrigin.Changes
floatoverloads for deterministic math wrappers inwwmath.h.(float)casts to resolve ambiguous math function calls (e.g. inAIPathfind.cpp).Inf/NaNpropagating into integers.