Browse Source

engine: fix framerate being capped to 60FPS with vsync, remove vid_displayfrequency cvar. Never sleep with vsync or timedemo, for accuracy

pull/2/head
Alibek Omarov 2 years ago
parent
commit
d13f7f06e4
  1. 2
      engine/client/vid_common.c
  2. 1
      engine/client/vid_common.h
  3. 1
      engine/common/common.h
  4. 27
      engine/common/host.c

2
engine/client/vid_common.c

@ -21,7 +21,6 @@ GNU General Public License for more details.
#include "platform/platform.h" #include "platform/platform.h"
#define WINDOW_NAME XASH_ENGINE_NAME " Window" // Half-Life #define WINDOW_NAME XASH_ENGINE_NAME " Window" // Half-Life
convar_t *vid_displayfrequency;
convar_t *vid_fullscreen; convar_t *vid_fullscreen;
convar_t *vid_mode; convar_t *vid_mode;
convar_t *vid_brightness; convar_t *vid_brightness;
@ -181,7 +180,6 @@ void VID_Init( void )
vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" ); vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" ); vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
vid_displayfrequency = Cvar_Get ( "vid_displayfrequency", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen refresh rate" );
vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" ); vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
vid_mode = Cvar_Get( "vid_mode", "0", FCVAR_RENDERINFO, "current video mode index (used just for storage)" ); vid_mode = Cvar_Get( "vid_mode", "0", FCVAR_RENDERINFO, "current video mode index (used just for storage)" );
vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" ); vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );

1
engine/client/vid_common.h

@ -31,7 +31,6 @@ extern glwstate_t glw_state;
#define VID_MIN_WIDTH 320 #define VID_MIN_WIDTH 320
extern convar_t *vid_fullscreen; extern convar_t *vid_fullscreen;
extern convar_t *vid_displayfrequency;
extern convar_t *vid_highdpi; extern convar_t *vid_highdpi;
extern convar_t *vid_rotate; extern convar_t *vid_rotate;
extern convar_t *vid_scale; extern convar_t *vid_scale;

1
engine/common/common.h

@ -159,7 +159,6 @@ extern convar_t *scr_download;
extern convar_t *cmd_scripting; extern convar_t *cmd_scripting;
extern convar_t *sv_maxclients; extern convar_t *sv_maxclients;
extern convar_t *cl_allow_levelshots; extern convar_t *cl_allow_levelshots;
extern convar_t *vid_displayfrequency;
extern convar_t host_developer; extern convar_t host_developer;
extern convar_t *host_limitlocal; extern convar_t *host_limitlocal;
extern convar_t *host_framerate; extern convar_t *host_framerate;

27
engine/common/host.c

@ -276,6 +276,13 @@ void Host_CheckSleep( void )
{ {
int sleeptime = host_sleeptime->value; int sleeptime = host_sleeptime->value;
#ifndef XASH_DEDICATED
// never sleep in timedemo for benchmarking purposes
// also don't sleep with vsync for less lag
if( CL_IsTimeDemo( ) || CVAR_TO_BOOL( gl_vsync ))
return;
#endif
if( Host_IsDedicated() ) if( Host_IsDedicated() )
{ {
// let the dedicated server some sleep // let the dedicated server some sleep
@ -597,24 +604,16 @@ double Host_CalcFPS( void )
} }
else if( Host_IsLocalGame( )) else if( Host_IsLocalGame( ))
{ {
fps = host_maxfps->value; if( !CVAR_TO_BOOL( gl_vsync ))
fps = host_maxfps->value;
} }
else else
{ {
fps = host_maxfps->value; if( !CVAR_TO_BOOL( gl_vsync ))
if( fps == 0.0 ) fps = MAX_FPS;
fps = bound( MIN_FPS, fps, MAX_FPS );
}
// probably left part of this condition is redundant :-)
if( host.type != HOST_DEDICATED && Host_IsLocalGame( ) && !CL_IsTimeDemo( ))
{
// ajdust fps for vertical synchronization
if( CVAR_TO_BOOL( gl_vsync ))
{ {
if( vid_displayfrequency->value != 0.0f ) fps = host_maxfps->value;
fps = vid_displayfrequency->value; if( fps == 0.0 ) fps = MAX_FPS;
else fps = 60.0; // default fps = bound( MIN_FPS, fps, MAX_FPS );
} }
} }
#endif #endif

Loading…
Cancel
Save