#2882 closed defect (fixed)
[PATCH] 200 FPS in main menu
Reported by: | Salesome | Owned by: | Itms |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | Core engine | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
When starting the game, the FPS counter shows around 200 FPS in the main menu (see attached screenshot).
I think, there should be a hard-coded limit of 60 or 30 FPS.
Attachments (4)
Change History (19)
by , 10 years ago
Attachment: | screenshot.jpg added |
---|
comment:1 by , 10 years ago
You can enable vsync in game options for that, it will also save power (also fans should run lower, etc.) and avoid tearing. This should eventually be enabled by default.
by , 9 years ago
Attachment: | t2882_limit_fps_wip_v1.patch added |
---|
Limits the FPS to 60 max. (showcase / wip)
comment:2 by , 9 years ago
Keywords: | patch review added |
---|---|
Milestone: | Backlog → Alpha 19 |
Priority: | Nice to Have → Should Have |
This ticket should definitely be fixed as every instance of 0ad draws as many frames as possible and consequently uses 100% cpu of a single core, no matter what.
Open questions:
-Where to save the constant (1/maxFPS)? -Should some sort of vsync be used? -SDL_WaitEvent should not be used?
// don't use SDL_WaitEvent: don't want the main loop to freeze until app focus is restored
-Limit the FPS only in the main menu, or ingame too?
comment:3 by , 9 years ago
Enabling vsync by default would be better, other than limiting fps it will also avoid tearing.
comment:4 by , 9 years ago
I remember from old times that I had to disable vsync to make the games run with acceptable performance. Some research suggests that vsync indeed can have negative performance impact causing the performance to drop by 50%:
From https://www.reddit.com/r/ftlgame/comments/15mxmt/does_vsync_affect_performance/
Most monitors refresh at 60 Hz (60 fps), so Vsync will limit your refresh rate options to things that divide evenly into that: 60, 30, 15, 7.5, etc. If you're currently getting something just under 60 fps, Vsync will cut it all the way to 30, which looks bad on paper but it's exactly what it's intended to do.
From http://www.tweakguides.com/Graphics_9.html
There is however a more fundamental problem with enabling VSync, and that is it can significantly reduce your overall framerate, often dropping your FPS to exactly 50% of the refresh rate. This is a difficult concept to explain, but it just has to do with timing. When VSync is enabled, your graphics card becomes a slave to your monitor. If at any time your FPS falls just below your refresh rate, each frame starts taking your graphics card longer to draw than the time it takes for your monitor to refresh itself. So every 2nd refresh, your graphics card just misses completing a new whole frame in time. This means that both its primary and secondary frame buffers are filled, it has nowhere to put any new information, so it has to sit idle and wait for the next refresh to come around before it can unload its recently completed frame, and start work on a new one in the newly cleared secondary buffer. This results in exactly half the framerate of the refresh rate whenever your FPS falls below the refresh rate.
comment:5 by , 9 years ago
Some extracts from the IRC logs:
April 8th 2015: (23:09:44) leper: (yes we should cap that at some point, but you can also just enable vsync)
March 16th 2015: (21:59:57) Arthur_D: in SuperTuxKart, we limit FPS in menus and cutscenes to about 30-33 FPS, also if vsync is off. Makes it easier for laptops too (22:00:47) Philip`: Arthur_D: Yeah, that seems better than forcing people to enable vsync (22:01:06) Philip`: since vsync hurts performance when you're actually playing (22:02:12) Arthur_D: some newer screens are 120 or more hz though, which is still overkill for menus ;)
comment:6 by , 9 years ago
Just don't cap FPS in the main game in a hardcoded way, or gamers will commit suicide. Might be okay for menus though. Maybe make that a config option? One value for menus, default 30 or 60, one value for game, default unlimited?
by , 9 years ago
Attachment: | t2882_limit_fps_v2.patch added |
---|
Adds a binary config option to limit the FPS to 50 if not ingame. Checking that config value each frame is no problem, since ConfigDB caches those values. vsync is ignored. If a user has 60 Hz, he/she will end up with 30 fps if I understand the description above correctly.
follow-up: 8 comment:7 by , 9 years ago
@Elexis, are you sure the string "Persist Match Settings" instead of "Persist match settings" should be included for this ticket ?
comment:8 by , 9 years ago
Replying to stanislas69:
@Elexis, are you sure the string "Persist Match Settings" instead of "Persist match settings" should be included for this ticket ?
I thought it could be fixed as the other options are capitalized as well: https://i.imgur.com/aWIvzfD.jpg
comment:10 by , 9 years ago
Summary: | 200 FPS in main menu → [PATCH] 200 FPS in main menu |
---|
by , 9 years ago
Attachment: | t2882_limit_fps_v3.patch added |
---|
Use the prefix "gui.menu" to the setting name and adds an entry to default.cfg
.
comment:12 by , 9 years ago
Keywords: | review removed |
---|
Thanks for the patch.
I changed the config option to limitfps
for consistency and added a check for avoiding passing negative values to SDL_Delay
. I also made the comment in the main loop larger.
comment:14 by , 7 years ago
Description: | modified (diff) |
---|
Hi, I noticed when moving the sliders a numeric indicator was appearing in a tooltip, but disappear when it reachs the maximum value. Also the number in the tooltip has too many decimal digits, I think 1 is just enough.
comment:15 by , 7 years ago
Both in the making :-)
https://code.wildfiregames.com/rP19507#inline-299 https://code.wildfiregames.com/D406
see FPS counter