From decc6e2a32ef49e673c081f30e19b8970155d887 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 11 Mar 2011 09:25:21 -0700 Subject: mesa: replace NEED_SECONDARY_COLOR(), RGBA_LOGICOP_ENABLED() with inlines and rename them. --- src/mesa/drivers/dri/i915/i830_state.c | 5 +-- src/mesa/drivers/dri/i915/i915_state.c | 3 +- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 2 +- src/mesa/drivers/dri/mga/mgastate.c | 9 +++--- src/mesa/drivers/dri/nouveau/nv04_state_raster.c | 4 +-- src/mesa/drivers/dri/nouveau/nv10_state_tnl.c | 2 +- src/mesa/drivers/dri/nouveau/nv20_state_tnl.c | 2 +- src/mesa/drivers/dri/r128/r128_state.c | 3 +- src/mesa/drivers/dri/r300/r300_state.c | 6 ++-- src/mesa/drivers/dri/r600/evergreen_state.c | 6 ++-- src/mesa/drivers/dri/r600/r700_state.c | 6 ++-- src/mesa/drivers/dri/radeon/radeon_state.c | 3 +- src/mesa/drivers/dri/savage/savagestate.c | 7 +++-- src/mesa/drivers/dri/sis/sis6326_state.c | 3 +- src/mesa/drivers/dri/sis/sis_state.c | 3 +- src/mesa/main/context.h | 24 --------------- src/mesa/main/state.c | 6 ++-- src/mesa/main/state.h | 39 ++++++++++++++++++++++++ src/mesa/swrast/s_aatriangle.c | 3 +- src/mesa/swrast/s_triangle.c | 5 +-- src/mesa/tnl/t_context.c | 3 +- 21 files changed, 85 insertions(+), 59 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index ef5b8d971d..9fecab10db 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -31,6 +31,7 @@ #include "main/macros.h" #include "main/enums.h" #include "main/dd.h" +#include "main/state.h" #include "texmem.h" @@ -234,7 +235,7 @@ i830EvalLogicOpBlendState(struct gl_context * ctx) I830_STATECHANGE(i830, I830_UPLOAD_CTX); - if (RGBA_LOGICOP_ENABLED(ctx)) { + if (_mesa_rgba_logicop_enabled(ctx)) { i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND | ENABLE_LOGIC_OP_MASK); i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND | @@ -679,7 +680,7 @@ update_specular(struct gl_context * ctx) I830_STATECHANGE(i830, I830_UPLOAD_CTX); i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD; else i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD; diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 58d4f5daff..3b1af4c455 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -31,6 +31,7 @@ #include "main/macros.h" #include "main/enums.h" #include "main/dd.h" +#include "main/state.h" #include "tnl/tnl.h" #include "tnl/t_context.h" @@ -209,7 +210,7 @@ i915EvalLogicOpBlendState(struct gl_context * ctx) dw0 = i915->state.Ctx[I915_CTXREG_LIS5]; dw1 = i915->state.Ctx[I915_CTXREG_LIS6]; - if (RGBA_LOGICOP_ENABLED(ctx)) { + if (_mesa_rgba_logicop_enabled(ctx)) { dw0 |= S5_LOGICOP_ENABLE; dw1 &= ~S6_CBUF_BLEND_ENABLE; } diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index d398775906..43cdd0d2ba 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -208,7 +208,7 @@ do_blit_bitmap( struct gl_context *ctx, COPY_4V(tmpColor, ctx->Current.RasterColor); - if (NEED_SECONDARY_COLOR(ctx)) { + if (_mesa_need_secondary_color(ctx)) { ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor); } diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index 2fac2b49cd..bfc55f4fc6 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -30,6 +30,7 @@ #include "main/colormac.h" #include "main/dd.h" #include "main/mm.h" +#include "main/state.h" #include "mgacontext.h" #include "mgadd.h" @@ -114,7 +115,7 @@ static void mgaDDAlphaFunc(struct gl_context *ctx, GLenum func, GLfloat ref) static void updateBlendLogicOp(struct gl_context *ctx) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLboolean logicOp = RGBA_LOGICOP_ENABLED(ctx); + GLboolean logicOp = _mesa_rgba_logicop_enabled(ctx); MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT ); @@ -197,7 +198,7 @@ static void mgaDDBlendFuncSeparate( struct gl_context *ctx, GLenum sfactorRGB, mmesa->hw.blend_func = (src | dst); FALLBACK( ctx, MGA_FALLBACK_BLEND, - ctx->Color.BlendEnabled && !RGBA_LOGICOP_ENABLED(ctx) && + ctx->Color.BlendEnabled && !_mesa_rgba_logicop_enabled(ctx) && mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) ); } @@ -483,7 +484,7 @@ static void updateSpecularLighting( struct gl_context *ctx ) mgaContextPtr mmesa = MGA_CONTEXT(ctx); unsigned int specen; - specen = NEED_SECONDARY_COLOR(ctx) ? TMC_specen_enable : 0; + specen = _mesa_need_secondary_color(ctx) ? TMC_specen_enable : 0; if ( specen != mmesa->hw.specen ) { mmesa->hw.specen = specen; @@ -962,7 +963,7 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) ? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i); mmesa->setup.dwgctl &= DC_bop_MASK; - mmesa->setup.dwgctl |= RGBA_LOGICOP_ENABLED(ctx) + mmesa->setup.dwgctl |= _mesa_rgba_logicop_enabled(ctx) ? mmesa->hw.rop : mgarop_NoBLK[ GL_COPY & 0x0f ]; mmesa->setup.alphactrl &= AC_src_MASK & AC_dst_MASK & AC_atmode_MASK diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c index ecfbdfedff..78d29fc485 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c @@ -277,7 +277,7 @@ nv04_emit_blend(struct gl_context *ctx, int emit) blend |= NV04_MULTITEX_TRIANGLE_BLEND_SHADE_MODE_FLAT; /* Secondary color */ - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) blend |= NV04_MULTITEX_TRIANGLE_BLEND_SPECULAR_ENABLE; /* Fog. */ @@ -315,7 +315,7 @@ nv04_emit_blend(struct gl_context *ctx, int emit) blend |= get_texenv_mode(GL_MODULATE); /* Secondary color */ - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) blend |= NV04_TEXTURED_TRIANGLE_BLEND_SPECULAR_ENABLE; /* Fog. */ diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c index e8bd12e6e0..96d1b320d8 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c @@ -199,7 +199,7 @@ nv10_emit_light_model(struct gl_context *ctx, int emit) BEGIN_RING(chan, celsius, NV10_3D_LIGHT_MODEL, 1); OUT_RING(chan, ((m->LocalViewer ? NV10_3D_LIGHT_MODEL_LOCAL_VIEWER : 0) | - (NEED_SECONDARY_COLOR(ctx) ? + (_mesa_need_secondary_color(ctx) ? NV10_3D_LIGHT_MODEL_SEPARATE_SPECULAR : 0) | (!ctx->Light.Enabled && ctx->Fog.ColorSumEnabled ? NV10_3D_LIGHT_MODEL_VERTEX_SPECULAR : 0))); diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c index 4677198dd0..4f7ddd8e49 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c @@ -178,7 +178,7 @@ nv20_emit_light_model(struct gl_context *ctx, int emit) OUT_RING(chan, ((m->LocalViewer ? NV20_3D_LIGHT_MODEL_VIEWER_LOCAL : NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL) | - (NEED_SECONDARY_COLOR(ctx) ? + (_mesa_need_secondary_color(ctx) ? NV20_3D_LIGHT_MODEL_SEPARATE_SPECULAR : 0))); diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index d6725cdd0e..7ce082ead2 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -43,6 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/enums.h" #include "main/colormac.h" #include "main/macros.h" +#include "main/state.h" #include "swrast/swrast.h" #include "vbo/vbo.h" #include "tnl/tnl.h" @@ -736,7 +737,7 @@ static void updateSpecularLighting( struct gl_context *ctx ) r128ContextPtr rmesa = R128_CONTEXT(ctx); GLuint t = rmesa->setup.tex_cntl_c; - if ( NEED_SECONDARY_COLOR( ctx ) ) { + if ( _mesa_need_secondary_color( ctx ) ) { if (ctx->Light.ShadeModel == GL_FLAT) { /* R128 can't do flat-shaded separate specular */ t &= ~R128_SPEC_LIGHT_ENABLE; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 9df9101bcd..51989c6b22 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -214,7 +214,7 @@ static void r300SetBlendState(struct gl_context * ctx) (R300_BLEND_GL_ZERO << R300_DST_BLEND_SHIFT); int eqnA = R300_COMB_FCN_ADD_CLAMP; - if (RGBA_LOGICOP_ENABLED(ctx) || !ctx->Color.BlendEnabled) { + if (_mesa_rgba_logicop_enabled(ctx) || !ctx->Color.BlendEnabled) { r300SetBlendCntl(r300, func, eqn, 0, func, eqn); return; } @@ -335,7 +335,7 @@ static void r300SetLogicOpState(struct gl_context *ctx) { r300ContextPtr r300 = R300_CONTEXT(ctx); R300_STATECHANGE(r300, rop); - if (RGBA_LOGICOP_ENABLED(ctx)) { + if (_mesa_rgba_logicop_enabled(ctx)) { r300->hw.rop.cmd[1] = R300_RB3D_ROPCNTL_ROP_ENABLE | translate_logicop(ctx->Color.LogicOp); } else { @@ -349,7 +349,7 @@ static void r300SetLogicOpState(struct gl_context *ctx) */ static void r300LogicOpcode(struct gl_context *ctx, GLenum logicop) { - if (RGBA_LOGICOP_ENABLED(ctx)) + if (_mesa_rgba_logicop_enabled(ctx)) r300SetLogicOpState(ctx); } diff --git a/src/mesa/drivers/dri/r600/evergreen_state.c b/src/mesa/drivers/dri/r600/evergreen_state.c index 006e50007b..db117417ac 100644 --- a/src/mesa/drivers/dri/r600/evergreen_state.c +++ b/src/mesa/drivers/dri/r600/evergreen_state.c @@ -342,7 +342,7 @@ static void evergreenSetBlendState(struct gl_context * ctx) //diff : CB_COLOR_CO EVERGREEN_STATECHANGE(context, cb); - if (RGBA_LOGICOP_ENABLED(ctx) || !ctx->Color.BlendEnabled) { + if (_mesa_rgba_logicop_enabled(ctx) || !ctx->Color.BlendEnabled) { SETfield(blend_reg, BLEND_ONE, COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask); SETfield(blend_reg, @@ -520,7 +520,7 @@ static void evergreenSetLogicOpState(struct gl_context *ctx) //diff : CB_COLOR_C EVERGREEN_STATECHANGE(context, cb); - if (RGBA_LOGICOP_ENABLED(ctx)) + if (_mesa_rgba_logicop_enabled(ctx)) SETfield(evergreen->CB_COLOR_CONTROL.u32All, evergreen_translate_logicop(ctx->Color.LogicOp), EG_CB_COLOR_CONTROL__ROP3_shift, @@ -1148,7 +1148,7 @@ static void evergreenShadeModel(struct gl_context * ctx, GLenum mode) //same static void evergreenLogicOpcode(struct gl_context *ctx, GLenum logicop) //diff { - if (RGBA_LOGICOP_ENABLED(ctx)) + if (_mesa_rgba_logicop_enabled(ctx)) evergreenSetLogicOpState(ctx); } diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index f8770690ff..d272fec250 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -453,7 +453,7 @@ static void r700SetBlendState(struct gl_context * ctx) R600_STATECHANGE(context, blnd); - if (RGBA_LOGICOP_ENABLED(ctx) || !ctx->Color.BlendEnabled) { + if (_mesa_rgba_logicop_enabled(ctx) || !ctx->Color.BlendEnabled) { SETfield(blend_reg, BLEND_ONE, COLOR_SRCBLEND_shift, COLOR_SRCBLEND_mask); SETfield(blend_reg, @@ -644,7 +644,7 @@ static void r700SetLogicOpState(struct gl_context *ctx) R600_STATECHANGE(context, blnd); - if (RGBA_LOGICOP_ENABLED(ctx)) + if (_mesa_rgba_logicop_enabled(ctx)) SETfield(r700->CB_COLOR_CONTROL.u32All, translate_logicop(ctx->Color.LogicOp), ROP3_shift, ROP3_mask); else @@ -657,7 +657,7 @@ static void r700SetLogicOpState(struct gl_context *ctx) */ static void r700LogicOpcode(struct gl_context *ctx, GLenum logicop) { - if (RGBA_LOGICOP_ENABLED(ctx)) + if (_mesa_rgba_logicop_enabled(ctx)) r700SetLogicOpState(ctx); } diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index e88e984354..a93e61870a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -40,6 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/framebuffer.h" #include "main/simple_list.h" +#include "main/state.h" #include "vbo/vbo.h" #include "tnl/tnl.h" @@ -661,7 +662,7 @@ static void radeonUpdateSpecular( struct gl_context *ctx ) TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_FOGCOORDSPEC, flag); - if (NEED_SECONDARY_COLOR(ctx)) { + if (_mesa_need_secondary_color(ctx)) { assert( (p & RADEON_SPECULAR_ENABLE) != 0 ); } else { assert( (p & RADEON_SPECULAR_ENABLE) == 0 ); diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c index 1feffa0b0a..21ebf5dc2b 100644 --- a/src/mesa/drivers/dri/savage/savagestate.c +++ b/src/mesa/drivers/dri/savage/savagestate.c @@ -29,8 +29,9 @@ #include "main/enums.h" #include "main/macros.h" #include "main/dd.h" - #include "main/mm.h" +#include "main/state.h" + #include "savagedd.h" #include "savagecontext.h" @@ -869,7 +870,7 @@ static void savageUpdateSpecular_s4(struct gl_context *ctx) { savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); uint32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui; - if (NEED_SECONDARY_COLOR(ctx)) { + if (_mesa_need_secondary_color(ctx)) { imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_TRUE; } else { imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_FALSE; @@ -883,7 +884,7 @@ static void savageUpdateSpecular_s3d(struct gl_context *ctx) { savageContextPtr imesa = SAVAGE_CONTEXT( ctx ); uint32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui; - if (NEED_SECONDARY_COLOR(ctx)) { + if (_mesa_need_secondary_color(ctx)) { imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_TRUE; } else { imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_FALSE; diff --git a/src/mesa/drivers/dri/sis/sis6326_state.c b/src/mesa/drivers/dri/sis/sis6326_state.c index 9708f63912..9ca58293b4 100644 --- a/src/mesa/drivers/dri/sis/sis6326_state.c +++ b/src/mesa/drivers/dri/sis/sis6326_state.c @@ -35,6 +35,7 @@ #include "main/context.h" #include "main/colormac.h" +#include "main/state.h" #include "swrast/swrast.h" #include "vbo/vbo.h" #include "tnl/tnl.h" @@ -355,7 +356,7 @@ static void sis6326UpdateSpecular(struct gl_context *ctx) sisContextPtr smesa = SIS_CONTEXT(ctx); __GLSiSHardware *current = &smesa->current; - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) current->hwCapEnable |= S_ENABLE_Specular; else current->hwCapEnable &= ~S_ENABLE_Specular; diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c index e53c326441..828772ed6e 100644 --- a/src/mesa/drivers/dri/sis/sis_state.c +++ b/src/mesa/drivers/dri/sis/sis_state.c @@ -38,6 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/macros.h" +#include "main/state.h" #include "swrast/swrast.h" #include "vbo/vbo.h" #include "tnl/tnl.h" @@ -407,7 +408,7 @@ static void sisUpdateSpecular(struct gl_context *ctx) sisContextPtr smesa = SIS_CONTEXT(ctx); __GLSiSHardware *current = &smesa->current; - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) current->hwCapEnable |= MASK_SpecularEnable; else current->hwCapEnable &= ~MASK_SpecularEnable; diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 4e391dde49..33a36311c8 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -286,28 +286,4 @@ do { \ -/** - * Is the secondary color needed? - */ -#define NEED_SECONDARY_COLOR(CTX) \ - (((CTX)->Light.Enabled && \ - (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ - || (CTX)->Fog.ColorSumEnabled \ - || ((CTX)->VertexProgram._Current && \ - ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) && \ - ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \ - || ((CTX)->FragmentProgram._Current && \ - ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) && \ - ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \ - ) - - -/** - * Is RGBA LogicOp enabled? - */ -#define RGBA_LOGICOP_ENABLED(CTX) \ - ((CTX)->Color.ColorLogicOpEnabled || \ - ((CTX)->Color.BlendEnabled && (CTX)->Color.Blend[0].EquationRGB == GL_LOGIC_OP)) - - #endif /* CONTEXT_H */ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 502c429294..19c9bbabda 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -53,7 +53,7 @@ static void update_separate_specular(struct gl_context *ctx) { - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; else ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; @@ -442,7 +442,7 @@ update_color(struct gl_context *ctx) /* This is needed to support 1.1's RGB logic ops AND * 1.0's blending logicops. */ - ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx); + ctx->Color._LogicOpEnabled = _mesa_rgba_logicop_enabled(ctx); } @@ -524,7 +524,7 @@ update_tricaps(struct gl_context *ctx, GLbitfield new_state) ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; if (ctx->Light.ShadeModel == GL_FLAT) ctx->_TriangleCaps |= DD_FLATSHADE; - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; /* diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index f0eb43d8ee..a48c777567 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -46,4 +46,43 @@ extern void _mesa_set_vp_override(struct gl_context *ctx, GLboolean flag); +/** + * Is the secondary color needed? + */ +static INLINE GLboolean +_mesa_need_secondary_color(const struct gl_context *ctx) +{ + if (ctx->Light.Enabled && + ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + return GL_TRUE; + + if (ctx->Fog.ColorSumEnabled) + return GL_TRUE; + + if (ctx->VertexProgram._Current && + (ctx->VertexProgram._Current != ctx->VertexProgram._TnlProgram) && + (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) + return GL_TRUE; + + if (ctx->FragmentProgram._Current && + (ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram) && + (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) + return GL_TRUE; + + return GL_FALSE; +} + + +/** + * Is RGBA LogicOp enabled? + */ +static INLINE GLboolean +_mesa_rgba_logicop_enabled(const struct gl_context *ctx) +{ + return ctx->Color.ColorLogicOpEnabled || + (ctx->Color.BlendEnabled && ctx->Color.Blend[0].EquationRGB == GL_LOGIC_OP); +} + + + #endif diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index c597808e40..2c02a01327 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -33,6 +33,7 @@ #include "main/colormac.h" #include "main/macros.h" #include "main/imports.h" +#include "main/state.h" #include "s_aatriangle.h" #include "s_context.h" #include "s_span.h" @@ -305,7 +306,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) if (ctx->Texture._EnabledCoordUnits != 0 || ctx->FragmentProgram._Current || swrast->_FogEnabled - || NEED_SECONDARY_COLOR(ctx)) { + || _mesa_need_secondary_color(ctx)) { SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri; } else { diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 066f18203f..d07a4ef751 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -35,6 +35,7 @@ #include "main/imports.h" #include "main/macros.h" #include "main/mtypes.h" +#include "main/state.h" #include "program/prog_instruction.h" #include "s_aatriangle.h" @@ -1032,7 +1033,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled || - NEED_SECONDARY_COLOR(ctx) || + _mesa_need_secondary_color(ctx) || swrast->_FogEnabled) { /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ const struct gl_texture_object *texObj2D; @@ -1113,7 +1114,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) } else { ASSERT(!swrast->_FogEnabled); - ASSERT(!NEED_SECONDARY_COLOR(ctx)); + ASSERT(!_mesa_need_secondary_color(ctx)); if (ctx->Light.ShadeModel==GL_SMOOTH) { /* smooth shaded, no texturing, stippled or some raster ops */ #if CHAN_BITS != 8 diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 47aeeb8859..5f5e2663b5 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -34,6 +34,7 @@ #include "main/light.h" #include "math/m_translate.h" #include "math/m_xform.h" +#include "main/state.h" #include "tnl.h" #include "t_context.h" @@ -127,7 +128,7 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 ); } - if (NEED_SECONDARY_COLOR(ctx)) + if (_mesa_need_secondary_color(ctx)) RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 ); for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { -- cgit v1.2.3