Port old inaccurate fps sample as toggle
For Jon-sama 🥹
This commit is contained in:
parent
6143d8088b
commit
82a6edce5d
3 changed files with 44 additions and 4 deletions
|
|
@ -1627,6 +1627,7 @@ void D_SRB2Main(void)
|
|||
if (!dedicated)
|
||||
{
|
||||
CV_RegisterVar(&cv_ticrate);
|
||||
CV_RegisterVar(&cv_accuratefps);
|
||||
CV_RegisterVar(&cv_constextsize);
|
||||
}
|
||||
|
||||
|
|
|
|||
46
src/screen.c
46
src/screen.c
|
|
@ -87,6 +87,9 @@ static void SCR_ChangeFullscreen(void);
|
|||
static CV_PossibleValue_t fullscreen_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Borderless Window"}, {0, NULL}};
|
||||
consvar_t cv_fullscreen = CVAR_INIT ("fullscreen", "Yes", CV_SAVE|CV_CALL, fullscreen_cons_t, SCR_ChangeFullscreen);
|
||||
|
||||
static CV_PossibleValue_t accuratefps_cons_t[] = {{0, "Inaccurate"}, {1, "Accurate"}, {0, NULL}};
|
||||
consvar_t cv_accuratefps = CVAR_INIT ("fpssampling", "Accurate", CV_SAVE, accuratefps_cons_t, NULL);
|
||||
|
||||
// =========================================================================
|
||||
// SCREEN VARIABLES
|
||||
// =========================================================================
|
||||
|
|
@ -526,6 +529,8 @@ double averageFPS = 0.0f;
|
|||
|
||||
static double total_frame_time = 0.0;
|
||||
static int frame_index;
|
||||
|
||||
static double fps_samples[NUM_FPS_SAMPLES];
|
||||
#endif
|
||||
|
||||
static boolean fps_init = false;
|
||||
|
|
@ -549,11 +554,44 @@ void SCR_CalculateFPS(void)
|
|||
|
||||
#ifdef USE_FPS_SAMPLES
|
||||
total_frame_time += frameElapsed;
|
||||
if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME)
|
||||
|
||||
if (cv_accuratefps.value)
|
||||
{
|
||||
averageFPS = 1.0 / (total_frame_time / frame_index);
|
||||
total_frame_time = 0.0;
|
||||
frame_index = 0;
|
||||
if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
averageFPS = 1.0 / (total_frame_time / frame_index);
|
||||
total_frame_time = 0.0;
|
||||
frame_index = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
static int sampleIndex = 0;
|
||||
|
||||
fps_samples[sampleIndex] = frameElapsed;
|
||||
|
||||
sampleIndex++;
|
||||
if (sampleIndex >= NUM_FPS_SAMPLES)
|
||||
sampleIndex = 0;
|
||||
|
||||
averageFPS = 0.0;
|
||||
for (int i = 0; i < NUM_FPS_SAMPLES; i++)
|
||||
{
|
||||
averageFPS += fps_samples[i];
|
||||
}
|
||||
|
||||
if (averageFPS > 0.0)
|
||||
{
|
||||
averageFPS = 1.0 / (averageFPS / NUM_FPS_SAMPLES);
|
||||
}
|
||||
}
|
||||
|
||||
while (total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
total_frame_time -= MAX_FRAME_TIME;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Direct, unsampled counter.
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ extern UINT8 *scr_borderpatch; // patch used to fill the view borders
|
|||
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_renderhitbox, cv_fullscreen;
|
||||
extern consvar_t cv_vhseffect, cv_shittyscreen, cv_votebgscaling;
|
||||
extern consvar_t cv_parallelsoftware;
|
||||
extern consvar_t cv_accuratefps;
|
||||
|
||||
// wait for page flipping to end or not
|
||||
extern consvar_t cv_vidwait;
|
||||
|
|
|
|||
Loading…
Reference in a new issue