Conversation
|
I think .0005 is actually getting converted to a zero ms sleep (.0005 * 1000 gets passed to I'm a little unsure about the logic for the affinity, but changing the sleep to .001 is a welcome change that fixes the main problem. LÖVE 12 supports high resolution sleep, which should also fix the issue. |
|
The affinity is a concept i came up with after testing the frametime graph using MSI Afterburner, your code gives a very consistant framerate, however since it gets truncated to 0 it's due to the while loop blocking the program until the condition isn't met. It's a range between 0.5 and 0.85, and it depends on your target framerate, the while loop still blocks the program, but this time it calls It adjusts how likely |
Running a project rendering a rectangle and a simple gradient shader at 60fps, it was taking up 14-17% of my CPU.
Added a small check so it sleeps only when necessary, at a reasonable stability.
CPU usage is now 2-4%.
Compared to an empty project at the same fps and no libraries, the difference is just 1%.
I did run it on Linux, 1-3% usage vs 5% originally.
An adaptive affinity was added to compensate for high fps. Lower values produce more consistent frametimes at the cost of higher CPU usage.
The affinity formula is simplified from this equation:
( 1 - (tick.framerate - 60) / (240-60) ) * 0.35 + 0.5Tested in LÖVE 11.5