diff --git a/src/am_map.c b/src/am_map.c index d60437e8..46d63fa0 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -575,14 +575,6 @@ static void AM_clearLastMark(void) void AM_enableSmoothLines(void) { - static boolean precalc_once = true; - - if (precalc_once && map_smooth_lines) - { - V_InitFlexTranTable(); - precalc_once = false; - } - AM_drawFline = map_smooth_lines ? AM_drawFline_Smooth : AM_drawFline_Vanilla; } diff --git a/src/d_main.c b/src/d_main.c index 66b6585b..e30e75dd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -388,7 +388,7 @@ void D_Display (void) } while (!done); - I_ResetTargetRefresh(); // reset after wipe + drs_skip_frame = true; // skip DRS after wipe } // diff --git a/src/g_game.c b/src/g_game.c index c7fe65ae..0e8d8337 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -59,6 +59,7 @@ #include "m_snapshot.h" #include "m_swap.h" // [FG] LONG #include "i_input.h" +#include "i_video.h" #include "m_array.h" #define SAVEGAMESIZE 0x20000 @@ -2155,6 +2156,8 @@ static void G_DoSaveGame(void) if (name) free(name); M_SetQuickSaveSlot(savegameslot); + + drs_skip_frame = true; } static void G_DoLoadGame(void) diff --git a/src/i_video.c b/src/i_video.c index ebcfd384..98fa71ac 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -108,6 +108,8 @@ boolean screenvisible = true; boolean window_focused = true; +boolean drs_skip_frame; + void *I_GetSDLWindow(void) { return screen; @@ -249,6 +251,8 @@ static void HandleWindowEvent(SDL_WindowEvent *event) default: break; } + + drs_skip_frame = true; } // [FG] fullscreen toggle from Chocolate Doom 3.0 @@ -471,7 +475,7 @@ static void UpdateRender(void) } } -static uint64_t frametime_withoutpresent; +static uint64_t frametime_start, frametime_withoutpresent; static int targetrefresh; static void ResetResolution(int height); @@ -482,13 +486,18 @@ void I_DynamicResolution(void) static int frame_counter; static double averagepercent; - if (resolution_mode != RES_DRS || frametime_withoutpresent == 0 || - // Skip if frame time is too long (e.g. window event). - frametime_withoutpresent > 100000) + if (resolution_mode != RES_DRS || frametime_withoutpresent == 0 || menuactive) { return; } + if (drs_skip_frame) + { + frametime_start = frametime_withoutpresent = 0; + drs_skip_frame = false; + return; + } + // 1.25 milliseconds for SDL render present double target = (1.0 / targetrefresh) - 0.00125; double actual = frametime_withoutpresent / 1000000.0; @@ -498,9 +507,8 @@ void I_DynamicResolution(void) #define DRS_MIN_HEIGHT 400 #define DRS_DELTA 0.1 #define DRS_GREATER (1 + DRS_DELTA) - #define DRS_LESS (1 - DRS_DELTA) - // 50px step to make scaling artefacts less noticeable. - #define DRS_STEP (SCREENHEIGHT / 4) + #define DRS_LESS (1 - DRS_DELTA / 10.0) + #define DRS_STEP (SCREENHEIGHT / 2) int newheight = 0; int oldheight = video.height; @@ -513,7 +521,7 @@ void I_DynamicResolution(void) if (actualpercent > DRS_GREATER) { - double reduction = (actualpercent - DRS_GREATER ) * 0.2; + double reduction = (actualpercent - DRS_GREATER ) * 0.4; newheight = (int)MAX(DRS_MIN_HEIGHT, oldheight - oldheight * reduction); } else if (averagepercent < DRS_LESS && frame_counter > targetrefresh) @@ -553,8 +561,6 @@ static void CreateUpscaledTexture(boolean force); void I_FinishUpdate(void) { - static uint64_t frametime_start; - if (noblit) { return; @@ -1090,6 +1096,8 @@ static void ResetResolution(int height) I_InitDiskFlash(); I_Printf(VB_DEBUG, "ResetResolution: %dx%d", video.width, video.height); + + drs_skip_frame = true; } static void CreateUpscaledTexture(boolean force) @@ -1206,8 +1214,6 @@ static void ResetLogicalSize(void) void I_ResetTargetRefresh(void) { - frametime_withoutpresent = 0; // skip DRS one frame - if (uncapped) { targetrefresh = (fpslimit >= TICRATE) ? fpslimit : native_refresh_rate; diff --git a/src/i_video.h b/src/i_video.h index 000edc5f..ccdb3320 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -69,6 +69,8 @@ void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle void I_DynamicResolution(void); +extern boolean drs_skip_frame; + extern char *sdl_renderdriver; extern boolean use_vsync; // killough 2/8/98: controls whether vsync is called diff --git a/src/r_main.c b/src/r_main.c index 2ae3a1a1..def77651 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -29,7 +29,7 @@ #include "r_voxel.h" #include "i_video.h" #include "v_video.h" -#include "am_map.h" +#include "v_flextran.h" #include "st_stuff.h" // killough: viewangleoffset is a legacy from the pre-v1.2 days, when Doom @@ -557,6 +557,7 @@ void R_Init (void) R_InitLightTables(); R_InitSkyMap(); R_InitTranslationTables(); + V_InitFlexTranTable(); // [FG] spectre drawing mode R_SetFuzzColumnMode();