From 7aed2b0c30c6d29d70efd2402a68a8e3de98418c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 10 Mar 2009 20:14:32 -0600 Subject: [PATCH] swrast: remove old texture_apply() code; always use texture combine code --- src/mesa/swrast/s_context.c | 22 +- src/mesa/swrast/s_context.h | 2 +- src/mesa/swrast/s_texcombine.c | 401 +-------------------------------- 3 files changed, 22 insertions(+), 403 deletions(-) diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 0257abc34ac..56bf2033ca6 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -172,19 +172,29 @@ _swrast_update_fog_hint( GLcontext *ctx ) /** - * Update the swrast->_AnyTextureCombine flag. + * Update the swrast->_TextureCombinePrimary flag. */ static void _swrast_update_texture_env( GLcontext *ctx ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint i; - swrast->_AnyTextureCombine = GL_FALSE; + + swrast->_TextureCombinePrimary = GL_FALSE; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (ctx->Texture.Unit[i].EnvMode == GL_COMBINE_EXT || - ctx->Texture.Unit[i].EnvMode == GL_COMBINE4_NV) { - swrast->_AnyTextureCombine = GL_TRUE; - return; + const struct gl_tex_env_combine_state *combine = + ctx->Texture.Unit[i]._CurrentCombine; + GLuint term; + for (term = 0; term < combine->_NumArgsRGB; term++) { + if (combine->SourceRGB[term] == GL_PRIMARY_COLOR) { + swrast->_TextureCombinePrimary = GL_TRUE; + return; + } + if (combine->SourceA[term] == GL_PRIMARY_COLOR) { + swrast->_TextureCombinePrimary = GL_TRUE; + return; + } } } } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 4cf57c6fc67..b7a17cb28c5 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -131,7 +131,7 @@ typedef struct GLfloat _BackfaceSign; /** +1 or -1 */ GLfloat _BackfaceCullSign; /** +1, 0, or -1 */ GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */ - GLboolean _AnyTextureCombine; + GLboolean _TextureCombinePrimary; GLboolean _FogEnabled; GLboolean _DeferredTexture; GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */ diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index ef2db0dc7e3..2c694c25cba 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -29,7 +29,6 @@ #include "main/colormac.h" #include "main/image.h" #include "main/imports.h" -#include "main/macros.h" #include "main/pixel.h" #include "shader/prog_instruction.h" @@ -92,8 +91,6 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, GLfloat rgba[MAX_WIDTH][4]; GLuint i, term; - ASSERT(CONST_SWRAST_CONTEXT(ctx)->_AnyTextureCombine); - for (i = 0; i < n; i++) { rgba[i][RCOMP] = CHAN_TO_FLOAT(rgbaChan[i][RCOMP]); rgba[i][GCOMP] = CHAN_TO_FLOAT(rgbaChan[i][GCOMP]); @@ -535,7 +532,6 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, } - /** * Apply X/Y/Z/W/0/1 swizzle to an array of colors/texels. * See GL_EXT_texture_swizzle. @@ -566,382 +562,6 @@ swizzle_texels(GLuint swizzle, GLuint count, float4_array texels) } -/** - * Apply a conventional OpenGL texture env mode (REPLACE, ADD, BLEND, - * MODULATE, or DECAL) to an array of fragments. - * Input: textureUnit - pointer to texture unit to apply - * format - base internal texture format - * n - number of fragments - * texels - array of texel colors - * InOut: rgba - incoming fragment colors modified by texel colors - * according to the texture environment mode. - */ -static void -texture_apply( const GLcontext *ctx, - const struct gl_texture_unit *texUnit, - GLuint n, - float4_array texel, - GLchan rgbaChan[][4] ) -{ - GLint baseLevel; - GLuint i; - GLfloat Rc, Gc, Bc, Ac; - GLenum format; - GLfloat rgba[MAX_WIDTH][4]; - - ASSERT(texUnit); - ASSERT(texUnit->_Current); - - baseLevel = texUnit->_Current->BaseLevel; - ASSERT(texUnit->_Current->Image[0][baseLevel]); - - format = texUnit->_Current->Image[0][baseLevel]->_BaseFormat; - - if (format == GL_COLOR_INDEX || format == GL_YCBCR_MESA) { - format = GL_RGBA; /* a bit of a hack */ - } - else if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) { - format = texUnit->_Current->DepthMode; - } - - /* skip chan->float conversion when not needed */ - if (texUnit->EnvMode != GL_REPLACE || format != GL_RGBA) { - /* convert GLchan colors to GLfloat */ - for (i = 0; i < n; i++) { - rgba[i][RCOMP] = CHAN_TO_FLOAT(rgbaChan[i][RCOMP]); - rgba[i][GCOMP] = CHAN_TO_FLOAT(rgbaChan[i][GCOMP]); - rgba[i][BCOMP] = CHAN_TO_FLOAT(rgbaChan[i][BCOMP]); - rgba[i][ACOMP] = CHAN_TO_FLOAT(rgbaChan[i][ACOMP]); - } - } - - switch (texUnit->EnvMode) { - case GL_REPLACE: - switch (format) { - case GL_ALPHA: - for (i=0;iEnvColor[0]; - Gc = texUnit->EnvColor[1]; - Bc = texUnit->EnvColor[2]; - Ac = texUnit->EnvColor[3]; - switch (format) { - case GL_ALPHA: - for (i=0;i_AnyTextureCombine) { + if (swrast->_TextureCombinePrimary) { GLuint i; for (i = 0; i < span->end; i++) { primary_rgba[i][RCOMP] = CHAN_TO_FLOAT(span->array->rgba[i][RCOMP]); @@ -1101,27 +721,16 @@ _swrast_texture_span( GLcontext *ctx, SWspan *span ) } } - /* * OK, now apply the texture (aka texture combine/blend). * We modify the span->color.rgba values. */ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { if (ctx->Texture.Unit[unit]._ReallyEnabled) { - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - if (texUnit->_CurrentCombine != &texUnit->_EnvMode ) { - texture_combine( ctx, unit, span->end, - primary_rgba, - swrast->TexelBuffer, - span->array->rgba ); - } - else { - /* conventional texture blend */ - float4_array texels = - get_texel_array(swrast->TexelBuffer, unit, span->end); - texture_apply( ctx, texUnit, span->end, - texels, span->array->rgba ); - } + texture_combine( ctx, unit, span->end, + primary_rgba, + swrast->TexelBuffer, + span->array->rgba ); } } } -- 2.30.2