mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 01:10:51 +00:00
Improve frame limiter logic
git-svn-id: https://svn.eduke32.com/eduke32@7935 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0a5cdea62a
commit
564a68f1a7
1 changed files with 13 additions and 10 deletions
|
@ -6323,24 +6323,27 @@ void G_MaybeAllocPlayer(int32_t pnum)
|
||||||
|
|
||||||
int G_FPSLimit(void)
|
int G_FPSLimit(void)
|
||||||
{
|
{
|
||||||
|
if (!r_maxfps)
|
||||||
|
return 1;
|
||||||
|
|
||||||
static double nextPageDelay = g_frameDelay;
|
static double nextPageDelay = g_frameDelay;
|
||||||
static uint64_t lastFrameTicks = timerGetTicksU64() - (uint64_t) g_frameDelay;
|
uint64_t const delay = llrint(nextPageDelay);
|
||||||
int frameWaiting = 0;
|
|
||||||
|
|
||||||
uint64_t const frameTicks = timerGetTicksU64();
|
uint64_t const frameTicks = timerGetTicksU64();
|
||||||
|
uint64_t const frameDelay = (uint64_t)llrint(g_frameDelay);
|
||||||
|
|
||||||
|
static uint64_t lastFrameTicks = frameTicks - frameDelay;
|
||||||
uint64_t elapsedTime = frameTicks-lastFrameTicks;
|
uint64_t elapsedTime = frameTicks-lastFrameTicks;
|
||||||
|
|
||||||
if (!r_maxfps || elapsedTime >= (uint64_t) nextPageDelay)
|
int frameWaiting = 0;
|
||||||
{
|
|
||||||
if (elapsedTime >= (uint64_t) (nextPageDelay + g_frameDelay))
|
if (elapsedTime >= delay)
|
||||||
{
|
{
|
||||||
//If we missed a frame, reset any cumulated remainder from rendering frames early
|
//If we missed a frame, reset any cumulated remainder from rendering frames early
|
||||||
|
if (elapsedTime > frameDelay)
|
||||||
nextPageDelay = g_frameDelay;
|
nextPageDelay = g_frameDelay;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
nextPageDelay += double(frameDelay-elapsedTime);
|
||||||
nextPageDelay += g_frameDelay - elapsedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastFrameTicks = frameTicks;
|
lastFrameTicks = frameTicks;
|
||||||
++frameWaiting;
|
++frameWaiting;
|
||||||
|
|
Loading…
Reference in a new issue