diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/context.h | 26 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatriangle.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_lines.c | 3 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_triangle.c | 14 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_vb.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 8 |
7 files changed, 50 insertions, 19 deletions
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index be65be82147..78b21796272 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -361,4 +361,30 @@ do { \ /*@}*/ + +/** + * Macros to help evaluate current state conditions + */ + +/*@{*/ + +/** + * Is the secondary color needed? + */ +#define NEED_SECONDARY_COLOR(CTX) \ + (((CTX)->Light.Enabled && \ + (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \ + || (CTX)->Fog.ColorSumEnabled) + + +/** + * Is two-sided lighting in effect? + */ +#define NEED_TWO_SIDED_LIGHTING(CTX) \ + (ctx->Light.Enabled && ctx->Light.Model.TwoSide) + + +/*@}*/ + + #endif diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 21b8c0437ef..7f2f3e338a4 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -464,7 +464,7 @@ _swrast_set_aa_triangle_function(GLcontext *ctx) ASSERT(ctx->Polygon.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0) { - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) { + if (NEED_SECONDARY_COLOR(ctx)) { if (ctx->Texture._EnabledCoordUnits > 1) { SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri; } diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 9e429aef857..99da79afd5f 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -226,8 +226,8 @@ _swrast_validate_triangle( GLcontext *ctx, _swrast_validate_derived( ctx ); swrast->choose_triangle( ctx ); - if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) && - ctx->Texture._EnabledUnits == 0) { + if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) { + /* separate specular color, but no texture */ swrast->SpecTriangle = swrast->Triangle; swrast->Triangle = _swrast_add_spec_terms_triangle; } @@ -243,8 +243,7 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 ) _swrast_validate_derived( ctx ); swrast->choose_line( ctx ); - if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) && - ctx->Texture._EnabledUnits == 0) { + if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) { swrast->SpecLine = swrast->Line; swrast->Line = _swrast_add_spec_terms_line; } @@ -261,8 +260,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 ) _swrast_validate_derived( ctx ); swrast->choose_point( ctx ); - if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) && - ctx->Texture._EnabledUnits == 0) { + if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) { swrast->SpecPoint = swrast->Point; swrast->Point = _swrast_add_spec_terms_point; } diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 97143a2f4b7..f003395d428 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -24,6 +24,7 @@ #include "glheader.h" +#include "context.h" #include "colormac.h" #include "macros.h" #include "s_aaline.h" @@ -304,7 +305,7 @@ _swrast_choose_line( GLcontext *ctx ) else if (ctx->Texture._EnabledCoordUnits) { /* textured lines */ if (ctx->Texture._EnabledCoordUnits > 0x1 - || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) { + || NEED_SECONDARY_COLOR(ctx)) { /* multi-texture and/or separate specular color */ USE(multitextured_line); } diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index b041c32ef5c..d106d4c3173 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -69,7 +69,7 @@ static void _swsetup_render_line_tri( GLcontext *ctx, return; } - if (ctx->_TriangleCaps & DD_FLATSHADE) { + if (ctx->Light.ShadeModel == GL_FLAT) { COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[1], v1->color); COPY_CHAN4(s[0], v0->specular); @@ -95,7 +95,7 @@ static void _swsetup_render_line_tri( GLcontext *ctx, if (ef[e2]) _swrast_Line( ctx, v2, v0 ); } - if (ctx->_TriangleCaps & DD_FLATSHADE) { + if (ctx->Light.ShadeModel == GL_FLAT) { COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v1->color, c[1]); COPY_CHAN4(v0->specular, s[0]); @@ -128,7 +128,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx, return; } - if (ctx->_TriangleCaps & DD_FLATSHADE) { + if (ctx->Light.ShadeModel == GL_FLAT) { + /* save colors/indexes for v0, v1 vertices */ COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[1], v1->color); COPY_CHAN4(s[0], v0->specular); @@ -136,6 +137,7 @@ static void _swsetup_render_point_tri( GLcontext *ctx, i[0] = v0->index; i[1] = v1->index; + /* copy v2 color/indexes to v0, v1 indexes */ COPY_CHAN4(v0->color, v2->color); COPY_CHAN4(v1->color, v2->color); COPY_CHAN4(v0->specular, v2->specular); @@ -148,7 +150,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx, if (ef[e1]) _swrast_Point( ctx, v1 ); if (ef[e2]) _swrast_Point( ctx, v2 ); - if (ctx->_TriangleCaps & DD_FLATSHADE) { + if (ctx->Light.ShadeModel == GL_FLAT) { + /* restore v0, v1 colores/indexes */ COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v1->color, c[1]); COPY_CHAN4(v0->specular, s[0]); @@ -294,7 +297,8 @@ void _swsetup_choose_trifuncs( GLcontext *ctx ) /* We piggyback the two-sided stencil front/back determination on the * unfilled triangle path. */ - if ((ctx->_TriangleCaps & DD_TRI_UNFILLED) || + if (ctx->Polygon.FrontMode != GL_FILL || + ctx->Polygon.BackMode != GL_FILL || (ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide)) ind |= SS_UNFILLED_BIT; diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c index fa4993434a0..29bad8eefea 100644 --- a/src/mesa/swrast_setup/ss_vb.c +++ b/src/mesa/swrast_setup/ss_vb.c @@ -392,7 +392,7 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) else if (ctx->Texture._EnabledCoordUnits == 1) funcindex |= TEX0; /* only unit 0 is enabled */ - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) + if (NEED_SECONDARY_COLOR(ctx)) funcindex |= SPEC; } else { @@ -418,7 +418,9 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) swsetup->SetupIndex = funcindex; tnl->Driver.Render.BuildVertices = setup_tab[funcindex]; - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { + if (NEED_TWO_SIDED_LIGHTING(ctx) || + ctx->Polygon.FrontMode != GL_FILL || + ctx->Polygon.BackMode != GL_FILL) { tnl->Driver.Render.Interp = interp_extras; tnl->Driver.Render.CopyPV = copy_pv_extras; } diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 28dd1412167..dd06874304b 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -72,7 +72,7 @@ /* Clip and render whole begin/end objects */ /**********************************************************************/ -#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED) +#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) #define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] #define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val @@ -184,7 +184,7 @@ static void clip_elt_triangles( GLcontext *ctx, /* Render whole begin/end objects */ /**********************************************************************/ -#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED) +#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) #define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] #define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val @@ -348,7 +348,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) if (ctx->Visual.rgbMode) { inputs |= VERT_BIT_COLOR0; - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) + if (NEED_SECONDARY_COLOR(ctx)) inputs |= VERT_BIT_COLOR1; if (ctx->Texture._EnabledCoordUnits) { @@ -370,7 +370,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) if (ctx->Fog.Enabled) inputs |= VERT_BIT_FOG; - if (ctx->_TriangleCaps & DD_TRI_UNFILLED) + if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) inputs |= VERT_BIT_EDGEFLAG; if (ctx->RenderMode==GL_FEEDBACK) |