summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2001-02-16 18:14:41 +0000
committerKeith Whitwell <[email protected]>2001-02-16 18:14:41 +0000
commit46b0988c673b28e072fd0cbf477632a9ab6f9f18 (patch)
tree3463116da957c6f13dcb0b415ca8476640503fc7 /src/mesa/swrast
parent2448fc7deeaa870d879de17158f243f239c05b15 (diff)
Allow swrast to cope (fairly) cleanly with GL_SEPERATE_SPECULAR when
texturing is not enabled, and without requiring the two colors be added externally. As a part of this, collapsed the decomposition of quads into triangles inside swrast to be hardwired into _swrast_Quad; removed s_quads.[ch]. Removed checks on texture state from t_vb_light.c, which was previously required by swrast. Moved the t_dd_ templates to a new directory.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aatriangle.c17
-rw-r--r--src/mesa/swrast/s_context.c100
-rw-r--r--src/mesa/swrast/s_context.h15
-rw-r--r--src/mesa/swrast/s_lines.c24
-rw-r--r--src/mesa/swrast/s_lines.h7
-rw-r--r--src/mesa/swrast/s_points.c16
-rw-r--r--src/mesa/swrast/s_points.h5
-rw-r--r--src/mesa/swrast/s_triangle.c36
-rw-r--r--src/mesa/swrast/s_triangle.h8
9 files changed, 143 insertions, 85 deletions
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index 219798d8c9e..d9a11b0cf66 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.6 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.7 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -405,9 +405,7 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._ReallyEnabled) {
- if (ctx->Light.Enabled &&
- (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
- ctx->Fog.ColorSumEnabled)) {
+ if (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) {
if (swrast->_MultiTextureEnabled) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
@@ -424,13 +422,12 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
}
}
}
+ else if (ctx->Visual.rgbMode) {
+ SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
+ }
else {
- if (ctx->Visual.rgbMode) {
- SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
- }
- else {
- SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
- }
+ SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
}
+
ASSERT(SWRAST_CONTEXT(ctx)->Triangle);
}
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 55966a95a86..b78b9e34ff4 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.12 2001/01/29 21:47:13 brianp Exp $ */
+/* $Id: s_context.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,6 @@
#include "s_points.h"
#include "s_lines.h"
#include "s_triangle.h"
-#include "s_quads.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_texture.h"
@@ -153,31 +152,32 @@ _swrast_update_hint( GLcontext *ctx )
swrast->AllowPixelFog));
}
-#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
- _NEW_POLYGON| \
- _NEW_DEPTH| \
- _NEW_STENCIL| \
- _NEW_COLOR| \
- _NEW_TEXTURE| \
- _NEW_HINT| \
- _SWRAST_NEW_RASTERMASK| \
- _NEW_LIGHT| \
- _NEW_FOG)
-
-#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
- _NEW_LINE| \
- _NEW_TEXTURE| \
- _NEW_LIGHT| \
- _NEW_FOG| \
- _NEW_DEPTH)
-
-#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
- _NEW_POINT | \
- _NEW_TEXTURE | \
- _NEW_LIGHT | \
- _NEW_FOG)
-
-#define _SWRAST_NEW_QUAD 0
+#define _SWRAST_NEW_TRIANGLE (_NEW_RENDERMODE| \
+ _NEW_POLYGON| \
+ _NEW_DEPTH| \
+ _NEW_STENCIL| \
+ _NEW_COLOR| \
+ _NEW_TEXTURE| \
+ _NEW_HINT| \
+ _SWRAST_NEW_RASTERMASK| \
+ _NEW_LIGHT| \
+ _NEW_FOG | \
+ _DD_NEW_SEPERATE_SPECULAR)
+
+#define _SWRAST_NEW_LINE (_NEW_RENDERMODE| \
+ _NEW_LINE| \
+ _NEW_TEXTURE| \
+ _NEW_LIGHT| \
+ _NEW_FOG| \
+ _NEW_DEPTH | \
+ _DD_NEW_SEPERATE_SPECULAR)
+
+#define _SWRAST_NEW_POINT (_NEW_RENDERMODE | \
+ _NEW_POINT | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_FOG | \
+ _DD_NEW_SEPERATE_SPECULAR)
#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
@@ -189,19 +189,6 @@ _swrast_update_hint( GLcontext *ctx )
* after a state change.
*/
static void
-_swrast_validate_quad( GLcontext *ctx,
- const SWvertex *v0, const SWvertex *v1,
- const SWvertex *v2, const SWvertex *v3 )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- _swrast_validate_derived( ctx );
- swrast->choose_quad( ctx );
-
- swrast->Quad( ctx, v0, v1, v2, v3 );
-}
-
-static void
_swrast_validate_triangle( GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
@@ -212,6 +199,12 @@ _swrast_validate_triangle( GLcontext *ctx,
_swrast_validate_derived( ctx );
swrast->choose_triangle( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecTriangle = swrast->Triangle;
+ swrast->Triangle = _swrast_add_spec_terms_triangle;
+ }
+
swrast->Triangle( ctx, v0, v1, v2 );
}
@@ -223,6 +216,13 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
_swrast_validate_derived( ctx );
swrast->choose_line( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecLine = swrast->Line;
+ swrast->Line = _swrast_add_spec_terms_line;
+ }
+
+
swrast->Line( ctx, v0, v1 );
}
@@ -234,6 +234,12 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
_swrast_validate_derived( ctx );
swrast->choose_point( ctx );
+ if ((ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) &&
+ !ctx->Texture._ReallyEnabled) {
+ swrast->SpecPoint = swrast->Point;
+ swrast->Point = _swrast_add_spec_terms_point;
+ }
+
swrast->Point( ctx, v0 );
}
@@ -302,9 +308,6 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
if (new_state & swrast->invalidate_point)
swrast->Point = _swrast_validate_point;
- if (new_state & swrast->invalidate_quad)
- swrast->Quad = _swrast_validate_quad;
-
if (new_state & _SWRAST_NEW_BLEND_FUNC)
swrast->BlendFunc = _swrast_validate_blend_func;
@@ -350,12 +353,8 @@ _swrast_Quad( GLcontext *ctx,
const SWvertex *v0, const SWvertex *v1,
const SWvertex *v2, const SWvertex *v3 )
{
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-/* _swrast_print_vertex( ctx, v0 ); */
-/* _swrast_print_vertex( ctx, v1 ); */
-/* _swrast_print_vertex( ctx, v2 ); */
-/* _swrast_print_vertex( ctx, v3 ); */
- SWRAST_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 );
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v2, v3 );
}
void
@@ -432,17 +431,14 @@ _swrast_CreateContext( GLcontext *ctx )
swrast->choose_point = _swrast_choose_point;
swrast->choose_line = _swrast_choose_line;
swrast->choose_triangle = _swrast_choose_triangle;
- swrast->choose_quad = _swrast_choose_quad;
swrast->invalidate_point = _SWRAST_NEW_POINT;
swrast->invalidate_line = _SWRAST_NEW_LINE;
swrast->invalidate_triangle = _SWRAST_NEW_TRIANGLE;
- swrast->invalidate_quad = _SWRAST_NEW_QUAD;
swrast->Point = _swrast_validate_point;
swrast->Line = _swrast_validate_line;
swrast->Triangle = _swrast_validate_triangle;
- swrast->Quad = _swrast_validate_quad;
swrast->InvalidateState = _swrast_sleep;
swrast->BlendFunc = _swrast_validate_blend_func;
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 86b71ecc459..6603b56e7df 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -63,10 +63,6 @@ typedef void (*swrast_line_func)( GLcontext *ctx,
typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
const SWvertex *, const SWvertex *);
-typedef void (*swrast_quad_func)( GLcontext *ctx,
- const SWvertex *, const SWvertex *,
- const SWvertex *, const SWvertex *);
-
/*
@@ -136,12 +132,10 @@ typedef struct
void (*choose_point)( GLcontext * );
void (*choose_line)( GLcontext * );
void (*choose_triangle)( GLcontext * );
- void (*choose_quad)( GLcontext * );
GLuint invalidate_point;
GLuint invalidate_line;
GLuint invalidate_triangle;
- GLuint invalidate_quad;
/* Function pointers for dispatch behind public entrypoints.
@@ -151,7 +145,14 @@ typedef struct
swrast_point_func Point;
swrast_line_func Line;
swrast_tri_func Triangle;
- swrast_quad_func Quad;
+
+ /* Placeholders for when seperate specular (or secondary color) is
+ * enabled but texturing is not.
+ */
+ swrast_point_func SpecPoint;
+ swrast_line_func SpecLine;
+ swrast_tri_func SpecTriangle;
+
/* Internal hooks, kept uptodate by the same mechanism as above.
*/
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index d448bd59e4e..af62dba3d99 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,4 +1,4 @@
-/* $Id: s_lines.c,v 1.10 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_lines.c,v 1.11 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "macros.h"
#include "mmath.h"
#include "s_aaline.h"
@@ -909,6 +910,22 @@ static void flat_multitextured_line( GLcontext *ctx,
}
+void _swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ SWvertex *ncv1 = (SWvertex *)v1;
+ GLchan c[2][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ ACC_3V( ncv1->color, ncv1->specular );
+ SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+}
+
#ifdef DEBUG
extern void
@@ -978,9 +995,8 @@ _swrast_choose_line( GLcontext *ctx )
ASSERT(swrast->Triangle);
}
else if (ctx->Texture._ReallyEnabled) {
- if (swrast->_MultiTextureEnabled
- || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR
- || ctx->Fog.ColorSumEnabled) {
+ if (swrast->_MultiTextureEnabled ||
+ (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR)) {
/* multi-texture and/or separate specular color */
if (ctx->Light.ShadeModel==GL_SMOOTH)
swrast->Line = smooth_multitextured_line;
diff --git a/src/mesa/swrast/s_lines.h b/src/mesa/swrast/s_lines.h
index ea660f69f05..110f536c488 100644
--- a/src/mesa/swrast/s_lines.h
+++ b/src/mesa/swrast/s_lines.h
@@ -1,4 +1,4 @@
-/* $Id: s_lines.h,v 1.3 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_lines.h,v 1.4 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,5 +33,10 @@
void
_swrast_choose_line( GLcontext *ctx );
+void
+_swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 );
+
#endif
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index bb5de30975b..85001291e4d 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,4 +1,4 @@
-/* $Id: s_points.c,v 1.12 2001/01/23 23:39:37 brianp Exp $ */
+/* $Id: s_points.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "context.h"
#include "macros.h"
#include "mmath.h"
@@ -158,6 +159,18 @@
+void _swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ GLchan c[1][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ SWRAST_CONTEXT(ctx)->SpecPoint( ctx, ncv0 );
+ COPY_CHAN4( ncv0->color, c[0] );
+}
+
+
/* record the current point function name */
#ifdef DEBUG
@@ -263,3 +276,4 @@ _swrast_choose_point( GLcontext *ctx )
USE(gl_select_point);
}
}
+
diff --git a/src/mesa/swrast/s_points.h b/src/mesa/swrast/s_points.h
index ead900f0165..1dd78cb8645 100644
--- a/src/mesa/swrast/s_points.h
+++ b/src/mesa/swrast/s_points.h
@@ -1,4 +1,4 @@
-/* $Id: s_points.h,v 1.3 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_points.h,v 1.4 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,5 +33,8 @@
void
_swrast_choose_point( GLcontext *ctx );
+void
+_swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 );
#endif
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9f3f2fe54b1..411c241684a 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.12 2001/02/07 18:44:55 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.13 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,6 +34,7 @@
#include "glheader.h"
#include "context.h"
+#include "colormac.h"
#include "macros.h"
#include "mem.h"
#include "mmath.h"
@@ -2232,6 +2233,27 @@ static void occlusion_zless_triangle( GLcontext *ctx,
+void _swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */
+ SWvertex *ncv1 = (SWvertex *)v1;
+ SWvertex *ncv2 = (SWvertex *)v2;
+ GLchan c[3][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ COPY_CHAN4( c[2], ncv2->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ ACC_3V( ncv1->color, ncv1->specular );
+ ACC_3V( ncv2->color, ncv2->specular );
+ SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 );
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+ COPY_CHAN4( ncv2->color, c[2] );
+}
+
#if 0
@@ -2358,9 +2380,7 @@ _swrast_choose_triangle( GLcontext *ctx )
swrast->Triangle = lambda_multitextured_triangle;
dputs("lambda_multitextured_triangle");
}
- else if ((ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
- || ctx->Fog.ColorSumEnabled) {
+ else if (ctx->_TriangleCaps & DD_SEPERATE_SPECULAR) {
/* separate specular color interpolation */
if (needLambda) {
swrast->Triangle = lambda_textured_spec_triangle;
@@ -2387,8 +2407,8 @@ _swrast_choose_triangle( GLcontext *ctx )
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
- dputs("smooth_rgba_triangle");
- swrast->Triangle = smooth_rgba_triangle;
+ dputs("smooth_rgba_triangle");
+ swrast->Triangle = smooth_rgba_triangle;
}
else {
dputs("smooth_ci_triangle");
@@ -2398,8 +2418,8 @@ _swrast_choose_triangle( GLcontext *ctx )
else {
/* flat shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
- dputs("flat_rgba_triangle");
- swrast->Triangle = flat_rgba_triangle;
+ dputs("flat_rgba_triangle");
+ swrast->Triangle = flat_rgba_triangle;
}
else {
dputs("flat_ci_triangle");
diff --git a/src/mesa/swrast/s_triangle.h b/src/mesa/swrast/s_triangle.h
index c0064e8d46e..318b6a66716 100644
--- a/src/mesa/swrast/s_triangle.h
+++ b/src/mesa/swrast/s_triangle.h
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.h,v 1.4 2000/11/22 07:32:18 joukj Exp $ */
+/* $Id: s_triangle.h,v 1.5 2001/02/16 18:14:41 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,6 +45,12 @@ GLboolean gl_cull_triangle( GLcontext *ctx,
void
_swrast_choose_triangle( GLcontext *ctx );
+void
+_swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 );
+
#endif