OpenGL2: remove lightmap support from generic glsl shader.

This path was barely used and doing this compiles fewer shaders.
This commit is contained in:
SmileTheory 2014-11-10 21:59:37 -08:00
parent 1d016e6ff5
commit b1821e303d
6 changed files with 3 additions and 238 deletions

View file

@ -2122,161 +2122,6 @@ static void ComputeVertexAttribs(void)
}
}
typedef struct {
int blendA;
int blendB;
int multitextureEnv;
int multitextureBlend;
} collapse_t;
static collapse_t collapse[] = {
{ 0, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,
GL_MODULATE, 0 },
{ 0, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,
GL_MODULATE, 0 },
{ GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,
GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },
{ GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR,
GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },
{ GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,
GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },
{ GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO,
GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR },
{ 0, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE,
GL_ADD, 0 },
{ GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE,
GL_ADD, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE },
#if 0
{ 0, GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA,
GL_DECAL, 0 },
#endif
{ -1 }
};
/*
================
CollapseMultitexture
Attempt to combine two stages into a single multitexture stage
FIXME: I think modulated add + modulated add collapses incorrectly
=================
*/
static qboolean CollapseMultitexture( void ) {
int abits, bbits;
int i;
textureBundle_t tmpBundle;
if ( !qglActiveTextureARB ) {
return qfalse;
}
// make sure both stages are active
if ( !stages[0].active || !stages[1].active ) {
return qfalse;
}
// on voodoo2, don't combine different tmus
if ( glConfig.driverType == GLDRV_VOODOO ) {
if ( stages[0].bundle[0].image[0]->TMU ==
stages[1].bundle[0].image[0]->TMU ) {
return qfalse;
}
}
abits = stages[0].stateBits;
bbits = stages[1].stateBits;
// make sure that both stages have identical state other than blend modes
if ( ( abits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) !=
( bbits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) ) {
return qfalse;
}
abits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );
bbits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );
// search for a valid multitexture blend function
for ( i = 0; collapse[i].blendA != -1 ; i++ ) {
if ( abits == collapse[i].blendA
&& bbits == collapse[i].blendB ) {
break;
}
}
// nothing found
if ( collapse[i].blendA == -1 ) {
return qfalse;
}
// GL_ADD is a separate extension
if ( collapse[i].multitextureEnv == GL_ADD && !glConfig.textureEnvAddAvailable ) {
return qfalse;
}
// make sure waveforms have identical parameters
if ( ( stages[0].rgbGen != stages[1].rgbGen ) ||
( stages[0].alphaGen != stages[1].alphaGen ) ) {
return qfalse;
}
// an add collapse can only have identity colors
if ( collapse[i].multitextureEnv == GL_ADD && stages[0].rgbGen != CGEN_IDENTITY ) {
return qfalse;
}
if ( stages[0].rgbGen == CGEN_WAVEFORM )
{
if ( memcmp( &stages[0].rgbWave,
&stages[1].rgbWave,
sizeof( stages[0].rgbWave ) ) )
{
return qfalse;
}
}
if ( stages[0].alphaGen == AGEN_WAVEFORM )
{
if ( memcmp( &stages[0].alphaWave,
&stages[1].alphaWave,
sizeof( stages[0].alphaWave ) ) )
{
return qfalse;
}
}
// make sure that lightmaps are in bundle 1 for 3dfx
if ( stages[0].bundle[0].isLightmap )
{
tmpBundle = stages[0].bundle[0];
stages[0].bundle[0] = stages[1].bundle[0];
stages[0].bundle[1] = tmpBundle;
}
else
{
stages[0].bundle[1] = stages[1].bundle[0];
}
// set the new blend state bits
shader.multitextureEnv = collapse[i].multitextureEnv;
stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS );
stages[0].stateBits |= collapse[i].multitextureBlend;
//
// move down subsequent shaders
//
memmove( &stages[1], &stages[2], sizeof( stages[0] ) * ( MAX_SHADER_STAGES - 2 ) );
Com_Memset( &stages[MAX_SHADER_STAGES-1], 0, sizeof( stages[0] ) );
return qtrue;
}
static void CollapseStagesToLightall(shaderStage_t *diffuse,
shaderStage_t *normal, shaderStage_t *specular, shaderStage_t *lightmap,
@ -2607,9 +2452,6 @@ static int CollapseStagesToGLSL(void)
numStages++;
}
if (numStages == i && i >= 2 && CollapseMultitexture())
numStages--;
// convert any remaining lightmap stages to a lighting pass with a white texture
// only do this with r_sunlightMode non-zero, as it's only for correct shadows.
if (r_sunlightMode->integer && shader.numDeforms == 0)
@ -3647,15 +3489,6 @@ void R_ShaderList_f (void) {
} else {
ri.Printf (PRINT_ALL, " ");
}
if ( shader->multitextureEnv == GL_ADD ) {
ri.Printf( PRINT_ALL, "MT(a) " );
} else if ( shader->multitextureEnv == GL_MODULATE ) {
ri.Printf( PRINT_ALL, "MT(m) " );
} else if ( shader->multitextureEnv == GL_DECAL ) {
ri.Printf( PRINT_ALL, "MT(d) " );
} else {
ri.Printf( PRINT_ALL, " " );
}
if ( shader->explicitlyDefined ) {
ri.Printf( PRINT_ALL, "E " );
} else {