Skip to content

Adaptive Fps Limiter#119

Merged
SoloByte merged 18 commits intomainfrom
auto-framerate-capping
Dec 19, 2025
Merged

Adaptive Fps Limiter#119
SoloByte merged 18 commits intomainfrom
auto-framerate-capping

Conversation

@SoloByte
Copy link
Collaborator

Simple system that can be enabled for a more situational aware fps limiting. Can be used in capped and uncapped fps mode. Min and Max Framerate settings were removed from the WindowSettings. AdaptiveFpsLimiterSettings now hold Min and Max limits instead.

The fps limiter tries to set the fps limit to what the current frame time (time the current frame took) allows (with some adjustable tolerances). It will reduce the frame rate if the system cant keep up and will increase it again when there enough remaining frame time that allows a safe increase. If too many consecutive slow downs happen, raising the fps limit will be on a cooldown to not have a constantly changing framerate.

This system can be completely disabled. If it does not prove useful in the future it also can easily be removed again.

Feat: AdapativeFpsLimiter started
Refactor: GameGameloop.cs updated to use ShapeMath time conversion functions and const members.
Refactor: GameWindow Min and MaxFramerate properties removed.
Docs: GameWindow AdaptiveFpsLimiter xml summary added.
Feat: AdaptiveFpsLimiter is now set up properly using WindowSettings in GameWindow constructor.
Refactor: WindowSettings Min and MaxFramerate properties removed and AdaptiveFpsLimiter.Settings property added.
…t yet implemented)

Refactor: GameGameloop some minor clean up.
@SoloByte SoloByte added this to the 5.0 milestone Dec 18, 2025
@SoloByte SoloByte self-assigned this Dec 18, 2025
@SoloByte SoloByte requested a review from Copilot December 19, 2025 08:50
@SoloByte SoloByte review requested due to automatic review settings December 19, 2025 08:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an adaptive FPS limiter system that dynamically adjusts the target framerate based on measured performance. The system replaces the static MinFramerate and MaxFramerate properties in WindowSettings with a more sophisticated AdaptiveFpsLimiterSettings configuration.

  • Adds a new AdaptiveFpsLimiter class with configurable settings for dynamic framerate adjustment
  • Introduces time conversion utility functions and double-precision interpolation methods to ShapeMath
  • Removes fixed min/max framerate constraints from WindowSettings and GameWindow, replacing them with the adaptive limiter

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
ShapeEngine/StaticLib/ShapeMath.cs Adds time conversion constants and functions (nanoseconds/milliseconds/seconds), plus double-precision lerp and exponential decay functions
ShapeEngine/Core/Structs/WindowSettings.cs Replaces MinFramerate and MaxFramerate fields with AdaptiveFpsLimiterSettings configuration
ShapeEngine/Core/GameWindow.cs Removes min/max framerate properties and associated validation logic; integrates AdaptiveFpsLimiter instance
ShapeEngine/Core/GameDef/GameGameloop.cs Adds FrameTime property and integrates adaptive limiter updates into the game loop
ShapeEngine/Core/AdaptiveFpsLimiter.cs New file implementing the adaptive FPS limiting algorithm with configurable presets and runtime adjustment logic
Examples/Program.cs Updates example to use new AdaptiveFpsLimiterSettings instead of separate min/max framerate fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SoloByte SoloByte merged commit 6ed3b4f into main Dec 19, 2025
7 checks passed
@SoloByte SoloByte deleted the auto-framerate-capping branch December 19, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants