Xezon/wip deterministic math v3#8
Open
xezon wants to merge 71 commits into
Open
Conversation
Integrate GameMath library (fdlibm) for bit-perfect cross-platform floating-point reproducibility. When USE_DETERMINISTIC_MATH is active, all WWMath functions (Sin, Cos, Sqrt, Inv_Sqrt, Float_To_Long, Acos, Asin, Atan, Atan2) use fdlibm instead of x87 asm or system CRT. - Add GameMath via FetchContent with global include paths - Replace Trig.cpp with inline WWMath::*Trig wrappers - Add WWMath::*Origin wrappers for bare CRT calls in game logic - Prioritize USE_DETERMINISTIC_MATH over _MSC_VER/_M_IX86 guards - Verified: win32 replay CRC matches original x87 output
Add global Sqrt(double) to trig.h/Trig.cpp, routing through WWMath::SqrtOrigin(). Replace 5 bare CRT sqrt() calls in BaseType.h (Coord2D::length, Coord2D::toAngle, ICoord2D::length, Coord3D::length, ICoord3D::length) with the new Sqrt() gateway. This closes the last known CRT math leak in CRC-critical code paths. Same pattern as existing Sin/Cos/ACos routing via Trig.cpp.
…erage - Restore original Trig.cpp code (author comments, defines, REGENERATE_TRIG_TABLES) - Keep only functional changes: sinf->WWMath::SinTrig redirects + Sqrt(double) - Restore original tab alignment in wwmath.h #define block - Route remaining CRT calls in SimulationMathCrc through WWMath (sinh/cosh/tanh/logf) - Add cmake comments explaining FORCE usage
- Add RUN_MATH_BENCHMARK_REPLAY400_FLAG to SimulationMathCrc.h - Implement 10000-iteration dual-path benchmark in SimulationMathCrc.cpp - Inject benchmark trigger into GameLogic::update at replay frame 400 - Benchmark measures CRT vs WWMath precision and performance
- Declare loop iterator outside of for loop in runBenchmark to support legacy MSVC scoping rules
…ministic math parity
- Merge gmath.h include + USE_DETERMINISTIC_MATH into single __has_include block - Replace all #ifdef/#if defined() with #if USE_DETERMINISTIC_MATH - Remove TheSuperHackers @fix prefix from cmake comment - Expand ODR abbreviation in gamemath.cmake comment - Add blank lines after setFPMode() in benchmark - Fix iters abbreviation in printf - Simplify benchmark: remove replay dependency, auto-trigger at frame 400 - Rename WWMath wrappers to Function_Name convention (578 replacements, 79 files)
… Atan2, Atanf, Atan2f
…Acos, Asinf, Acosf
74d8ae3 to
ec55507
Compare
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.
No description provided.