You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor framerate limiter to reduce CPU consumption (#4385)
* Frame limiter refactor: queue-only ApplyFrameRateLimit, centralized pacing in ApplyQueuedFrameRateLimit
TL;DR: Main menu runs with arbitrary FPS limit now
- EnsureFrameRateLimitApplied no longer calls ApplyFrameRateLimit() from Present path
to avoid skewed pacing; now only queues the target rate for the timer hook.
- ApplyFrameRateLimit simplified to just queue the requested rate.
- ApplyQueuedFrameRateLimit is now the single enforcement point:
uses high-precision timing, adaptive sleep/yield calibration, and minimal spin
to achieve stable pacing without wasting CPU.
- Added detailed comments clarifying responsibilities and caveats
(e.g. Main Menu not using timer hook).
* refactor(core): implement high-precision FPS limiter
Replace scattered frame rate limiting logic with centralized `FPSLimiter` class.
**Key improvements:**
- High-precision timing using `RDTSC`, `QueryPerformanceFrequency`, and waitable timers
- Unified FPS limit handling from server, client scripts, user settings, and VSync
- Dynamic CEF browser frame rate synchronization
- Consistent frame pacing through `CModManager` pulse integration
**Changes:**
- Add `FPSLimiter` class with centralized frame limiting logic
- Integrate limiter into `CCore`, replacing old methods and variables
- Refactor `CCommands` to handle `fps_limit` and `vsync` cvars
- Update all APIs, Lua functions, and network packets to use `FPSLimiterInterface`
* Remove bug introduced by validating and loading flag in LoadDefaults
* Use `std::numeric_limits<uint32_t>::max()`
* `const noexcept` on `GetEnforcer` and `GetFPSTarget`
* No lambda for `CPacketHandler` and update referenced code
* `std::unique_ptr` instead of raw pointer
* No MTA versioning in comments for new files
* No SString, updated std:: members, logging removed, EnumToString, static_cast, and more.
- Cleanup CClientVariables::ValidateValues
- Removed // Easter egg! comment
* Reverted side-refactors and issued #4427
* CClientGame cleanup (Check #4428) and formatting
Given that I needed to touch I applied formatting
* Use stringstream for cleanliness
* More std:: members
* Use stringstream and reinterpret_cast function ptr typedef
* Tweaks
* Add V-Sync checkbox to settings
* Refactored the refactor to match guidelines and one of the last cleanups of code
* Wait for network module before updating webcore fps
---------
Co-authored-by: Marek Kulik <noreply@bug32.com>
Co-authored-by: Dutchman101 <12105539+Dutchman101@users.noreply.github.com>
0 commit comments