diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2000-11-13 20:02:56 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2000-11-13 20:02:56 +0000 |
commit | 1e1aac034c986a08248861363c0baa27dc2ae2d5 (patch) | |
tree | d6aa2dd575eae913007d089928d765be8c867126 /src/mesa/swrast_setup | |
parent | 6b8ae62d6b6a3b06c51628123fc30634cacf9c7c (diff) |
Cleanup of derived state calculation prior to seperating software T&L
into a new directory. Specifically the handling of changes to lighting
lighting space (light in model vs. light in eye) have been revamped.
Moved several derived values used only by swrast into that directory.
Removed direct calls to swrast_flush() from vbrender.c -- pushed into
ctx->Driver.RenderFinish.
Optimized flat-shading case in swrast_setup.
Diffstat (limited to 'src/mesa/swrast_setup')
-rw-r--r-- | src/mesa/swrast_setup/ss_context.c | 5 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_triangle.c | 89 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_tritmp.h | 126 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_vb.c | 12 |
4 files changed, 162 insertions, 70 deletions
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index a10f22cb3f..10942037a3 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -1,4 +1,4 @@ -/* $Id: ss_context.c,v 1.2 2000/11/10 17:45:16 brianp Exp $ */ +/* $Id: ss_context.c,v 1.3 2000/11/13 20:02:58 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -107,10 +107,9 @@ static void _swsetup_invalidate_state( GLcontext *ctx, GLuint new_state ) { SScontext *swsetup = SWSETUP_CONTEXT(ctx); - + swsetup->NewState |= new_state; - if (new_state & _SWSETUP_NEW_RENDERINDEX) { swsetup->Triangle = _swsetup_validate_triangle; swsetup->Line = _swsetup_validate_line; diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index 992bc4f396..ab70f5c97b 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -36,7 +36,8 @@ #define SS_OFFSET_BIT 0x2 #define SS_TWOSIDE_BIT 0x4 #define SS_UNFILLED_BIT 0x10 -#define SS_MAX_TRIFUNC 0x20 +#define SS_COPY_EXTRAS 0x20 /* optimization */ +#define SS_MAX_TRIFUNC 0x40 static triangle_func tri_tab[SS_MAX_TRIFUNC]; static line_func line_tab[SS_MAX_TRIFUNC]; @@ -112,6 +113,70 @@ static quad_func quad_tab[SS_MAX_TRIFUNC]; #define TAG(x) x##_flat_offset_twoside_unfilled #include "ss_tritmp.h" +#define IND (0|SS_COPY_EXTRAS) +#define TAG(x) x##_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_spec +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_offset_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_offset_spec +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_twoside_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_twoside_spec +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_offset_twoside_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_offset_twoside_spec +#include "ss_tritmp.h" + +#define IND (SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_offset_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_offset_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_twoside_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_twoside_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_offset_twoside_unfilled_spec +#include "ss_tritmp.h" + +#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_COPY_EXTRAS) +#define TAG(x) x##_flat_offset_twoside_unfilled_spec +#include "ss_tritmp.h" + void _swsetup_trifuncs_init( GLcontext *ctx ) { @@ -133,6 +198,23 @@ void _swsetup_trifuncs_init( GLcontext *ctx ) init_flat_twoside_unfilled(); init_offset_twoside_unfilled(); init_flat_offset_twoside_unfilled(); + + init_spec(); + init_flat_spec(); + init_offset_spec(); + init_flat_offset_spec(); + init_twoside_spec(); + init_flat_twoside_spec(); + init_offset_twoside_spec(); + init_flat_offset_twoside_spec(); + init_unfilled_spec(); + init_flat_unfilled_spec(); + init_offset_unfilled_spec(); + init_flat_offset_unfilled_spec(); + init_twoside_unfilled_spec(); + init_flat_twoside_unfilled_spec(); + init_offset_twoside_unfilled_spec(); + init_flat_offset_twoside_unfilled_spec(); } @@ -153,6 +235,11 @@ void _swsetup_choose_trifuncs( GLcontext *ctx ) if (ctx->Polygon._Unfilled) ind |= SS_UNFILLED_BIT; + if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) || + ctx->RenderMode == GL_SELECT || + !ctx->Visual.RGBAflag) + ind |= SS_COPY_EXTRAS; + swsetup->Triangle = tri_tab[ind]; swsetup->Line = line_tab[ind]; swsetup->Points = points_tab[ind]; diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h index 570827a1b5..37b5664225 100644 --- a/src/mesa/swrast_setup/ss_tritmp.h +++ b/src/mesa/swrast_setup/ss_tritmp.h @@ -45,16 +45,24 @@ static void TAG(triangle)(GLcontext *ctx, if (IND & (SS_TWOSIDE_BIT | SS_FLAT_BIT)) { SS_COLOR(c[0], v[0]->color); - SS_COLOR(c[1], v[1]->color); - SS_COLOR(c[2], v[2]->color); - SS_SPEC(s[0], v[0]->specular); - SS_SPEC(s[1], v[1]->specular); - SS_SPEC(s[2], v[2]->specular); + if (IND & SS_TWOSIDE_BIT) { + SS_COLOR(c[1], v[1]->color); + SS_COLOR(c[2], v[2]->color); + } + + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(s[0], v[0]->specular); + SS_IND(i[0], v[0]->index); + + if (IND & SS_TWOSIDE_BIT) { + SS_SPEC(s[1], v[1]->specular); + SS_IND(i[1], v[1]->index); - SS_IND(i[0], v[0]->index); - SS_IND(i[1], v[1]->index); - SS_IND(i[2], v[2]->index); + SS_SPEC(s[2], v[2]->specular); + SS_IND(i[2], v[2]->index); + } + } } if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) @@ -82,25 +90,29 @@ static void TAG(triangle)(GLcontext *ctx, SS_COLOR(v[1]->color, vbcolor[pv]); SS_COLOR(v[2]->color, vbcolor[pv]); - SS_SPEC(v[0]->specular, vbspec[pv]); - SS_SPEC(v[1]->specular, vbspec[pv]); - SS_SPEC(v[2]->specular, vbspec[pv]); - - SS_IND(v[0]->index, vbindex[pv]); - SS_IND(v[1]->index, vbindex[pv]); - SS_IND(v[2]->index, vbindex[pv]); + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(v[0]->specular, vbspec[pv]); + SS_SPEC(v[1]->specular, vbspec[pv]); + SS_SPEC(v[2]->specular, vbspec[pv]); + + SS_IND(v[0]->index, vbindex[pv]); + SS_IND(v[1]->index, vbindex[pv]); + SS_IND(v[2]->index, vbindex[pv]); + } } else { SS_COLOR(v[0]->color, vbcolor[e0]); SS_COLOR(v[1]->color, vbcolor[e1]); SS_COLOR(v[2]->color, vbcolor[e2]); - SS_SPEC(v[0]->specular, vbspec[e0]); - SS_SPEC(v[1]->specular, vbspec[e1]); - SS_SPEC(v[2]->specular, vbspec[e2]); + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(v[0]->specular, vbspec[e0]); + SS_SPEC(v[1]->specular, vbspec[e1]); + SS_SPEC(v[2]->specular, vbspec[e2]); - SS_IND(v[0]->index, vbindex[e0]); - SS_IND(v[1]->index, vbindex[e1]); - SS_IND(v[2]->index, vbindex[e2]); + SS_IND(v[0]->index, vbindex[e0]); + SS_IND(v[1]->index, vbindex[e1]); + SS_IND(v[2]->index, vbindex[e2]); + } } } } @@ -125,23 +137,18 @@ static void TAG(triangle)(GLcontext *ctx, } } } - else if(IND & SS_FLAT_BIT) + else if (IND & SS_FLAT_BIT) { GLubyte *color = VB->Color[0]->data[pv]; GLubyte *spec = VB->SecondaryColor[0]->data[pv]; GLuint index = VB->Index[0]->data[pv]; SS_COLOR(v[0]->color, color); - SS_COLOR(v[1]->color, color); - SS_COLOR(v[2]->color, color); - SS_SPEC(v[0]->specular, spec); - SS_SPEC(v[1]->specular, spec); - SS_SPEC(v[2]->specular, spec); - - SS_IND(v[0]->index, index); - SS_IND(v[1]->index, index); - SS_IND(v[2]->index, index); + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(v[0]->specular, spec); + SS_IND(v[0]->index, index); + } } if (mode == GL_POINT) { @@ -181,16 +188,24 @@ static void TAG(triangle)(GLcontext *ctx, if (IND & (SS_FLAT_BIT | SS_TWOSIDE_BIT)) { SS_COLOR(v[0]->color, c[0]); - SS_COLOR(v[1]->color, c[1]); - SS_COLOR(v[2]->color, c[2]); - - SS_SPEC(v[0]->specular, s[0]); - SS_SPEC(v[1]->specular, s[1]); - SS_SPEC(v[2]->specular, s[2]); - SS_IND(v[0]->index, i[0]); - SS_IND(v[1]->index, i[1]); - SS_IND(v[2]->index, i[2]); + if (IND & SS_TWOSIDE_BIT) { + SS_COLOR(v[1]->color, c[1]); + SS_COLOR(v[2]->color, c[2]); + } + + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(v[0]->specular, s[0]); + SS_IND(v[0]->index, i[0]); + + if (IND & SS_TWOSIDE_BIT) { + SS_SPEC(v[1]->specular, s[1]); + SS_IND(v[1]->index, i[1]); + + SS_SPEC(v[2]->specular, s[2]); + SS_IND(v[2]->index, i[2]); + } + } } } @@ -223,35 +238,26 @@ static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv ) GLuint index = VB->Index[0]->data[pv]; SS_COLOR(c[0], vert0->color); - SS_COLOR(c[1], vert1->color); - - SS_SPEC(s[0], vert0->specular); - SS_SPEC(s[1], vert1->specular); - - SS_IND(i[0], vert0->index); - SS_IND(i[1], vert1->index); - SS_COLOR(vert0->color, color); - SS_COLOR(vert1->color, color); - - SS_SPEC(vert0->specular, spec); - SS_SPEC(vert1->specular, spec); - SS_IND(vert0->index, index); - SS_IND(vert1->index, index); + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(s[0], vert0->specular); + SS_SPEC(vert0->specular, spec); + + SS_IND(i[0], vert0->index); + SS_IND(vert0->index, index); + } } _swrast_Line( ctx, vert0, vert1 ); if (IND & SS_FLAT_BIT) { SS_COLOR(vert0->color, c[0]); - SS_COLOR(vert1->color, c[1]); - SS_SPEC(vert0->specular, s[0]); - SS_SPEC(vert1->specular, s[1]); - - SS_IND(vert0->index, i[0]); - SS_IND(vert1->index, i[1]); + if (IND & SS_COPY_EXTRAS) { + SS_SPEC(vert0->specular, s[0]); + SS_IND(vert0->index, i[0]); + } } } diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c index 5e0f4dc84b..15e6049cb5 100644 --- a/src/mesa/swrast_setup/ss_vb.c +++ b/src/mesa/swrast_setup/ss_vb.c @@ -165,16 +165,16 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR || ctx->Fog.ColorSumEnabled) funcindex |= SPEC; - - if (ctx->Point._Attenuated) - funcindex |= EYE; - - if (ctx->Fog.Enabled) - funcindex |= FOG; } else { funcindex = INDEX; } + + if (ctx->Point._Attenuated) + funcindex |= EYE; + + if (ctx->Fog.Enabled) + funcindex |= FOG; } else { /* feedback or section */ |