Skip to content

Commit

Permalink
ref: gl: make GL_Support and GL_MaxTextureUnits functions inlined
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jan 30, 2025
1 parent f9d4ac2 commit 77abf62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
18 changes: 16 additions & 2 deletions ref/gl/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,6 @@ void CL_AddCustomBeam( cl_entity_t *pEnvBeam );
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
const char *GL_ErrorString( int err );
qboolean GL_Support( int r_ext );
int GL_MaxTextureUnits( void );

//
// gl_triapi.c
Expand Down Expand Up @@ -756,6 +754,22 @@ static inline uint LinearGammaTable( uint b )
return !FBitSet( gp_host->features, ENGINE_LINEAR_GAMMA_SPACE ) ? tr.lineargammatable[b] : b;
}

static inline qboolean GL_Support( int r_ext )
{
if( r_ext >= 0 && r_ext < GL_EXTCOUNT )
return glConfig.extension[r_ext] ? true : false;
gEngfuncs.Con_Printf( S_ERROR "%s: invalid extension %d\n", __func__, r_ext );

return false;
}

static inline int GL_MaxTextureUnits( void )
{
if( GL_Support( GL_SHADER_GLSL100_EXT ))
return Q_min( Q_max( glConfig.max_texture_coords, glConfig.max_teximage_units ), MAX_TEXTURE_UNITS );
return glConfig.max_texture_units;
}

#define WORLDMODEL (gp_cl->models[1])

//
Expand Down
26 changes: 0 additions & 26 deletions ref/gl/gl_opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,32 +464,6 @@ static void GL_SetExtension( int r_ext, int enable )
else gEngfuncs.Con_Printf( S_ERROR "%s: invalid extension %d\n", __func__, r_ext );
}

/*
=================
GL_Support
=================
*/
qboolean GL_Support( int r_ext )
{
if( r_ext >= 0 && r_ext < GL_EXTCOUNT )
return glConfig.extension[r_ext] ? true : false;
gEngfuncs.Con_Printf( S_ERROR "%s: invalid extension %d\n", __func__, r_ext );

return false;
}

/*
=================
GL_MaxTextureUnits
=================
*/
int GL_MaxTextureUnits( void )
{
if( GL_Support( GL_SHADER_GLSL100_EXT ))
return Q_min( Q_max( glConfig.max_texture_coords, glConfig.max_teximage_units ), MAX_TEXTURE_UNITS );
return glConfig.max_texture_units;
}

/*
=================
GL_CheckExtension
Expand Down

0 comments on commit 77abf62

Please sign in to comment.