From 19c2c690d33c2ccef6835a237faee11d131fdac6 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Tue, 25 Jun 2019 18:34:56 +0000 Subject: [PATCH] Fix latency issue introduced by G_FPSLimit() handling of videoNextPage() that was causing frames to be delayed presentation until after the next frame is prepared. videoNextPage() is now called immediately after preparing the frame for drawing, outside of G_FPSLimit() but on the condition that its return value is true. git-svn-id: https://svn.eduke32.com/eduke32@7730 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/demo.cpp | 3 +++ source/duke3d/src/game.cpp | 11 +++-------- source/duke3d/src/gameexec.cpp | 1 + source/duke3d/src/network.cpp | 1 + source/duke3d/src/screens.cpp | 7 +++++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index 3784484bd..6e2813fda 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -899,6 +899,7 @@ nextdemo_nomenu: if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) { Demo_FinishProfile(); + videoNextPage(); goto RECHECK; } @@ -957,6 +958,8 @@ nextdemo_nomenu: if (ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, BETAVERSION, 0, 0, 2+8+16+128); } + + videoNextPage(); } // NOTE: We must prevent handleevents() and Net_GetPackets() from diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 61e348b88..b1c9aabad 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6138,13 +6138,7 @@ void G_MaybeAllocPlayer(int32_t pnum) int G_FPSLimit(void) { static auto nextPageTicks = (double)timerGetTicksU64(); - static unsigned frameWaiting = 0; - - if (frameWaiting) - { - frameWaiting--; - videoNextPage(); - } + int frameWaiting = 0; auto const frameTicks = (double)timerGetTicksU64(); @@ -6154,7 +6148,7 @@ int G_FPSLimit(void) nextPageTicks = frameTicks; nextPageTicks += g_frameDelay; - frameWaiting++; + ++frameWaiting; } return frameWaiting; @@ -6819,6 +6813,7 @@ MAIN_LOOP_RESTART: if (videoGetRenderMode() >= REND_POLYMOST) G_DrawBackground(); G_DisplayRest(smoothRatio); + videoNextPage(); if (gameUpdate) { diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 18620b931..e697175c3 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1253,6 +1253,7 @@ void Screen_Play(void) if (VM_OnEventWithReturn(EVENT_SCREEN, g_player[screenpeek].ps->i, screenpeek, I_CheckAllInput())) running = false; + videoNextPage(); I_ClearAllInput(); } while (running); } diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index a5cc30b21..46025cc01 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -4709,6 +4709,7 @@ void Net_WaitForServer(void) { display_betascreen(); gametext_center_shade(170, "Waiting for server", 14); + videoNextPage(); } // XXX: this looks like something that should be rate limited... diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 794b69229..2537e4b3f 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -1572,6 +1572,7 @@ void gameDisplay3DRScreen() P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0); g_restorePalette = 0; } + videoNextPage(); } } @@ -1676,6 +1677,9 @@ void gameDisplayTitleScreen(void) P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0); g_restorePalette = 0; } + + videoNextPage(); + #ifdef LUNATIC if (g_elEventError) break; @@ -1882,6 +1886,7 @@ static void G_BonusCutscenes(void) rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); } } + videoNextPage(); } G_HandleAsync(); @@ -2306,6 +2311,7 @@ void G_BonusScreen(int32_t bonusonly) { videoClearScreen(0); G_DisplayMPResultsScreen(); + videoNextPage(); } if (I_CheckAllInput()) @@ -2578,6 +2584,7 @@ void G_BonusScreen(int32_t bonusonly) break; VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek); + videoNextPage(); } } while (1); }