Browse Source

ref: gl: only enable/disable texture units in fixed-function pipeline rendering, in our case, low TMUs

pull/2/head
Alibek Omarov 1 year ago
parent
commit
22f60d50ac
  1. 26
      ref/gl/gl_backend.c
  2. 5
      ref/gl/gl_image.c
  3. 1
      ref/gl/gl_local.h

26
ref/gl/gl_backend.c

@ -259,6 +259,27 @@ void GL_MultiTexCoord2f( GLenum texture, GLfloat s, GLfloat t )
pglMultiTexCoord2f( texture + GL_TEXTURE0_ARB, s, t ); pglMultiTexCoord2f( texture + GL_TEXTURE0_ARB, s, t );
} }
/*
====================
GL_EnableTextureUnit
====================
*/
void GL_EnableTextureUnit( int tmu, qboolean enable )
{
// only enable fixed-function pipeline units
if( tmu < glConfig.max_texture_units )
{
if( enable )
{
pglEnable( glState.currentTextureTargets[tmu] );
}
else if( glState.currentTextureTargets[tmu] != GL_NONE )
{
pglDisable( glState.currentTextureTargets[tmu] );
}
}
}
/* /*
================= =================
GL_TextureTarget GL_TextureTarget
@ -274,11 +295,10 @@ void GL_TextureTarget( uint target )
if( glState.currentTextureTargets[glState.activeTMU] != target ) if( glState.currentTextureTargets[glState.activeTMU] != target )
{ {
if( glState.currentTextureTargets[glState.activeTMU] != GL_NONE ) GL_EnableTextureUnit( glState.activeTMU, false );
pglDisable( glState.currentTextureTargets[glState.activeTMU] );
glState.currentTextureTargets[glState.activeTMU] = target; glState.currentTextureTargets[glState.activeTMU] = target;
if( target != GL_NONE ) if( target != GL_NONE )
pglEnable( glState.currentTextureTargets[glState.activeTMU] ); GL_EnableTextureUnit( glState.activeTMU, true );
} }
} }

5
ref/gl/gl_image.c

@ -105,10 +105,9 @@ void GL_Bind( GLint tmu, GLenum texnum )
if( glState.currentTextureTargets[tmu] != glTarget ) if( glState.currentTextureTargets[tmu] != glTarget )
{ {
if( glState.currentTextureTargets[tmu] != GL_NONE ) GL_EnableTextureUnit( tmu, false );
pglDisable( glState.currentTextureTargets[tmu] );
glState.currentTextureTargets[tmu] = glTarget; glState.currentTextureTargets[tmu] = glTarget;
pglEnable( glState.currentTextureTargets[tmu] ); GL_EnableTextureUnit( tmu, true );
} }
if( glState.currentTextures[tmu] == texture->texnum ) if( glState.currentTextures[tmu] == texture->texnum )

1
ref/gl/gl_local.h

@ -301,6 +301,7 @@ void GL_CleanupAllTextureUnits( void );
void GL_LoadIdentityTexMatrix( void ); void GL_LoadIdentityTexMatrix( void );
void GL_DisableAllTexGens( void ); void GL_DisableAllTexGens( void );
void GL_SetRenderMode( int mode ); void GL_SetRenderMode( int mode );
void GL_EnableTextureUnit( int tmu, qboolean enable );
void GL_TextureTarget( uint target ); void GL_TextureTarget( uint target );
void GL_Cull( GLenum cull ); void GL_Cull( GLenum cull );
void R_ShowTextures( void ); void R_ShowTextures( void );

Loading…
Cancel
Save