diff --git a/src/common/rendering/hwrenderer/data/hw_clock.cpp b/src/common/rendering/hwrenderer/data/hw_clock.cpp index a9209d236..ec2847944 100644 --- a/src/common/rendering/hwrenderer/data/hw_clock.cpp +++ b/src/common/rendering/hwrenderer/data/hw_clock.cpp @@ -153,7 +153,6 @@ ADD_STAT(lightstats) static int printstats; static bool switchfps; static uint64_t waitstart; -extern uint64_t LastCount; EXTERN_CVAR(Bool, vid_fps) void CheckBench() diff --git a/src/common/statusbar/base_sbar.cpp b/src/common/statusbar/base_sbar.cpp index af48e75fa..68fe29230 100644 --- a/src/common/statusbar/base_sbar.cpp +++ b/src/common/statusbar/base_sbar.cpp @@ -59,7 +59,6 @@ CVAR(Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE); CVAR(Int, crosshairhealth, 2, CVAR_ARCHIVE); CVARD(Float, crosshairscale, 0.5, CVAR_ARCHIVE, "changes the size of the crosshair"); CVAR(Bool, crosshairgrow, false, CVAR_ARCHIVE); -EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Float, hud_scalefactor) EXTERN_CVAR(Bool, hud_aspectscale) @@ -568,9 +567,6 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag case DI_SCREEN_BOTTOM: orgy = twod->GetHeight(); break; } - // move stuff in the top right corner a bit down if the fps counter is on. - if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10; - DVector2 Scale = GetHUDScale(); x *= Scale.X; @@ -662,9 +658,6 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag case DI_SCREEN_BOTTOM: orgy = twod->GetHeight(); break; } - // move stuff in the top right corner a bit down if the fps counter is on. - if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10; - x *= Scale.X; y *= Scale.Y; scaleX *= Scale.X; @@ -742,9 +735,6 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d case DI_SCREEN_VCENTER: orgy = twod->GetHeight() / 2; break; case DI_SCREEN_BOTTOM: orgy = twod->GetHeight(); break; } - - // move stuff in the top right corner a bit down if the fps counter is on. - if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10; } else { @@ -907,9 +897,6 @@ void DStatusBarCore::TransformRect(double& x, double& y, double& w, double& h, i case DI_SCREEN_BOTTOM: orgy = twod->GetHeight(); break; } - // move stuff in the top right corner a bit down if the fps counter is on. - if ((flags & (DI_SCREEN_HMASK | DI_SCREEN_VMASK)) == DI_SCREEN_RIGHT_TOP && vid_fps) y += 10; - DVector2 Scale = GetHUDScale(); x *= Scale.X; diff --git a/src/d_main.cpp b/src/d_main.cpp index 3615523b4..87830ba90 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -293,13 +293,14 @@ CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) } // Controlled by startup dialog -CVAR (Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -CVAR (Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -CVAR (Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -CVAR (Bool, autoloadwidescreen, true, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) -CVAR (Bool, r_debug_disable_vis_filter, false, 0) +CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR(Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR(Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR(Bool, autoloadwidescreen, true, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +CVAR(Bool, r_debug_disable_vis_filter, false, 0) CVAR(Bool, vid_fps, false, 0) CVAR(Int, vid_showpalette, 0, 0) + CUSTOM_CVAR (Bool, i_discordrpc, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { I_UpdateWindowTitle(); @@ -765,7 +766,34 @@ static void DrawPaletteTester(int paletteno) // Draws the fps counter, dot ticker, and palette debug. // //========================================================================== -uint64_t LastCount; +uint64_t LastFPS, LastMSCount; + +void CalcFps() +{ + static uint64_t LastMS = 0, LastSec = 0, FrameCount = 0, LastTic = 0; + + uint64_t ms = screen->FrameTime; + uint64_t howlong = ms - LastMS; + if ((signed)howlong > 0) // do this only once per frame. + { + uint32_t thisSec = (uint32_t)(ms / 1000); + if (LastSec < thisSec) + { + LastFPS = FrameCount / (thisSec - LastSec); + LastSec = thisSec; + FrameCount = 0; + } + FrameCount++; + LastMS = ms; + LastMSCount = howlong; + } +} + +ADD_STAT(fps) +{ + CalcFps(); + return FStringf("%2llu ms (%3llu fps)", (unsigned long long)LastMSCount , (unsigned long long)LastFPS); +} static void DrawRateStuff() { @@ -774,34 +802,19 @@ static void DrawRateStuff() // Draws frame time and cumulative fps if (vid_fps) { - uint64_t ms = screen->FrameTime; - uint64_t howlong = ms - LastMS; - if ((signed)howlong >= 0) - { - char fpsbuff[40]; - int chars; - int rate_x; + CalcFps(); + char fpsbuff[40]; + int chars; + int rate_x; + int textScale = active_con_scale(twod); - int textScale = active_con_scale(twod); - - chars = mysnprintf(fpsbuff, countof(fpsbuff), "%2llu ms (%3llu fps)", (unsigned long long)howlong, (unsigned long long)LastCount); - rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); - ClearRect(twod, rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, GPalette.BlackIndex, 0); - DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char*)&fpsbuff[0], - DTA_VirtualWidth, screen->GetWidth() / textScale, - DTA_VirtualHeight, screen->GetHeight() / textScale, - DTA_KeepRatio, true, TAG_DONE); - - uint32_t thisSec = (uint32_t)(ms / 1000); - if (LastSec < thisSec) - { - LastCount = FrameCount / (thisSec - LastSec); - LastSec = thisSec; - FrameCount = 0; - } - FrameCount++; - } - LastMS = ms; + chars = mysnprintf(fpsbuff, countof(fpsbuff), "%2llu ms (%3llu fps)", (unsigned long long)LastMSCount, (unsigned long long)LastFPS); + rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]); + ClearRect(twod, rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, GPalette.BlackIndex, 0); + DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char*)&fpsbuff[0], + DTA_VirtualWidth, screen->GetWidth() / textScale, + DTA_VirtualHeight, screen->GetHeight() / textScale, + DTA_KeepRatio, true, TAG_DONE); } int Height = screen->GetHeight(); @@ -2740,7 +2753,7 @@ FString System_GetLocationDescription() auto& vp = r_viewpoint; auto Level = vp.ViewLevel; return Level == nullptr ? FString() : FStringf("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n%llu fps\n\n", - Level->MapName.GetChars(), Level->LevelName.GetChars(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw.Degrees, vp.Angles.Pitch.Degrees, (unsigned long long)LastCount); + Level->MapName.GetChars(), Level->LevelName.GetChars(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw.Degrees, vp.Angles.Pitch.Degrees, (unsigned long long)LastFPS); } diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index d32b94bc2..6d6b8b7b3 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -66,7 +66,6 @@ enum EXTERN_CVAR(Int, fraglimit) EXTERN_CVAR(Int, screenblocks) -EXTERN_CVAR(Bool, vid_fps) class DSBarInfo; static double nulclip[] = { 0,0,0,0 }; @@ -1287,8 +1286,6 @@ public: w = (forceWidth < 0 ? texture->GetDisplayWidth() : forceWidth); h = (forceHeight < 0 ? texture->GetDisplayHeight() : forceHeight); - if(vid_fps && rx < 0 && ry >= 0) - ry += 10; rx *= Scale.X; ry *= Scale.Y; @@ -1432,8 +1429,6 @@ public: } else { - if(vid_fps && ax < 0 && ay >= 0) - ry += 10; bool xright = rx < 0; bool ybot = ry < 0; diff --git a/src/rendering/swrenderer/scene/r_scene.cpp b/src/rendering/swrenderer/scene/r_scene.cpp index bd864c1bb..d5d6a9d5e 100644 --- a/src/rendering/swrenderer/scene/r_scene.cpp +++ b/src/rendering/swrenderer/scene/r_scene.cpp @@ -421,7 +421,7 @@ namespace swrenderer ///////////////////////////////////////////////////////////////////////// - ADD_STAT(fps) + ADD_STAT(swfps) { FString out; out.Format("frame=%04.1f ms walls=%04.1f ms planes=%04.1f ms masked=%04.1f ms", @@ -432,7 +432,7 @@ namespace swrenderer static double f_acc, w_acc, p_acc, m_acc; static int acc_c; - ADD_STAT(fps_accumulated) + ADD_STAT(swfps_accumulated) { f_acc += FrameCycles.TimeMS(); w_acc += WallCycles.TimeMS();