-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Implement accumulator pattern for precise frame rate limiting #16484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement accumulator pattern for precise frame rate limiting #16484
Conversation
This commit replaces the simple frame time threshold check with an accumulator-based approach for more accurate frame rate control. Changes include: - Remove the "+1" adjustment in maxFPS calculation that caused target FPS to drift - Add a time accumulator to track elapsed time between frames - Only render when sufficient time has accumulated - Prevent accumulator from growing too large during slow frames Fixes issue where setting maxFPS to 60 resulted in actual FPS of 48.
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16484/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16484/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16484/merge#BCU1XR#0 |
Visualization tests for WebGPU |
WebGL2 visualization test reporter: |
@deltakosh @Popov72 what do you guys think about this update? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
However, I would appreciate someone that has the context regarding the vbl sync
(value + 1
) provide a bit more explanation whether or not it is still needed here.
@deltakosh @Popov72 can we merge this? |
Thanks! I did not see your ping among the million I got :D |
This commit replaces the simple frame time threshold check with an accumulator-based approach for more accurate frame rate control. Changes include:
Fixes issue where setting maxFPS to 60 resulted in actual FPS of 48.