working DRS in capped mode, remove newsync uncapped hack (#1341)

This commit is contained in:
Roman Fomin 2023-12-18 16:06:43 +07:00 committed by GitHub
parent ba70ba460c
commit 80145d6e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 41 deletions

View File

@ -755,20 +755,7 @@ void TryRunTics (void)
if (new_sync)
{
if (uncapped)
{
// decide how many tics to run
if (realtics < availabletics-1)
counts = realtics+1;
else if (realtics < availabletics)
counts = realtics;
else
counts = availabletics;
}
else
{
counts = availabletics;
}
// [AM] If we've uncapped the framerate and there are no tics
// to run, return early instead of waiting around.

View File

@ -89,7 +89,7 @@ static int actualheight;
static int native_width;
static int native_height;
static int native_height_adjusted;
static int refresh_rate;
static int native_refresh_rate;
static boolean need_resize;
@ -477,6 +477,7 @@ static void UpdateRender(void)
}
static uint64_t frametime_withoutpresent;
static int targetrefresh;
static void ResetResolution(int height);
static void ResetLogicalSize(void);
@ -495,7 +496,7 @@ static void DynamicResolution(void)
}
// 1.25 milliseconds for SDL render present
double target = (1.0 / refresh_rate) - 0.00125;
double target = (1.0 / targetrefresh) - 0.00125;
double actual = frametime_withoutpresent / 1000000.0;
double actualpercent = actual / target;
@ -609,22 +610,19 @@ void I_FinishUpdate(void)
need_resize = false;
}
if (uncapped)
if (uncapped && fpslimit >= TICRATE)
{
if (fpslimit >= TICRATE)
{
uint64_t target_time = 1000000ull / fpslimit;
static uint64_t start_time;
uint64_t target_time = 1000000ull / targetrefresh;
while (1)
while (true)
{
uint64_t current_time = I_GetTimeUS();
uint64_t elapsed_time = current_time - start_time;
uint64_t elapsed_time = current_time - frametime_start;
uint64_t remaining_time = 0;
if (elapsed_time >= target_time)
{
start_time = current_time;
frametime_start = current_time;
break;
}
@ -634,9 +632,10 @@ void I_FinishUpdate(void)
I_Sleep((remaining_time - 1000) / 1000);
}
}
}
else
{
frametime_start = I_GetTimeUS();
}
}
//
@ -1149,6 +1148,18 @@ static void ResetLogicalSize(void)
}
}
void I_ResetTargetRefresh(void)
{
if (uncapped)
{
targetrefresh = (fpslimit >= TICRATE) ? fpslimit : native_refresh_rate;
}
else
{
targetrefresh = TICRATE;
}
}
//
// killough 11/98: New routine, for setting hires and page flipping
//
@ -1161,6 +1172,7 @@ static void I_InitVideoParms(void)
resolution_mode = default_resolution_mode;
uncapped = default_uncapped;
grabmouse = default_grabmouse;
I_ResetTargetRefresh();
//!
// @category video
@ -1359,7 +1371,7 @@ static void CreateSurfaces(void)
native_width = mode.w;
native_height = mode.h;
refresh_rate = mode.refresh_rate;
native_refresh_rate = mode.refresh_rate;
w = native_width;
h = use_aspect ? (int)(native_height / 1.2) : native_height;

View File

@ -62,6 +62,7 @@ void I_FinishUpdate (void);
void I_ReadScreen (byte* scr);
void I_ResetScreen(void); // killough 10/98
void I_ResetTargetRefresh(void);
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle
extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called

View File

@ -3773,9 +3773,10 @@ static void M_SetMidiPlayer(void)
S_RestartMusic();
}
static void M_EnableDisableFPSLimit(void)
static void M_ToggleUncapped(void)
{
DISABLE_ITEM(!uncapped, gen_settings1[gen1_fpslimit]);
I_ResetTargetRefresh();
}
static void M_ToggleFullScreen(void)
@ -3792,6 +3793,7 @@ static void M_CoerceFPSLimit(void)
{
if (fpslimit < TICRATE)
fpslimit = 0;
I_ResetTargetRefresh();
}
static void M_ResetScreen(void)
@ -3820,7 +3822,7 @@ setup_menu_t gen_settings1[] = { // General Settings screen1
{"", S_SKIP, m_null, M_X, M_Y + gen1_gap2*M_SPC},
{"Uncapped Frame Rate", S_YESNO, m_null, M_X, M_Y+ gen1_uncapped*M_SPC,
{"uncapped"}, 0, M_EnableDisableFPSLimit},
{"uncapped"}, 0, M_ToggleUncapped},
{"Frame Rate Limit", S_NUM, m_null, M_X,
M_Y + gen1_fpslimit*M_SPC, {"fpslimit"}, 0, M_CoerceFPSLimit},
@ -6864,7 +6866,7 @@ void M_ResetSetupMenu(void)
void M_ResetSetupMenuVideo(void)
{
M_EnableDisableFPSLimit();
M_ToggleUncapped();
}
//