Move away from using the ctx->_TriangleCaps bitfield.
New macros in context.h for testing state: NEED_SECONDARY_COLOR and NEED_TWO_SIDED_LIGHTING.
This commit is contained in:
@@ -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
|
#endif
|
||||||
|
@@ -464,7 +464,7 @@ _swrast_set_aa_triangle_function(GLcontext *ctx)
|
|||||||
ASSERT(ctx->Polygon.SmoothFlag);
|
ASSERT(ctx->Polygon.SmoothFlag);
|
||||||
|
|
||||||
if (ctx->Texture._EnabledCoordUnits != 0) {
|
if (ctx->Texture._EnabledCoordUnits != 0) {
|
||||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
|
if (NEED_SECONDARY_COLOR(ctx)) {
|
||||||
if (ctx->Texture._EnabledCoordUnits > 1) {
|
if (ctx->Texture._EnabledCoordUnits > 1) {
|
||||||
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
|
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
|
||||||
}
|
}
|
||||||
|
@@ -226,8 +226,8 @@ _swrast_validate_triangle( GLcontext *ctx,
|
|||||||
_swrast_validate_derived( ctx );
|
_swrast_validate_derived( ctx );
|
||||||
swrast->choose_triangle( ctx );
|
swrast->choose_triangle( ctx );
|
||||||
|
|
||||||
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
|
if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
|
||||||
ctx->Texture._EnabledUnits == 0) {
|
/* separate specular color, but no texture */
|
||||||
swrast->SpecTriangle = swrast->Triangle;
|
swrast->SpecTriangle = swrast->Triangle;
|
||||||
swrast->Triangle = _swrast_add_spec_terms_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_validate_derived( ctx );
|
||||||
swrast->choose_line( ctx );
|
swrast->choose_line( ctx );
|
||||||
|
|
||||||
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
|
if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
|
||||||
ctx->Texture._EnabledUnits == 0) {
|
|
||||||
swrast->SpecLine = swrast->Line;
|
swrast->SpecLine = swrast->Line;
|
||||||
swrast->Line = _swrast_add_spec_terms_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_validate_derived( ctx );
|
||||||
swrast->choose_point( ctx );
|
swrast->choose_point( ctx );
|
||||||
|
|
||||||
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
|
if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
|
||||||
ctx->Texture._EnabledUnits == 0) {
|
|
||||||
swrast->SpecPoint = swrast->Point;
|
swrast->SpecPoint = swrast->Point;
|
||||||
swrast->Point = _swrast_add_spec_terms_point;
|
swrast->Point = _swrast_add_spec_terms_point;
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "glheader.h"
|
#include "glheader.h"
|
||||||
|
#include "context.h"
|
||||||
#include "colormac.h"
|
#include "colormac.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "s_aaline.h"
|
#include "s_aaline.h"
|
||||||
@@ -304,7 +305,7 @@ _swrast_choose_line( GLcontext *ctx )
|
|||||||
else if (ctx->Texture._EnabledCoordUnits) {
|
else if (ctx->Texture._EnabledCoordUnits) {
|
||||||
/* textured lines */
|
/* textured lines */
|
||||||
if (ctx->Texture._EnabledCoordUnits > 0x1
|
if (ctx->Texture._EnabledCoordUnits > 0x1
|
||||||
|| (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
|
|| NEED_SECONDARY_COLOR(ctx)) {
|
||||||
/* multi-texture and/or separate specular color */
|
/* multi-texture and/or separate specular color */
|
||||||
USE(multitextured_line);
|
USE(multitextured_line);
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ static void _swsetup_render_line_tri( GLcontext *ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->_TriangleCaps & DD_FLATSHADE) {
|
if (ctx->Light.ShadeModel == GL_FLAT) {
|
||||||
COPY_CHAN4(c[0], v0->color);
|
COPY_CHAN4(c[0], v0->color);
|
||||||
COPY_CHAN4(c[1], v1->color);
|
COPY_CHAN4(c[1], v1->color);
|
||||||
COPY_CHAN4(s[0], v0->specular);
|
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 (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(v0->color, c[0]);
|
||||||
COPY_CHAN4(v1->color, c[1]);
|
COPY_CHAN4(v1->color, c[1]);
|
||||||
COPY_CHAN4(v0->specular, s[0]);
|
COPY_CHAN4(v0->specular, s[0]);
|
||||||
@@ -128,7 +128,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
|
|||||||
return;
|
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[0], v0->color);
|
||||||
COPY_CHAN4(c[1], v1->color);
|
COPY_CHAN4(c[1], v1->color);
|
||||||
COPY_CHAN4(s[0], v0->specular);
|
COPY_CHAN4(s[0], v0->specular);
|
||||||
@@ -136,6 +137,7 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
|
|||||||
i[0] = v0->index;
|
i[0] = v0->index;
|
||||||
i[1] = v1->index;
|
i[1] = v1->index;
|
||||||
|
|
||||||
|
/* copy v2 color/indexes to v0, v1 indexes */
|
||||||
COPY_CHAN4(v0->color, v2->color);
|
COPY_CHAN4(v0->color, v2->color);
|
||||||
COPY_CHAN4(v1->color, v2->color);
|
COPY_CHAN4(v1->color, v2->color);
|
||||||
COPY_CHAN4(v0->specular, v2->specular);
|
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[e1]) _swrast_Point( ctx, v1 );
|
||||||
if (ef[e2]) _swrast_Point( ctx, v2 );
|
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(v0->color, c[0]);
|
||||||
COPY_CHAN4(v1->color, c[1]);
|
COPY_CHAN4(v1->color, c[1]);
|
||||||
COPY_CHAN4(v0->specular, s[0]);
|
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
|
/* We piggyback the two-sided stencil front/back determination on the
|
||||||
* unfilled triangle path.
|
* 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))
|
(ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide))
|
||||||
ind |= SS_UNFILLED_BIT;
|
ind |= SS_UNFILLED_BIT;
|
||||||
|
|
||||||
|
@@ -392,7 +392,7 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx)
|
|||||||
else if (ctx->Texture._EnabledCoordUnits == 1)
|
else if (ctx->Texture._EnabledCoordUnits == 1)
|
||||||
funcindex |= TEX0; /* only unit 0 is enabled */
|
funcindex |= TEX0; /* only unit 0 is enabled */
|
||||||
|
|
||||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
if (NEED_SECONDARY_COLOR(ctx))
|
||||||
funcindex |= SPEC;
|
funcindex |= SPEC;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -418,7 +418,9 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx)
|
|||||||
swsetup->SetupIndex = funcindex;
|
swsetup->SetupIndex = funcindex;
|
||||||
tnl->Driver.Render.BuildVertices = setup_tab[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.Interp = interp_extras;
|
||||||
tnl->Driver.Render.CopyPV = copy_pv_extras;
|
tnl->Driver.Render.CopyPV = copy_pv_extras;
|
||||||
}
|
}
|
||||||
|
@@ -72,7 +72,7 @@
|
|||||||
/* Clip and render whole begin/end objects */
|
/* 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_GET(idx) VB->EdgeFlag[idx]
|
||||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
#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 */
|
/* 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_GET(idx) VB->EdgeFlag[idx]
|
||||||
#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
|
#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) {
|
if (ctx->Visual.rgbMode) {
|
||||||
inputs |= VERT_BIT_COLOR0;
|
inputs |= VERT_BIT_COLOR0;
|
||||||
|
|
||||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
if (NEED_SECONDARY_COLOR(ctx))
|
||||||
inputs |= VERT_BIT_COLOR1;
|
inputs |= VERT_BIT_COLOR1;
|
||||||
|
|
||||||
if (ctx->Texture._EnabledCoordUnits) {
|
if (ctx->Texture._EnabledCoordUnits) {
|
||||||
@@ -370,7 +370,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
|
|||||||
if (ctx->Fog.Enabled)
|
if (ctx->Fog.Enabled)
|
||||||
inputs |= VERT_BIT_FOG;
|
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;
|
inputs |= VERT_BIT_EDGEFLAG;
|
||||||
|
|
||||||
if (ctx->RenderMode==GL_FEEDBACK)
|
if (ctx->RenderMode==GL_FEEDBACK)
|
||||||
|
Reference in New Issue
Block a user