Browse Source

engine: move ref cvars to static allocation

pull/2/head
Alibek Omarov 2 years ago
parent
commit
5d7d5319fd
  1. 8
      engine/client/cl_main.c
  2. 6
      engine/client/cl_parse.c
  3. 6
      engine/client/cl_qparse.c
  4. 6
      engine/client/cl_scrn.c
  5. 4
      engine/client/cl_view.c
  6. 4
      engine/client/client.h
  7. 4
      engine/client/keys.c
  8. 36
      engine/client/ref_common.c
  9. 6
      engine/client/ref_common.h
  10. 2
      engine/client/vid_common.h
  11. 2
      engine/common/common.h
  12. 6
      engine/common/host.c
  13. 6
      engine/platform/linux/vid_fbdev.c
  14. 14
      engine/platform/sdl/vid_sdl.c
  15. 4
      engine/ref_api.h
  16. 10
      ref/gl/gl_backend.c
  17. 1
      ref/gl/gl_local.h
  18. 2
      ref/gl/gl_opengl.c
  19. 1
      ref/soft/r_local.h

8
engine/client/cl_main.c

@ -480,7 +480,7 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd ) @@ -480,7 +480,7 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
int changed;
int pressed, released;
if( !gl_showtextures->value || CL_IsDevOverviewMode( ))
if( !r_showtextures.value || CL_IsDevOverviewMode( ))
return false;
changed = (oldbuttons ^ cmd->buttons);
@ -488,9 +488,9 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd ) @@ -488,9 +488,9 @@ qboolean CL_ProcessShowTexturesCmds( usercmd_t *cmd )
released = changed & (~cmd->buttons);
if( released & ( IN_RIGHT|IN_MOVERIGHT ))
Cvar_SetValue( "r_showtextures", gl_showtextures->value + 1 );
Cvar_SetValue( "r_showtextures", r_showtextures.value + 1 );
if( released & ( IN_LEFT|IN_MOVELEFT ))
Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
Cvar_SetValue( "r_showtextures", Q_max( 1, r_showtextures.value - 1 ));
oldbuttons = cmd->buttons;
return true;
@ -511,7 +511,7 @@ qboolean CL_ProcessOverviewCmds( usercmd_t *cmd ) @@ -511,7 +511,7 @@ qboolean CL_ProcessOverviewCmds( usercmd_t *cmd )
float step = (2.0f / size) * host.realframetime;
float step2 = step * 100.0f * (2.0f / ov->flZoom);
if( !CL_IsDevOverviewMode() || gl_showtextures->value )
if( !CL_IsDevOverviewMode() || r_showtextures.value )
return false;
if( ov->flZoom < 0.0f ) sign = -1;

6
engine/client/cl_parse.c

@ -931,10 +931,10 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) @@ -931,10 +931,10 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
// loading user settings
CSCR_LoadDefaultCVars( "user.scr" );
if( r_decals->value > mp_decals.value )
Cvar_SetValue( "r_decals", mp_decals.value );
if( r_decals.value > mp_decals.value )
Cvar_DirectSet( &r_decals, mp_decals.string );
}
else Cvar_Reset( "r_decals" );
else Cvar_DirectSet( &r_decals, NULL );
// set the background state
if( cls.demoplayback && ( cls.demonum != -1 ))

6
engine/client/cl_qparse.c

@ -232,10 +232,10 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) @@ -232,10 +232,10 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
// loading user settings
CSCR_LoadDefaultCVars( "user.scr" );
if( r_decals->value > mp_decals.value )
Cvar_SetValue( "r_decals", mp_decals.value );
if( r_decals.value > mp_decals.value )
Cvar_DirectSet( &r_decals, mp_decals.string );
}
else Cvar_Reset( "r_decals" );
else Cvar_DirectSet( &r_decals, NULL );
if( cl.background ) // tell the game parts about background state
Cvar_FullSet( "cl_background", "1", FCVAR_READ_ONLY );

6
engine/client/cl_scrn.c

@ -366,7 +366,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background ) @@ -366,7 +366,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
cl.video_prepped = false;
if( !Host_IsDedicated() )
oldclear = gl_clear->value;
oldclear = gl_clear.value;
if( CL_IsInMenu( ) && !cls.changedemo && !is_background )
{
@ -382,7 +382,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background ) @@ -382,7 +382,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
return;
if( !Host_IsDedicated() )
gl_clear->value = 0.0f;
gl_clear.value = 0.0f;
if( is_background ) IN_MouseSavePos( );
cls.draw_changelevel = !is_background;
@ -391,7 +391,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background ) @@ -391,7 +391,7 @@ void SCR_BeginLoadingPlaque( qboolean is_background )
cl.background = is_background; // set right state before svc_serverdata is came
if( !Host_IsDedicated() )
gl_clear->value = oldclear;
gl_clear.value = oldclear;
// SNDDMA_LockSound();
}

4
engine/client/cl_view.c

@ -311,7 +311,7 @@ void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp ) @@ -311,7 +311,7 @@ void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
rvp->fov_y = V_CalcFov( &rvp->fov_x, clgame.viewport[2], clgame.viewport[3] );
// adjust FOV for widescreen
if( refState.wideScreen && r_adjust_fov->value )
if( refState.wideScreen && r_adjust_fov.value )
V_AdjustFov( &rvp->fov_x, &rvp->fov_y, clgame.viewport[2], clgame.viewport[3], false );
rvp->flags = 0;
@ -472,7 +472,7 @@ void R_ShowTree( void ) @@ -472,7 +472,7 @@ void R_ShowTree( void )
float y = NODE_INTERVAL_Y(1.0f);
mleaf_t *viewleaf;
if( !cl.worldmodel || !CVAR_TO_BOOL( r_showtree ))
if( !cl.worldmodel || !r_showtree.value )
return;
world.recursion_level = 0;

4
engine/client/client.h

@ -683,7 +683,7 @@ extern convar_t *cl_clockreset; @@ -683,7 +683,7 @@ extern convar_t *cl_clockreset;
extern convar_t *cl_fixtimerate;
extern convar_t *hud_fontscale;
extern convar_t *hud_scale;
extern convar_t *gl_showtextures;
extern convar_t r_showtextures;
extern convar_t *cl_bmodelinterp;
extern convar_t *cl_lw; // local weapons
extern convar_t *cl_charset;
@ -697,7 +697,7 @@ extern convar_t *v_dark; // start from dark @@ -697,7 +697,7 @@ extern convar_t *v_dark; // start from dark
extern convar_t *net_graph;
extern convar_t *rate;
extern convar_t *m_ignore;
extern convar_t *r_showtree;
extern convar_t r_showtree;
extern convar_t *ui_renderworld;
//=============================================================================

4
engine/client/keys.c

@ -719,10 +719,10 @@ void GAME_EXPORT Key_Event( int key, int down ) @@ -719,10 +719,10 @@ void GAME_EXPORT Key_Event( int key, int down )
switch( cls.key_dest )
{
case key_game:
if( CVAR_TO_BOOL( gl_showtextures ))
if( r_showtextures.value )
{
// close texture atlas
Cvar_SetValue( "r_showtextures", 0.0f );
Cvar_DirectSet( &r_showtextures, "0" );
return;
}
else if( host.mouse_visible && cls.state != ca_cinematic )

36
engine/client/ref_common.c

@ -8,14 +8,14 @@ @@ -8,14 +8,14 @@
struct ref_state_s ref;
ref_globals_t refState;
convar_t *gl_vsync;
convar_t *gl_showtextures;
convar_t *r_decals;
convar_t *r_adjust_fov;
convar_t *r_showtree;
convar_t *gl_msaa_samples;
convar_t *gl_clear;
convar_t *r_refdll;
CVAR_DEFINE_AUTO( gl_vsync, "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
CVAR_DEFINE_AUTO( r_showtextures, "0", FCVAR_CHEAT, "show all uploaded textures" );
CVAR_DEFINE_AUTO( r_adjust_fov, "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
CVAR_DEFINE_AUTO( r_decals, "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
CVAR_DEFINE_AUTO( gl_msaa_samples, "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
CVAR_DEFINE_AUTO( gl_clear, "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
void R_GetTextureParms( int *w, int *h, int texnum )
{
@ -618,14 +618,14 @@ qboolean R_Init( void ) @@ -618,14 +618,14 @@ qboolean R_Init( void )
qboolean success = false;
string requested;
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
gl_msaa_samples = Cvar_Get( "gl_msaa_samples", "0", FCVAR_GLCONFIG, "samples number for multisample anti-aliasing" );
gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
r_showtree = Cvar_Get( "r_showtree", "0", FCVAR_ARCHIVE, "build the graph of visible BSP tree" );
r_refdll = Cvar_Get( "r_refdll", "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
Cvar_RegisterVariable( &gl_vsync );
Cvar_RegisterVariable( &r_showtextures );
Cvar_RegisterVariable( &r_adjust_fov );
Cvar_RegisterVariable( &r_decals );
Cvar_RegisterVariable( &gl_msaa_samples );
Cvar_RegisterVariable( &gl_clear );
Cvar_RegisterVariable( &r_showtree );
Cvar_RegisterVariable( &r_refdll );
// cvars that are expected to exist
Cvar_Get( "r_speeds", "0", FCVAR_ARCHIVE, "shows renderer speeds" );
@ -669,9 +669,9 @@ qboolean R_Init( void ) @@ -669,9 +669,9 @@ qboolean R_Init( void )
if( !success && Sys_GetParmFromCmdLine( "-ref", requested ))
success = R_LoadRenderer( requested );
if( !success && COM_CheckString( r_refdll->string ))
if( !success && COM_CheckString( r_refdll.string ))
{
Q_strncpy( requested, r_refdll->string, sizeof( requested ));
Q_strncpy( requested, r_refdll.string, sizeof( requested ));
success = R_LoadRenderer( requested );
}

6
engine/client/ref_common.h

@ -46,9 +46,9 @@ void R_GetTextureParms( int *w, int *h, int texnum ); @@ -46,9 +46,9 @@ void R_GetTextureParms( int *w, int *h, int texnum );
void GL_RenderFrame( const struct ref_viewpass_s *rvp );
// common engine and renderer cvars
extern convar_t *r_decals;
extern convar_t *r_adjust_fov;
extern convar_t *gl_clear;
extern convar_t r_decals;
extern convar_t r_adjust_fov;
extern convar_t gl_clear;
qboolean R_Init( void );
void R_Shutdown( void );

2
engine/client/vid_common.h

@ -34,8 +34,8 @@ extern convar_t vid_fullscreen; @@ -34,8 +34,8 @@ extern convar_t vid_fullscreen;
extern convar_t vid_highdpi;
extern convar_t window_xpos;
extern convar_t window_ypos;
extern convar_t gl_msaa_samples;
extern convar_t *gl_msaa_samples;
void R_SaveVideoMode( int w, int h, int render_w, int render_h );
void VID_SetDisplayTransform( int *render_w, int *render_h );
void VID_CheckChanges( void );

2
engine/common/common.h

@ -153,7 +153,7 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, @@ -153,7 +153,7 @@ void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile,
#define Assert( f )
#endif
extern convar_t *gl_vsync;
extern convar_t gl_vsync;
extern convar_t *scr_loading;
extern convar_t *scr_download;
extern convar_t *cmd_scripting;

6
engine/common/host.c

@ -278,7 +278,7 @@ static int Host_CalcSleep( void ) @@ -278,7 +278,7 @@ static int Host_CalcSleep( void )
#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 ))
if( CL_IsTimeDemo( ) || gl_vsync.value )
return 0;
#endif
@ -599,12 +599,12 @@ double Host_CalcFPS( void ) @@ -599,12 +599,12 @@ double Host_CalcFPS( void )
}
else if( Host_IsLocalGame( ))
{
if( !CVAR_TO_BOOL( gl_vsync ))
if( !gl_vsync.value )
fps = host_maxfps->value;
}
else
{
if( !CVAR_TO_BOOL( gl_vsync ))
if( !gl_vsync.value )
{
fps = host_maxfps->value;
if( fps == 0.0 ) fps = MAX_FPS;

6
engine/platform/linux/vid_fbdev.c

@ -168,11 +168,11 @@ void GL_UpdateSwapInterval( void ) @@ -168,11 +168,11 @@ void GL_UpdateSwapInterval( void )
{
// setup fb vsync here
fb.vsync = false;
SetBits( gl_vsync->flags, FCVAR_CHANGED );
SetBits( gl_vsync.flags, FCVAR_CHANGED );
}
else if( FBitSet( gl_vsync->flags, FCVAR_CHANGED ))
else if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
{
ClearBits( gl_vsync->flags, FCVAR_CHANGED );
ClearBits( gl_vsync.flags, FCVAR_CHANGED );
fb.vsync = true;
}
}

14
engine/platform/sdl/vid_sdl.c

@ -455,13 +455,13 @@ void GL_UpdateSwapInterval( void ) @@ -455,13 +455,13 @@ void GL_UpdateSwapInterval( void )
if( cls.state < ca_active )
{
SDL_GL_SetSwapInterval( 0 );
SetBits( gl_vsync->flags, FCVAR_CHANGED );
SetBits( gl_vsync.flags, FCVAR_CHANGED );
}
else if( FBitSet( gl_vsync->flags, FCVAR_CHANGED ))
else if( FBitSet( gl_vsync.flags, FCVAR_CHANGED ))
{
ClearBits( gl_vsync->flags, FCVAR_CHANGED );
ClearBits( gl_vsync.flags, FCVAR_CHANGED );
if( SDL_GL_SetSwapInterval( gl_vsync->value ) )
if( SDL_GL_SetSwapInterval( gl_vsync.value ) )
Con_Reportf( S_ERROR "SDL_GL_SetSwapInterval: %s\n", SDL_GetError( ) );
}
#endif // SDL_VERSION_ATLEAST( 2, 0, 0 )
@ -676,7 +676,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) @@ -676,7 +676,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
glw_state.safe++;
if( !gl_msaa_samples->value && glw_state.safe == SAFE_NOMSAA )
if( !gl_msaa_samples.value && glw_state.safe == SAFE_NOMSAA )
glw_state.safe++; // no need to skip msaa, if we already disabled it
GL_SetupAttributes(); // re-choose attributes
@ -816,7 +816,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen ) @@ -816,7 +816,7 @@ qboolean VID_CreateWindow( int width, int height, qboolean fullscreen )
glw_state.safe++;
if( !gl_msaa_samples->value && glw_state.safe == SAFE_NOMSAA )
if( !gl_msaa_samples.value && glw_state.safe == SAFE_NOMSAA )
glw_state.safe++; // no need to skip msaa, if we already disabled it
GL_SetupAttributes(); // re-choose attributes
@ -1131,7 +1131,7 @@ qboolean VID_SetMode( void ) @@ -1131,7 +1131,7 @@ qboolean VID_SetMode( void )
else
ClearBits( vid_fullscreen.flags, FCVAR_CHANGED );
SetBits( gl_vsync->flags, FCVAR_CHANGED );
SetBits( gl_vsync.flags, FCVAR_CHANGED );
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, vid_fullscreen.value )) == rserr_ok )
{

4
engine/ref_api.h

@ -627,7 +627,7 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* @@ -627,7 +627,7 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
#define DECLARE_ENGINE_SHARED_CVAR( x, y ) extern cvar_t *x;
#define RETRIEVE_ENGINE_SHARED_CVAR( x, y ) \
if(!( x = gEngfuncs.pfnGetCvarPointer( #y, 0 ) )) \
gEngfuncs.Host_Error( S_ERROR "engine betrayed us and didn't gave us %s cvar pointer\n", #y );
gEngfuncs.Host_Error( S_ERROR "engine didn't gave us %s cvar pointer\n", #y );
#define ENGINE_SHARED_CVAR_NAME( f, x, y ) f( x, y )
#define ENGINE_SHARED_CVAR( f, x ) ENGINE_SHARED_CVAR_NAME( f, x, x )
@ -638,7 +638,7 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* @@ -638,7 +638,7 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
#define ENGINE_SHARED_CVAR_LIST( f ) \
ENGINE_SHARED_CVAR_NAME( f, vid_gamma, gamma ) \
ENGINE_SHARED_CVAR_NAME( f, vid_brightness, brightness ) \
ENGINE_SHARED_CVAR_NAME( f, gl_showtextures, r_showtextures ) \
ENGINE_SHARED_CVAR( f, r_showtextures ) \
ENGINE_SHARED_CVAR( f, r_speeds ) \
ENGINE_SHARED_CVAR( f, r_fullbright ) \
ENGINE_SHARED_CVAR( f, r_norefresh ) \

10
ref/gl/gl_backend.c

@ -611,7 +611,7 @@ void R_ShowTextures( void ) @@ -611,7 +611,7 @@ void R_ShowTextures( void )
static qboolean showHelp = true;
string shortname;
if( !CVAR_TO_BOOL( gl_showtextures ))
if( !r_showtextures->value )
return;
if( showHelp )
@ -629,8 +629,8 @@ void R_ShowTextures( void ) @@ -629,8 +629,8 @@ void R_ShowTextures( void )
rebuild_page:
total = base_w * base_h;
start = total * (gl_showtextures->value - 1);
end = total * gl_showtextures->value;
start = total * (r_showtextures->value - 1);
end = total * r_showtextures->value;
if( end > MAX_TEXTURES ) end = MAX_TEXTURES;
w = gpGlobals->width / base_w;
@ -645,10 +645,10 @@ rebuild_page: @@ -645,10 +645,10 @@ rebuild_page:
if( pglIsTexture( image->texnum )) j++;
}
if( i == MAX_TEXTURES && gl_showtextures->value != 1 )
if( i == MAX_TEXTURES && r_showtextures->value != 1 )
{
// bad case, rewind to one and try again
gEngfuncs.Cvar_SetValue( "r_showtextures", Q_max( 1, gl_showtextures->value - 1 ));
gEngfuncs.Cvar_SetValue( "r_showtextures", Q_max( 1, r_showtextures->value - 1 ));
if( ++numTries < 2 ) goto rebuild_page; // to prevent infinite loop
}

1
ref/gl/gl_local.h

@ -736,7 +736,6 @@ extern cvar_t *r_lighting_ambient; @@ -736,7 +736,6 @@ extern cvar_t *r_lighting_ambient;
extern cvar_t *r_studio_lambert;
extern cvar_t *r_detailtextures;
extern cvar_t *r_drawentities;
extern cvar_t *r_decals;
extern cvar_t *r_novis;
extern cvar_t *r_nocull;
extern cvar_t *r_lockpvs;

2
ref/gl/gl_opengl.c

@ -25,8 +25,6 @@ cvar_t *r_lighting_extended; @@ -25,8 +25,6 @@ cvar_t *r_lighting_extended;
cvar_t *r_lighting_modulate;
cvar_t *r_lighting_ambient;
cvar_t *r_detailtextures;
cvar_t *r_adjust_fov;
cvar_t *r_decals;
cvar_t *r_novis;
cvar_t *r_nocull;
cvar_t *r_lockpvs;

1
ref/soft/r_local.h

@ -1103,7 +1103,6 @@ extern cvar_t *sw_stipplealpha; @@ -1103,7 +1103,6 @@ extern cvar_t *sw_stipplealpha;
extern cvar_t *sw_surfcacheoverride;
extern cvar_t *sw_waterwarp;
extern cvar_t *sw_texfilt;
extern cvar_t *r_decals;
extern cvar_t *r_traceglow;
extern cvar_t *sw_notransbrushes;
extern cvar_t *sw_noalphabrushes;

Loading…
Cancel
Save