summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/glide/fxdd.c7
-rw-r--r--src/mesa/drivers/glide/fxdrv.h2
-rw-r--r--src/mesa/drivers/glide/fxtris.c63
-rw-r--r--src/mesa/drivers/glide/fxvb.c66
-rw-r--r--src/mesa/drivers/glide/fxvbtmp.h2
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c5
-rw-r--r--src/mesa/drivers/x11/xm_line.c38
-rw-r--r--src/mesa/drivers/x11/xm_tri.c78
-rw-r--r--src/mesa/main/api_validate.c3
-rw-r--r--src/mesa/main/buffers.c5
-rw-r--r--src/mesa/main/convolve.c4
-rw-r--r--src/mesa/main/dd.h27
-rw-r--r--src/mesa/main/fog.c14
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/swrast/s_aalinetemp.h18
-rw-r--r--src/mesa/swrast/s_aatritemp.h20
-rw-r--r--src/mesa/swrast/s_feedback.c12
-rw-r--r--src/mesa/swrast/s_triangle.c56
-rw-r--r--src/mesa/swrast/swrast.h4
-rw-r--r--src/mesa/swrast_setup/ss_context.c27
-rw-r--r--src/mesa/swrast_setup/ss_context.h6
-rw-r--r--src/mesa/swrast_setup/ss_triangle.c101
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h184
-rw-r--r--src/mesa/swrast_setup/swrast_setup.h13
-rw-r--r--src/mesa/tnl/t_array_import.c14
-rw-r--r--src/mesa/tnl/t_context.c7
-rw-r--r--src/mesa/tnl/t_context.h17
-rw-r--r--src/mesa/tnl/t_imm_api.c2
-rw-r--r--src/mesa/tnl/t_imm_exec.c13
-rw-r--r--src/mesa/tnl/t_pipeline.h8
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h558
-rw-r--r--src/mesa/tnl/t_vb_render.c416
-rw-r--r--src/mesa/tnl/t_vb_rendertmp.h86
33 files changed, 779 insertions, 1100 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 306e0be3b9..b36cbee47c 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -651,8 +651,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
}
static const struct gl_pipeline_stage *fx_pipeline[] = {
- &_tnl_update_material_stage,
- /* TODO: Add the fastpath here */
+ &_tnl_update_material_stage, /* TODO: Add the fastpath here */
&_tnl_vertex_transform_stage,
&_tnl_normal_transform_stage,
&_tnl_lighting_stage,
@@ -660,8 +659,7 @@ static const struct gl_pipeline_stage *fx_pipeline[] = {
&_tnl_texgen_stage,
&_tnl_texture_transform_stage,
&_tnl_point_attenuation_stage,
- &fx_render_stage, /* ADD: render simple unclipped vb's */
- &_tnl_render_stage, /* KEEP: the old render stage for fallbacks */
+ &_tnl_render_stage,
0,
};
@@ -680,7 +678,6 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa )
if (firsttime) {
fxDDSetupInit();
fxDDTrifuncInit();
-/* fxDDFastPathInit(); */
firsttime = 0;
}
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 38ce0ce2da..cefd6d0e1a 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -509,7 +509,7 @@ struct tfxMesaContext {
GLuint size;
};
-typedef void (*tfxSetupFunc)(GLcontext *ctx, GLuint, GLuint, GLuint);
+typedef void (*tfxSetupFunc)(GLcontext *ctx, GLuint, GLuint );
extern GrHwConfiguration glbHWConfig;
extern int glbCurrentBoard;
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index 7d887133b6..11072a2601 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -11,6 +11,7 @@
#include "swrast_setup/swrast_setup.h"
#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
#include "fxdrv.h"
#include "fxglidew.h"
@@ -469,6 +470,56 @@ fx_null_tri( GLcontext *ctx,
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+/* Vertices, no clipping.
+ */
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ grDrawPoint( &v[ELT(start)].v );
+
+#define RENDER_LINE( i1, i ) \
+ grDrawLine( &v[i1].v, &v[i].v )
+
+#define RENDER_TRI( i2, i1, i ) \
+ grDrawTriangle( &v[i2].v, &v[i1].v, &v[i].v )
+
+#define RENDER_QUAD( i3, i2, i1, i ) \
+ grDrawTriangle( &v[i3].v, &v[i2].v, &v[i].v ); \
+ grDrawTriangle( &v[i2].v, &v[i1].v, &v[i].v )
+
+#define TAG(x) fx_##x##_verts
+#define LOCAL_VARS \
+ fxVertex *v = FX_CONTEXT(ctx)->verts;
+
+/* Verts, no clipping.
+ */
+#define ELT(x) x
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#include "tnl/t_vb_rendertmp.h"
+
+
+/* Elts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#undef LOCAL_VARS
+#define TAG(x) fx_##x##_elts
+#define ELT(x) elt[x]
+#define LOCAL_VARS \
+ fxVertex *v = FX_CONTEXT(ctx)->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+#include "tnl/t_vb_rendertmp.h"
+
+
+
+
/* Setup the Point, Line, Triangle and Quad functions based on the
* current rendering state. Wherever possible, use the hardware to
* render the primitive. Otherwise, fallback to software rendering.
@@ -487,6 +538,8 @@ void fxDDChooseRenderState( GLcontext *ctx )
ctx->Driver.LineFunc = _swsetup_Line;
ctx->Driver.TriangleFunc = _swsetup_Triangle;
ctx->Driver.QuadFunc = _swsetup_Quad;
+ ctx->Driver.RenderTabVerts = _tnl_render_tab_verts;
+ ctx->Driver.RenderTabElts = _tnl_render_tab_elts;
fxMesa->render_index = FX_FALLBACK_BIT;
return;
@@ -549,9 +602,19 @@ void fxDDChooseRenderState( GLcontext *ctx )
ctx->Driver.TriangleFunc = rast_tab[index].triangle;
ctx->Driver.QuadFunc = rast_tab[index].quad;
fxMesa->render_index = index;
+
+ if (fxMesa->render_index == 0) {
+ ctx->Driver.RenderTabVerts = fx_render_tab_verts;
+ ctx->Driver.RenderTabElts = fx_render_tab_elts;
+ } else {
+ ctx->Driver.RenderTabVerts = _tnl_render_tab_verts;
+ ctx->Driver.RenderTabElts = _tnl_render_tab_elts;
+ }
}
+
+
#else
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index 22128e61f6..3138d59649 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -238,10 +238,10 @@ static tfxSetupFunc setupfuncs[MAX_SETUP];
static void
-fxsetup_invalid( GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs )
+fxsetup_invalid( GLcontext *ctx, GLuint start, GLuint end )
{
fprintf(stderr, "fxMesa: invalid setup function\n");
- (void) (ctx && start && end && newinputs);
+ (void) (ctx && start && end);
}
@@ -334,43 +334,49 @@ void fx_BuildProjVerts( GLcontext *ctx, GLuint start, GLuint count,
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLuint ind = fxMesa->setup_gone;
- fxMesa->setup_gone = 0;
+ if (newinputs == ~0) {
+ /* build interpolated vertices */
+ setupfuncs[fxMesa->setupindex]( ctx, start, count );
+ } else {
+ GLuint ind = fxMesa->setup_gone;
+ fxMesa->setup_gone = 0;
- if (newinputs & VERT_CLIP)
- ind = fxMesa->setupindex; /* clipmask has changed - invalidated all */
- else {
- if (newinputs & VERT_TEX0)
- ind |= fxMesa->tex_dest[0];
+ if (newinputs & VERT_CLIP)
+ ind = fxMesa->setupindex; /* clipmask has potentially changed */
+ else {
+ if (newinputs & VERT_TEX0)
+ ind |= fxMesa->tex_dest[0];
- if (newinputs & VERT_TEX1)
- ind |= fxMesa->tex_dest[1];
-
- if (newinputs & VERT_RGBA)
- ind |= SETUP_RGBA;
-
- ind &= fxMesa->setupindex;
- }
+ if (newinputs & VERT_TEX1)
+ ind |= fxMesa->tex_dest[1];
- if (0) {
- _tnl_print_vert_flags("newinputs", newinputs);
- fxPrintSetupFlags("setup function", ind);
- }
+ if (newinputs & VERT_RGBA)
+ ind |= SETUP_RGBA;
- if (fxMesa->new_state)
- fxSetupFXUnits( ctx );
+ ind &= fxMesa->setupindex;
+ }
- if (VB->importable_data)
- VB->import_data( ctx, VB->importable_data & newinputs,
- (VB->ClipOrMask
- ? VEC_NOT_WRITEABLE|VEC_BAD_STRIDE
- : VEC_BAD_STRIDE));
+ if (0) {
+ _tnl_print_vert_flags("newinputs", newinputs);
+ fxPrintSetupFlags("setup function", ind);
+ }
- setupfuncs[ind]( ctx, start, count, newinputs );
+ if (ind) {
+ if (fxMesa->new_state)
+ fxSetupFXUnits( ctx );
+
+ if (VB->importable_data)
+ VB->import_data( ctx, VB->importable_data & newinputs,
+ (VB->ClipOrMask
+ ? VEC_NOT_WRITEABLE|VEC_BAD_STRIDE
+ : VEC_BAD_STRIDE));
+
+ setupfuncs[ind]( ctx, start, count );
+ }
+ }
}
-
void fxAllocVB( GLcontext *ctx )
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h
index af21fc40af..0133758295 100644
--- a/src/mesa/drivers/glide/fxvbtmp.h
+++ b/src/mesa/drivers/glide/fxvbtmp.h
@@ -27,7 +27,7 @@
*/
-static void NAME(GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs)
+static void NAME(GLcontext *ctx, GLuint start, GLuint end )
{
fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
fxVertex *verts = fxMesa->verts;
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 6148100e22..f26ed3867e 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.36 2001/01/02 22:02:52 brianp Exp $ */
+/* $Id: osmesa.c,v 1.37 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -55,6 +55,7 @@
#include "swrast/s_lines.h"
#include "swrast/s_triangle.h"
#include "tnl/tnl.h"
+#include "array_cache/acache.h"
#endif
@@ -313,6 +314,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
GLcontext *ctx = &osmesa->gl_ctx;
_swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
@@ -1752,5 +1754,6 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state )
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
}
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index c76de401c8..e9bbfbca41 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -1,4 +1,4 @@
-/* $Id: xm_line.c,v 1.14 2001/01/02 22:02:52 brianp Exp $ */
+/* $Id: xm_line.c,v 1.15 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -127,7 +127,7 @@ static void flat_TRUECOLOR_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
XMesaImage *img = xmesa->xm_buffer->backimage;
unsigned long pixel;
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
@@ -148,7 +148,7 @@ static void flat_8A8B8G8R_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
@@ -168,7 +168,7 @@ static void flat_8R8G8B_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLuint
@@ -188,7 +188,7 @@ static void flat_8R8G8B24_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -211,7 +211,7 @@ static void flat_5R6G5B_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define PIXEL_TYPE GLushort
@@ -231,7 +231,7 @@ static void flat_DITHER_5R6G5B_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -251,7 +251,7 @@ static void flat_DITHER8_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
DITHER_SETUP;
@@ -273,7 +273,7 @@ static void flat_LOOKUP8_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLubyte pixel;
LOOKUP_SETUP;
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
@@ -295,7 +295,7 @@ static void flat_HPCR_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_XY 1
@@ -317,7 +317,7 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
XMesaImage *img = xmesa->xm_buffer->backimage;
unsigned long pixel;
PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
@@ -343,7 +343,7 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -369,7 +369,7 @@ static void flat_8R8G8B_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -395,7 +395,7 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@@ -422,7 +422,7 @@ static void flat_5R6G5B_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
@@ -447,7 +447,7 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
@@ -471,7 +471,7 @@ static void flat_DITHER8_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
DITHER_SETUP;
@@ -498,7 +498,7 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLubyte pixel;
LOOKUP_SETUP;
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
@@ -526,7 +526,7 @@ static void flat_HPCR_z_line( GLcontext *ctx,
const SWvertex *vert0, const SWvertex *vert1 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = vert0->color;
+ const GLubyte *color = vert1->color;
GLint r = color[0], g = color[1], b = color[2];
#define INTERP_XY 1
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index dbd252c50c..12f1f49a48 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -1,4 +1,4 @@
-/* $Id: xm_tri.c,v 1.15 2001/01/02 22:02:52 brianp Exp $ */
+/* $Id: xm_tri.c,v 1.16 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -451,7 +451,7 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
unsigned long pixel; \
- PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -485,8 +485,8 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_8B8G8R( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, len = RIGHT-LEFT; \
@@ -519,8 +519,8 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, len = RIGHT-LEFT; \
@@ -547,7 +547,7 @@ static void flat_8R8G8B24_z_triangle( GLcontext *ctx,
const SWvertex *v2 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = v0->color;
+ const GLubyte *color = v2->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
@@ -593,8 +593,8 @@ static void flat_TRUEDITHER_z_triangle( GLcontext *ctx,
GLdepth z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
- v0->color[1], v0->color[2] ); \
+ PACK_TRUEDITHER( p, xx, yy, v2->color[0], \
+ v2->color[1], v2->color[2] ); \
XMesaPutPixel( img, xx, yy, p ); \
zRow[i] = z; \
} \
@@ -620,8 +620,8 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_5R6G5B( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, len = RIGHT-LEFT; \
@@ -648,7 +648,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
const SWvertex *v2 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = v0->color;
+ const GLubyte *color = v2->color;
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
@@ -688,7 +688,7 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -721,7 +721,7 @@ static void flat_DITHER_z_triangle( GLcontext *ctx,
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -757,9 +757,9 @@ static void flat_HPCR_z_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- GLubyte r = v0->color[0]; \
- GLubyte g = v0->color[1]; \
- GLubyte b = v0->color[2];
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
@@ -793,9 +793,9 @@ static void flat_LOOKUP8_z_triangle( GLcontext *ctx,
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
LOOKUP_SETUP; \
- GLubyte r = v0->color[0]; \
- GLubyte g = v0->color[1]; \
- GLubyte b = v0->color[2]; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
GLubyte p = LOOKUP(r,g,b);
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1128,7 +1128,7 @@ static void flat_TRUECOLOR_triangle( GLcontext *ctx,
XMesaImage *img = xmesa->xm_buffer->backimage;
#define SETUP_CODE \
unsigned long pixel; \
- PACK_TRUECOLOR(pixel, v0->color[0], v0->color[1], v0->color[2]);
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1154,8 +1154,8 @@ static void flat_8A8B8G8R_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_8B8G8R( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_8B8G8R( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint xx; \
@@ -1181,8 +1181,8 @@ static void flat_8R8G8B_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_8R8G8B( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint xx; \
@@ -1204,7 +1204,7 @@ static void flat_8R8G8B24_triangle( GLcontext *ctx,
const SWvertex *v2 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = v0->color;
+ const GLubyte *color = v2->color;
#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -1237,8 +1237,8 @@ static void flat_TRUEDITHER_triangle( GLcontext *ctx,
GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
for (xx=LEFT;xx<RIGHT;xx++) { \
unsigned long p; \
- PACK_TRUEDITHER( p, xx, yy, v0->color[0], \
- v0->color[1], v0->color[2] ); \
+ PACK_TRUEDITHER( p, xx, yy, v2->color[0], \
+ v2->color[1], v2->color[2] ); \
XMesaPutPixel( img, xx, yy, p ); \
} \
}
@@ -1260,8 +1260,8 @@ static void flat_5R6G5B_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- unsigned long p = PACK_5R6G5B( v0->color[0], \
- v0->color[1], v0->color[2] );
+ unsigned long p = PACK_5R6G5B( v2->color[0], \
+ v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint xx; \
@@ -1283,7 +1283,7 @@ static void flat_DITHER_5R6G5B_triangle( GLcontext *ctx,
const SWvertex *v2 )
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- const GLubyte *color = v0->color;
+ const GLubyte *color = v2->color;
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -1313,7 +1313,7 @@ static void flat_DITHER8_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1339,7 +1339,7 @@ static void flat_DITHER_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
#define SETUP_CODE \
- FLAT_DITHER_SETUP( v0->color[0], v0->color[1], v0->color[2] );
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1367,9 +1367,9 @@ static void flat_HPCR_triangle( GLcontext *ctx,
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
- GLubyte r = v0->color[0]; \
- GLubyte g = v0->color[1]; \
- GLubyte b = v0->color[2];
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint xx, yy = FLIP(xmesa->xm_buffer, Y); \
@@ -1396,9 +1396,9 @@ static void flat_LOOKUP8_triangle( GLcontext *ctx,
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define SETUP_CODE \
LOOKUP_SETUP; \
- GLubyte r = v0->color[0]; \
- GLubyte g = v0->color[1]; \
- GLubyte b = v0->color[2]; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
GLubyte p = LOOKUP(r,g,b);
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 2706c705fc..9f265381ae 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -1,5 +1,5 @@
-/* $Id: api_validate.c,v 1.2 2001/01/02 21:40:57 brianp Exp $ */
+/* $Id: api_validate.c,v 1.3 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "mtypes.h"
#include "state.h"
+
GLboolean
_mesa_validate_DrawElements(GLcontext *ctx,
GLenum mode, GLsizei count, GLenum type,
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index da1e6125c9..c67c8e865e 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.21 2000/12/26 05:09:27 keithw Exp $ */
+/* $Id: buffers.c,v 1.22 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -373,8 +373,9 @@ void
_mesa_ResizeBuffersMESA( void )
{
GLcontext *ctx = _mesa_get_current_context();
-
GLuint buf_width, buf_height;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
+
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glResizeBuffersMESA\n");
diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c
index 24bdd9c4b0..1a32acb41e 100644
--- a/src/mesa/main/convolve.c
+++ b/src/mesa/main/convolve.c
@@ -1,4 +1,4 @@
-/* $Id: convolve.c,v 1.17 2000/12/26 05:09:28 keithw Exp $ */
+/* $Id: convolve.c,v 1.18 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -268,7 +268,7 @@ _mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
{
GET_CURRENT_CONTEXT(ctx);
GLuint c;
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
case GL_CONVOLUTION_1D:
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index cfac5f2ab2..9c600783dc 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.44 2000/12/26 05:09:28 keithw Exp $ */
+/* $Id: dd.h,v 1.45 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -126,13 +126,16 @@ struct gl_pixelstore_attrib;
*/
typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
-typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv );
+typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
typedef void (*triangle_func)( GLcontext *ctx,
- GLuint v1, GLuint v2, GLuint v3, GLuint pv );
+ GLuint v1, GLuint v2, GLuint v3 );
typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
- GLuint v3, GLuint v4, GLuint pv );
+ GLuint v3, GLuint v4 );
+
+typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint flags );
/*
@@ -758,19 +761,21 @@ struct dd_function_table {
triangle_func TriangleFunc;
quad_func QuadFunc;
+ render_func *RenderTabVerts;
+ render_func *RenderTabElts;
+
void (*ResetLineStipple)( GLcontext *ctx );
-
void (*BuildProjectedVertices)( GLcontext *ctx,
GLuint start, GLuint end,
GLuint new_inputs);
- /* This function, if not NULL, is called whenever new vertices are
- * required for rendering. The vertices in question are those n
- * such that start <= n < end. The new_inputs parameter indicates
- * those fields of the vertex which need to be updated, if only a
- * partial repair of the vertex is required.
+ /* This function is called whenever new vertices are required for
+ * rendering. The vertices in question are those n such that start
+ * <= n < end. The new_inputs parameter indicates those fields of
+ * the vertex which need to be updated, if only a partial repair of
+ * the vertex is required.
*
- * This function is called only from _tnl_render_stage in tnl/t_render.c.
+ * This function is called only from _tnl_render_stage in tnl/t_render.c.
*/
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 2a225d4d87..c0e4b4a907 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -1,4 +1,4 @@
-/* $Id: fog.c,v 1.31 2000/12/26 05:09:28 keithw Exp $ */
+/* $Id: fog.c,v 1.32 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -89,8 +89,6 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
switch (pname) {
case GL_FOG_MODE:
m = (GLenum) (GLint) *params;
- if (ctx->Fog.Mode == m)
- return;
switch (m) {
case GL_LINEAR:
case GL_EXP:
@@ -100,6 +98,8 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
gl_error( ctx, GL_INVALID_ENUM, "glFog" );
return;
}
+ if (ctx->Fog.Mode == m)
+ return;
FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.Mode = m;
break;
@@ -132,7 +132,7 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
ctx->Fog.Index = *params;
break;
case GL_FOG_COLOR:
- if (TEST_EQ_4V(ctx->Fog.Color, params))
+ if (TEST_EQ_4V(ctx->Fog.Color, params))
return;
FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.Color[0] = params[0];
@@ -142,12 +142,12 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
break;
case GL_FOG_COORDINATE_SOURCE_EXT: {
GLenum p = (GLenum)(GLint) *params;
- if (ctx->Fog.FogCoordinateSource == p)
- return;
if (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT) {
gl_error( ctx, GL_INVALID_ENUM, "glFog" );
return;
}
+ if (ctx->Fog.FogCoordinateSource == p)
+ return;
FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.FogCoordinateSource = p;
break;
@@ -160,8 +160,6 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
if (ctx->Driver.Fogfv) {
(*ctx->Driver.Fogfv)( ctx, pname, params );
}
-
- ctx->NewState |= _NEW_FOG;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7992b00304..913c2f2fb5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.9 2001/01/02 22:02:51 brianp Exp $ */
+/* $Id: mtypes.h,v 1.10 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,7 +35,6 @@
#include "glthread.h"
#include "math/m_matrix.h" /* GLmatrix */
-#include "math/m_translate.h" /* trans_XXX_func */
#if defined(MESA_TRACE)
#include "Trace/tr_context.h"
diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h
index d16fe2c129..f36c1f433f 100644
--- a/src/mesa/swrast/s_aalinetemp.h
+++ b/src/mesa/swrast/s_aalinetemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_aalinetemp.h,v 1.3 2001/01/04 15:32:32 brianp Exp $ */
+/* $Id: s_aalinetemp.h,v 1.4 2001/01/05 02:26:48 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -195,10 +195,10 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
v0->color[ACOMP], v1->color[ACOMP], line.aPlane);
}
else {
- constant_plane(v0->color[RCOMP], line.rPlane);
- constant_plane(v0->color[GCOMP], line.gPlane);
- constant_plane(v0->color[BCOMP], line.bPlane);
- constant_plane(v0->color[ACOMP], line.aPlane);
+ constant_plane(v1->color[RCOMP], line.rPlane);
+ constant_plane(v1->color[GCOMP], line.gPlane);
+ constant_plane(v1->color[BCOMP], line.bPlane);
+ constant_plane(v1->color[ACOMP], line.aPlane);
}
#endif
#ifdef DO_SPEC
@@ -211,9 +211,9 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
v0->specular[BCOMP], v1->specular[BCOMP], line.sbPlane);
}
else {
- constant_plane(v0->specular[RCOMP], line.srPlane);
- constant_plane(v0->specular[GCOMP], line.sgPlane);
- constant_plane(v0->specular[BCOMP], line.sbPlane);
+ constant_plane(v1->specular[RCOMP], line.srPlane);
+ constant_plane(v1->specular[GCOMP], line.sgPlane);
+ constant_plane(v1->specular[BCOMP], line.sbPlane);
}
#endif
#ifdef DO_INDEX
@@ -222,7 +222,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
v0->index, v1->index, line.iPlane);
}
else {
- constant_plane(v0->index, line.iPlane);
+ constant_plane(v1->index, line.iPlane);
}
#endif
#ifdef DO_TEX
diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h
index 247c7ac85a..c50680c007 100644
--- a/src/mesa/swrast/s_aatritemp.h
+++ b/src/mesa/swrast/s_aatritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_aatritemp.h,v 1.4 2000/11/19 23:10:26 brianp Exp $ */
+/* $Id: s_aatritemp.h,v 1.5 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -151,10 +151,10 @@
compute_plane(p0, p1, p2, v0->color[3], v1->color[3], v2->color[3], aPlane);
}
else {
- constant_plane(v0->color[RCOMP], rPlane);
- constant_plane(v0->color[GCOMP], gPlane);
- constant_plane(v0->color[BCOMP], bPlane);
- constant_plane(v0->color[ACOMP], aPlane);
+ constant_plane(v2->color[RCOMP], rPlane);
+ constant_plane(v2->color[GCOMP], gPlane);
+ constant_plane(v2->color[BCOMP], bPlane);
+ constant_plane(v2->color[ACOMP], aPlane);
}
#endif
#ifdef DO_INDEX
@@ -163,15 +163,21 @@
v1->index, v2->index, iPlane);
}
else {
- constant_plane(v0->index, iPlane);
+ constant_plane(v2->index, iPlane);
}
#endif
#ifdef DO_SPEC
- {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(p0, p1, p2, v0->specular[0], v1->specular[0], v2->specular[0],srPlane);
compute_plane(p0, p1, p2, v0->specular[1], v1->specular[1], v2->specular[1],sgPlane);
compute_plane(p0, p1, p2, v0->specular[2], v1->specular[2], v2->specular[2],sbPlane);
}
+ else {
+ /* KW: added this */
+ constant_plane(v2->specular[RCOMP], srPlane);
+ constant_plane(v2->specular[GCOMP], sgPlane);
+ constant_plane(v2->specular[BCOMP], sbPlane);
+ }
#endif
#ifdef DO_TEX
{
diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c
index a635569153..c63e11d17b 100644
--- a/src/mesa/swrast/s_feedback.c
+++ b/src/mesa/swrast/s_feedback.c
@@ -1,4 +1,4 @@
-/* $Id: s_feedback.c,v 1.3 2000/11/19 23:10:26 brianp Exp $ */
+/* $Id: s_feedback.c,v 1.4 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -100,9 +100,9 @@ void gl_feedback_triangle( GLcontext *ctx,
feedback_vertex( ctx, v1, v1 );
feedback_vertex( ctx, v2, v2 );
} else {
- feedback_vertex( ctx, v0, v0 );
- feedback_vertex( ctx, v1, v0 );
- feedback_vertex( ctx, v2, v0 );
+ feedback_vertex( ctx, v0, v2 );
+ feedback_vertex( ctx, v1, v2 );
+ feedback_vertex( ctx, v2, v2 );
}
}
}
@@ -122,8 +122,8 @@ void gl_feedback_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
feedback_vertex( ctx, v0, v0 );
feedback_vertex( ctx, v1, v1 );
} else {
- feedback_vertex( ctx, v0, v0 );
- feedback_vertex( ctx, v1, v0 );
+ feedback_vertex( ctx, v0, v1 );
+ feedback_vertex( ctx, v1, v1 );
}
swrast->StippleCounter++;
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 6c232cb694..b61d4401e1 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.7 2000/12/12 00:31:45 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.8 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -160,7 +160,7 @@ static void flat_rgba_triangle( GLcontext *ctx,
fffog += fdfogdx; \
} \
gl_write_monocolor_span( ctx, n, LEFT, Y, zspan, \
- fogspan, v0->color, \
+ fogspan, v2->color, \
GL_POLYGON ); \
} \
}
@@ -1613,10 +1613,10 @@ static void general_textured_triangle( GLcontext *ctx,
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1708,13 +1708,13 @@ static void general_textured_spec_triangle1( GLcontext *ctx,
GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
- sr = v0->specular[0]; \
- sg = v0->specular[1]; \
- sb = v0->specular[2]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
+ sr = v2->specular[0]; \
+ sg = v2->specular[1]; \
+ sb = v2->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -1837,10 +1837,10 @@ static void lambda_textured_triangle1( GLcontext *ctx,
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
@@ -1942,13 +1942,13 @@ static void lambda_textured_spec_triangle1( GLcontext *ctx,
const GLboolean flat_shade = (ctx->Light.ShadeModel==GL_FLAT); \
GLint r, g, b, a, sr, sg, sb; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
- sr = v0->specular[0]; \
- sg = v0->specular[1]; \
- sb = v0->specular[2]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
+ sr = v2->specular[0]; \
+ sg = v2->specular[1]; \
+ sb = v2->specular[2]; \
}
#define INNER_LOOP( LEFT, RIGHT, Y ) \
@@ -2055,10 +2055,10 @@ lambda_multitextured_triangle1( GLcontext *ctx,
GLfloat twidth[MAX_TEXTURE_UNITS], theight[MAX_TEXTURE_UNITS]; \
GLint r, g, b, a; \
if (flat_shade) { \
- r = v0->color[0]; \
- g = v0->color[1]; \
- b = v0->color[2]; \
- a = v0->color[3]; \
+ r = v2->color[0]; \
+ g = v2->color[1]; \
+ b = v2->color[2]; \
+ a = v2->color[3]; \
} \
{ \
GLuint unit; \
diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h
index d07f30a5ab..056435ee70 100644
--- a/src/mesa/swrast/swrast.h
+++ b/src/mesa/swrast/swrast.h
@@ -131,6 +131,8 @@ _swrast_ResetLineStipple( GLcontext *ctx );
/* These will always render the correct point/line/triangle for the
* current state.
+ *
+ * For flatshaded primitives, the provoking vertex is the final one.
*/
extern void
_swrast_Point( GLcontext *ctx, const SWvertex *v );
@@ -164,6 +166,8 @@ _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
extern void
_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
+/* Debug:
+ */
extern void
_swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index 84c313db8e..408438ca0b 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.5 2000/12/26 05:09:32 keithw Exp $ */
+/* $Id: ss_context.c,v 1.6 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -45,25 +45,24 @@
*/
static void
_swsetup_validate_quad( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint v3, GLuint pv )
+ GLuint v2, GLuint v3 )
{
_swsetup_choose_trifuncs( ctx );
- SWSETUP_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3, pv );
+ SWSETUP_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 );
}
static void
-_swsetup_validate_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+_swsetup_validate_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2 )
{
_swsetup_choose_trifuncs( ctx );
- SWSETUP_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2, pv );
+ SWSETUP_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
}
static void
-_swsetup_validate_line( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
+_swsetup_validate_line( GLcontext *ctx, GLuint v0, GLuint v1 )
{
_swsetup_choose_trifuncs( ctx );
- SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1, pv );
+ SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1 );
}
@@ -129,22 +128,22 @@ _swsetup_invalidate_state( GLcontext *ctx, GLuint new_state )
*/
void
_swsetup_Quad( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint v3, GLuint pv )
+ GLuint v2, GLuint v3 )
{
- SWSETUP_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3, pv );
+ SWSETUP_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 );
}
void
_swsetup_Triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv )
+ GLuint v2 )
{
- SWSETUP_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2, pv );
+ SWSETUP_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
}
void
-_swsetup_Line( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
+_swsetup_Line( GLcontext *ctx, GLuint v0, GLuint v1 )
{
- SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1, pv );
+ SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1 );
}
diff --git a/src/mesa/swrast_setup/ss_context.h b/src/mesa/swrast_setup/ss_context.h
index f4dcb4e7d1..601ae9eb34 100644
--- a/src/mesa/swrast_setup/ss_context.h
+++ b/src/mesa/swrast_setup/ss_context.h
@@ -44,12 +44,12 @@ typedef struct {
GLuint start, GLuint end, GLuint new_inputs );
void (*Quad)( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint v3, GLuint pv );
+ GLuint v2, GLuint v3 );
void (*Triangle)( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv );
+ GLuint v2 );
- void (*Line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv );
+ void (*Line)( GLcontext *ctx, GLuint v0, GLuint v1 );
void (*Points)( GLcontext *ctx, GLuint first, GLuint last );
diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c
index a3f8cd6cec..5fd5cd0f57 100644
--- a/src/mesa/swrast_setup/ss_triangle.c
+++ b/src/mesa/swrast_setup/ss_triangle.c
@@ -34,15 +34,13 @@
#include "ss_triangle.h"
#include "ss_context.h"
-#define SS_FLAT_BIT 0x1
+#define SS_RGBA_BIT 0x1
#define SS_OFFSET_BIT 0x2
#define SS_TWOSIDE_BIT 0x4
-#define SS_UNFILLED_BIT 0x10
-#define SS_RGBA_BIT 0x20
-#define SS_MAX_TRIFUNC 0x80
+#define SS_UNFILLED_BIT 0x8
+#define SS_MAX_TRIFUNC 0x10
static triangle_func tri_tab[SS_MAX_TRIFUNC];
-static line_func line_tab[SS_MAX_TRIFUNC];
static quad_func quad_tab[SS_MAX_TRIFUNC];
@@ -54,168 +52,88 @@ static quad_func quad_tab[SS_MAX_TRIFUNC];
#define TAG(x) x
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT)
#define TAG(x) x##_offset
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT)
-#define TAG(x) x##_flat_offset
-#include "ss_tritmp.h"
-
#define IND (SS_TWOSIDE_BIT)
#define TAG(x) x##_twoside
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT)
-#define TAG(x) x##_flat_twoside
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
#define TAG(x) x##_offset_twoside
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT)
-#define TAG(x) x##_flat_offset_twoside
-#include "ss_tritmp.h"
-
#define IND (SS_UNFILLED_BIT)
#define TAG(x) x##_unfilled
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_flat_unfilled
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_unfilled
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_flat_offset_unfilled
-#include "ss_tritmp.h"
-
#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_twoside_unfilled
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_flat_twoside_unfilled
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_twoside_unfilled
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_flat_offset_twoside_unfilled
-#include "ss_tritmp.h"
-
#define IND (0|SS_RGBA_BIT)
#define TAG(x) x##_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_offset_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
#define TAG(x) x##_twoside_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_twoside_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_twoside_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_offset_twoside_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_unfilled_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_offset_unfilled_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_twoside_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_twoside_unfilled_rgba
-#include "ss_tritmp.h"
-
#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
#define TAG(x) x##_offset_twoside_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_FLAT_BIT|SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
-#define TAG(x) x##_flat_offset_twoside_unfilled_rgba
-#include "ss_tritmp.h"
-
void _swsetup_trifuncs_init( GLcontext *ctx )
{
(void) ctx;
init();
- init_flat();
init_offset();
- init_flat_offset();
init_twoside();
- init_flat_twoside();
init_offset_twoside();
- init_flat_offset_twoside();
init_unfilled();
- init_flat_unfilled();
init_offset_unfilled();
- init_flat_offset_unfilled();
init_twoside_unfilled();
- init_flat_twoside_unfilled();
init_offset_twoside_unfilled();
- init_flat_offset_twoside_unfilled();
init_rgba();
- init_flat_rgba();
init_offset_rgba();
- init_flat_offset_rgba();
init_twoside_rgba();
- init_flat_twoside_rgba();
init_offset_twoside_rgba();
- init_flat_offset_twoside_rgba();
init_unfilled_rgba();
- init_flat_unfilled_rgba();
init_offset_unfilled_rgba();
- init_flat_offset_unfilled_rgba();
init_twoside_unfilled_rgba();
- init_flat_twoside_unfilled_rgba();
init_offset_twoside_unfilled_rgba();
- init_flat_offset_twoside_unfilled_rgba();
}
@@ -236,14 +154,19 @@ static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last )
}
}
+static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 )
+{
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ _swrast_Line( ctx, &verts[v0], &verts[v1] );
+}
+
+
+
void _swsetup_choose_trifuncs( GLcontext *ctx )
{
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
GLuint ind = 0;
- if (ctx->Light.ShadeModel == GL_FLAT)
- ind |= SS_FLAT_BIT;
-
if (ctx->Polygon._OffsetAny)
ind |= SS_OFFSET_BIT;
@@ -257,8 +180,8 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
ind |= SS_RGBA_BIT;
swsetup->Triangle = tri_tab[ind];
- swsetup->Line = line_tab[ind];
swsetup->Quad = quad_tab[ind];
+ swsetup->Line = swsetup_line;
swsetup->Points = swsetup_points;
}
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index d04a36b18b..936774aba4 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -26,44 +26,20 @@
*/
-static void TAG(triangle)(GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv)
+static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
SWvertex *v[3];
- GLfloat offset;
GLfloat z[3];
- GLubyte c[3][4], s[3][4];
- GLuint i[3];
+ GLfloat offset;
GLenum mode = GL_FILL;
+ GLuint facing;
v[0] = &verts[e0];
v[1] = &verts[e1];
v[2] = &verts[e2];
- if (IND & (SS_TWOSIDE_BIT | SS_FLAT_BIT)) {
- if (IND & SS_RGBA_BIT) {
- SS_COLOR(c[0], v[0]->color);
- SS_SPEC(s[0], v[0]->specular);
-
- if (IND & SS_TWOSIDE_BIT) {
- SS_COLOR(c[1], v[1]->color);
- SS_COLOR(c[2], v[2]->color);
-
- SS_SPEC(s[1], v[1]->specular);
- SS_SPEC(s[2], v[2]->specular);
- }
- } else {
- SS_IND(i[0], v[0]->index);
-
- if (IND & SS_TWOSIDE_BIT) {
- SS_IND(i[1], v[1]->index);
- SS_IND(i[2], v[2]->index);
- }
- }
- }
if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
{
@@ -75,46 +51,24 @@ static void TAG(triangle)(GLcontext *ctx,
if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
{
- GLuint facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
+ facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
if (IND & SS_UNFILLED_BIT)
mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
- if (IND & SS_TWOSIDE_BIT) {
- if (IND & SS_FLAT_BIT) {
+ if (facing == 1) {
+ if (IND & SS_TWOSIDE_BIT) {
if (IND & SS_RGBA_BIT) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr[facing]->data;
- GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[facing]->data;
-
- SS_COLOR(v[0]->color, vbcolor[pv]);
- 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]);
- } else {
- GLuint *vbindex = VB->IndexPtr[facing]->data;
-
- SS_IND(v[0]->index, vbindex[pv]);
- SS_IND(v[1]->index, vbindex[pv]);
- SS_IND(v[2]->index, vbindex[pv]);
- }
- } else {
- if (IND & SS_RGBA_BIT) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr[facing]->data;
- GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[facing]->data;
-
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[1]->data;
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
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]);
} else {
- GLuint *vbindex = VB->IndexPtr[facing]->data;
-
+ GLuint *vbindex = VB->IndexPtr[1]->data;
SS_IND(v[0]->index, vbindex[e0]);
SS_IND(v[1]->index, vbindex[e1]);
SS_IND(v[2]->index, vbindex[e2]);
@@ -143,23 +97,9 @@ static void TAG(triangle)(GLcontext *ctx,
}
}
}
- else if (IND & SS_FLAT_BIT)
- {
- if (IND & SS_RGBA_BIT) {
- GLubyte *color = VB->ColorPtr[0]->data[pv];
- GLubyte *spec = VB->SecondaryColorPtr[0]->data[pv];
-
- SS_COLOR(v[0]->color, color);
- SS_SPEC(v[0]->specular, spec);
- }
- else {
- GLuint index = VB->IndexPtr[0]->data[pv];
- SS_IND(v[0]->index, index);
- }
- }
if (mode == GL_POINT) {
- GLubyte *ef = VB->EdgeFlagPtr->data;
+ GLubyte *ef = VB->EdgeFlag;
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
v[0]->win[2] += offset;
v[1]->win[2] += offset;
@@ -169,7 +109,7 @@ static void TAG(triangle)(GLcontext *ctx,
if (ef[e1]) _swrast_Point( ctx, v[1] );
if (ef[e2]) _swrast_Point( ctx, v[2] );
} else if (mode == GL_LINE) {
- GLubyte *ef = VB->EdgeFlagPtr->data;
+ GLubyte *ef = VB->EdgeFlag;
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
v[0]->win[2] += offset;
v[1]->win[2] += offset;
@@ -193,27 +133,25 @@ static void TAG(triangle)(GLcontext *ctx,
v[2]->win[2] = z[2];
}
- if (IND & (SS_FLAT_BIT | SS_TWOSIDE_BIT)) {
- if (IND & SS_RGBA_BIT) {
- SS_COLOR(v[0]->color, c[0]);
- SS_SPEC(v[0]->specular, s[0]);
-
- if (IND & SS_TWOSIDE_BIT) {
- SS_COLOR(v[1]->color, c[1]);
- SS_COLOR(v[2]->color, c[2]);
- SS_SPEC(v[1]->specular, s[1]);
- SS_SPEC(v[2]->specular, s[2]);
- }
- }
- else {
- SS_IND(v[0]->index, i[0]);
-
- if (IND & SS_TWOSIDE_BIT) {
- SS_IND(v[1]->index, i[1]);
- SS_IND(v[2]->index, i[2]);
+ if (IND & SS_TWOSIDE_BIT) {
+ if (facing == 1) {
+ if (IND & SS_RGBA_BIT) {
+ GLubyte (*vbcolor)[4] = VB->ColorPtr[0]->data;
+ GLubyte (*vbspec)[4] = VB->SecondaryColorPtr[0]->data;
+ 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]);
+ } else {
+ GLuint *vbindex = VB->IndexPtr[0]->data;
+ SS_IND(v[0]->index, vbindex[e0]);
+ SS_IND(v[1]->index, vbindex[e1]);
+ SS_IND(v[2]->index, vbindex[e2]);
}
}
- }
+ }
}
@@ -221,75 +159,31 @@ static void TAG(triangle)(GLcontext *ctx,
/* Need to do something with edgeflags:
*/
static void TAG(quad)( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3,
- GLuint pv )
+ GLuint v1, GLuint v2, GLuint v3 )
{
if (IND & SS_UNFILLED_BIT) {
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLubyte ef1 = VB->EdgeFlagPtr->data[v1];
- GLubyte ef3 = VB->EdgeFlagPtr->data[v3];
- VB->EdgeFlagPtr->data[v1] = 0;
- TAG(triangle)( ctx, v0, v1, v3, pv );
- VB->EdgeFlagPtr->data[v1] = ef1;
- VB->EdgeFlagPtr->data[v3] = 0;
- TAG(triangle)( ctx, v1, v2, v3, pv );
- VB->EdgeFlagPtr->data[v3] = ef3;
+ GLubyte ef1 = VB->EdgeFlag[v1];
+ GLubyte ef3 = VB->EdgeFlag[v3];
+ VB->EdgeFlag[v1] = 0;
+ TAG(triangle)( ctx, v0, v1, v3 );
+ VB->EdgeFlag[v1] = ef1;
+ VB->EdgeFlag[v3] = 0;
+ TAG(triangle)( ctx, v1, v2, v3 );
+ VB->EdgeFlag[v3] = ef3;
} else {
- TAG(triangle)( ctx, v0, v1, v3, pv );
- TAG(triangle)( ctx, v1, v2, v3, pv );
+ TAG(triangle)( ctx, v0, v1, v3 );
+ TAG(triangle)( ctx, v1, v2, v3 );
}
}
-static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
- GLubyte c[2][4], s[2][4];
- GLuint i[2];
- SWvertex *vert0 = &verts[v0];
- SWvertex *vert1 = &verts[v1];
-
-
- if (IND & SS_FLAT_BIT) {
- if (IND & SS_RGBA_BIT) {
- GLubyte *color = VB->ColorPtr[0]->data[pv];
- GLubyte *spec = VB->SecondaryColorPtr[0]->data[pv];
-
- SS_COLOR(c[0], vert0->color);
- SS_COLOR(vert0->color, color);
-
- SS_SPEC(s[0], vert0->specular);
- SS_SPEC(vert0->specular, spec);
- }
- else {
- GLuint index = VB->IndexPtr[0]->data[pv];
-
- SS_IND(i[0], vert0->index);
- SS_IND(vert0->index, index);
- }
- }
-
- _swrast_Line( ctx, vert0, vert1 );
-
- if (IND & SS_FLAT_BIT) {
- if (IND & SS_RGBA_BIT) {
- SS_COLOR(vert0->color, c[0]);
- SS_SPEC(vert0->specular, s[0]);
- }
- else {
- SS_IND(vert0->index, i[0]);
- }
- }
-}
-
static void TAG(init)( void )
{
tri_tab[IND] = TAG(triangle);
quad_tab[IND] = TAG(quad);
- line_tab[IND] = TAG(line);
}
diff --git a/src/mesa/swrast_setup/swrast_setup.h b/src/mesa/swrast_setup/swrast_setup.h
index e5ea966821..fd9c94d4e5 100644
--- a/src/mesa/swrast_setup/swrast_setup.h
+++ b/src/mesa/swrast_setup/swrast_setup.h
@@ -47,23 +47,16 @@ _swsetup_BuildProjectedVertices( GLcontext *ctx,
GLuint new_inputs );
extern void
-_swsetup_Quad( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint v3, GLuint pv );
+_swsetup_Quad( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3 );
extern void
-_swsetup_Triangle( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint v2, GLuint pv );
-
+_swsetup_Triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2 );
extern void
-_swsetup_Line( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv );
-
+_swsetup_Line( GLcontext *ctx, GLuint v0, GLuint v1 );
extern void
_swsetup_Points( GLcontext *ctx, GLuint first, GLuint last );
-extern void
-_swsetup_IndexedPoints( GLcontext *ctx, GLuint first, GLuint last );
-
#endif
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c
index fc2c3d1944..008cc23c64 100644
--- a/src/mesa/tnl/t_array_import.c
+++ b/src/mesa/tnl/t_array_import.c
@@ -1,4 +1,4 @@
-/* $Id: t_array_import.c,v 1.3 2000/12/28 22:11:05 keithw Exp $ */
+/* $Id: t_array_import.c,v 1.4 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -301,11 +301,6 @@ static void _tnl_upgrade_client_data( GLcontext *ctx,
_tnl_import_texcoord( ctx, i, writeable, stride );
}
- if ((required & VERT_EDGE) && (VB->EdgeFlagPtr->flags & flags)) {
- ASSERT(VB->EdgeFlagPtr == &inputs->EdgeFlag);
- _tnl_import_edgeflag( ctx, writeable, stride );
- }
-
VB->importable_data &= ~required;
}
@@ -386,11 +381,8 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count )
}
if (inputs & VERT_EDGE) {
- if (imports & VERT_EDGE) {
- _tnl_import_edgeflag( ctx, 0, 0 );
- tmp->EdgeFlag.count = VB->Count;
- }
- VB->EdgeFlagPtr = &tmp->EdgeFlag;
+ _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
+ VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data;
}
if (inputs & VERT_SPEC_RGB) {
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 5b879d8a83..7d04210eb6 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,4 +1,4 @@
-/* $Id: t_context.c,v 1.7 2000/12/26 05:09:32 keithw Exp $ */
+/* $Id: t_context.c,v 1.8 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -69,6 +69,9 @@ install_driver_callbacks( GLcontext *ctx )
ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
ctx->Driver.BeginCallList = _tnl_BeginCallList;
ctx->Driver.EndCallList = _tnl_EndCallList;
+
+ ctx->Driver.RenderTabElts = _tnl_render_tab_elts;
+ ctx->Driver.RenderTabVerts = _tnl_render_tab_verts;
}
@@ -111,7 +114,7 @@ _tnl_CreateContext( GLcontext *ctx )
/* Set a few default values in the driver struct.
*/
install_driver_callbacks(ctx);
- ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT|FLUSH_STORED_VERTICES;
+ ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT;
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 62d260681c..8e3952a412 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -1,4 +1,4 @@
-/* $Id: t_context.h,v 1.8 2000/12/27 22:30:29 keithw Exp $ */
+/* $Id: t_context.h,v 1.9 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -226,6 +226,12 @@ struct vertex_arrays
typedef struct gl_material GLmaterial;
+typedef void (*interp_func)( GLcontext *ctx,
+ GLfloat t, GLuint dst, GLuint in, GLuint out,
+ GLboolean force_boundary );
+
+typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
+
/* Contains the current state of a running pipeline.
*/
typedef struct vertex_buffer
@@ -251,7 +257,7 @@ typedef struct vertex_buffer
GLubyte *ClipMask; /* VERT_CLIP (4) */
GLvector3f *NormalPtr; /* VERT_NORM */
GLfloat *NormalLengthPtr; /* VERT_NORM (optional) */
- GLvector1ub *EdgeFlagPtr; /* VERT_EDGE */
+ GLboolean *EdgeFlag; /* VERT_EDGE */
GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */
GLvector1ui *IndexPtr[2]; /* VERT_INDEX */
GLvector4ub *ColorPtr[2]; /* VERT_RGBA */
@@ -276,9 +282,10 @@ typedef struct vertex_buffer
*/
GLuint LastClipped;
- void *interpfunc;
- /* Two pieces of private data from _tnl_render_stage that have no
- * business being in this struct.
+ interp_func interpfunc;
+ copy_pv_func copypvfunc;
+ /* Private data from _tnl_render_stage that has no business being
+ * in this struct.
*/
} TNLvertexbuffer;
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
index 528f101661..aeca38dd4f 100644
--- a/src/mesa/tnl/t_imm_api.c
+++ b/src/mesa/tnl/t_imm_api.c
@@ -292,7 +292,7 @@ _tnl_end( GLcontext *ctx )
IM->FlushElt = 0;
}
- ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+/* ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; */
}
IM->BeginState = state;
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index 1549fa53af..4bdce0d18d 100644
--- a/src/mesa/tnl/t_imm_exec.c
+++ b/src/mesa/tnl/t_imm_exec.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_exec.c,v 1.4 2000/12/28 22:11:05 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.5 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -198,7 +198,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM )
VB->NormalPtr = 0;
VB->NormalLengthPtr = 0;
VB->FogCoordPtr = 0;
- VB->EdgeFlagPtr = 0;
+ VB->EdgeFlag = 0;
VB->IndexPtr[0] = 0;
VB->IndexPtr[1] = 0;
VB->ColorPtr[0] = 0;
@@ -259,10 +259,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM )
}
if (inputs & VERT_EDGE) {
- tmp->EdgeFlag.data = IM->EdgeFlag + start;
- tmp->EdgeFlag.start = IM->EdgeFlag + start;
- tmp->EdgeFlag.count = count;
- VB->EdgeFlagPtr = &tmp->EdgeFlag;
+ VB->EdgeFlag = IM->EdgeFlag + start;
}
if (inputs & VERT_RGBA) {
@@ -451,8 +448,8 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM )
*/
_tnl_copy_immediate_vertices( ctx, IM );
-/* if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) */
-/* ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES; */
+ if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1)
+ ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
}
diff --git a/src/mesa/tnl/t_pipeline.h b/src/mesa/tnl/t_pipeline.h
index 9d433bde0a..3f64eb8ed9 100644
--- a/src/mesa/tnl/t_pipeline.h
+++ b/src/mesa/tnl/t_pipeline.h
@@ -1,4 +1,4 @@
-/* $Id: t_pipeline.h,v 1.4 2000/12/26 05:09:33 keithw Exp $ */
+/* $Id: t_pipeline.h,v 1.5 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -62,4 +62,10 @@ extern const struct gl_pipeline_stage _tnl_render_stage;
*/
extern const struct gl_pipeline_stage *_tnl_default_pipeline[];
+
+/* Convenience routines provided by t_vb_render.c:
+ */
+extern render_func _tnl_render_tab_elts[];
+extern render_func _tnl_render_tab_verts[];
+
#endif
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
index 1aeb014e15..5957f4960c 100644
--- a/src/mesa/tnl/t_vb_cliptmp.h
+++ b/src/mesa/tnl/t_vb_cliptmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_cliptmp.h,v 1.4 2000/12/28 22:11:05 keithw Exp $ */
+/* $Id: t_vb_cliptmp.h,v 1.5 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -28,340 +28,45 @@
*/
-#define INSIDE( J ) !NEGATIVE(J)
-#define OUTSIDE( J ) NEGATIVE(J)
+#define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D
-
-
-
-static GLuint TAG(userclip_line)( GLcontext *ctx,
- GLuint *i, GLuint *j,
- interp_func interp )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint ii = *i;
- GLuint jj = *j;
- GLuint p;
-
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- GLfloat d = ctx->Transform._ClipUserPlane[p][3];
-
- GLfloat dpI = d*W(ii) + c*Z(ii) + b*Y(ii) + a*X(ii);
- GLfloat dpJ = d*W(jj) + c*Z(jj) + b*Y(jj) + a*X(jj);
-
- GLuint flagI = OUTSIDE( dpI );
- GLuint flagJ = OUTSIDE( dpJ );
-
- if (flagI ^ flagJ) {
- if (flagJ) {
- GLfloat t = dpI / (dpI - dpJ);
- VB->ClipMask[jj] |= CLIP_USER_BIT;
- jj = interp( ctx, t, ii, jj, GL_FALSE );
- VB->ClipMask[jj] = 0;
- } else {
- GLfloat t = dpJ / (dpJ - dpI);
- VB->ClipMask[ii] |= CLIP_USER_BIT;
- ii = interp( ctx, t, jj, ii, GL_FALSE );
- VB->ClipMask[ii] = 0;
- }
- }
- else if (flagI)
- return 0;
- }
- }
-
- *i = ii;
- *j = jj;
- return 1;
-}
-
-
-static GLuint TAG(userclip_polygon)( GLcontext *ctx,
- GLuint n,
- GLuint vlist[],
- interp_func interp )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint vlist2[MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist, *outlist = vlist2;
- GLubyte *clipmask = VB->ClipMask;
- GLuint p;
-
-#define CLIP_DOTPROD(xx) d*W(xx) + c*Z(xx) + b*Y(xx) + a*X(xx)
-
- /* Can be speeded up to if vertex_stage actually saves the
- * UserClipMask, and if it is used in this loop (after computing a
- * UserClipOrMask).
- */
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- register float a = ctx->Transform._ClipUserPlane[p][0];
- register float b = ctx->Transform._ClipUserPlane[p][1];
- register float c = ctx->Transform._ClipUserPlane[p][2];
- register float d = ctx->Transform._ClipUserPlane[p][3];
-
- /* initialize prev to be last in the input list */
- GLuint idxPrev = inlist[n-1];
- GLfloat dpPrev = CLIP_DOTPROD(idxPrev);
- GLuint outcount = 0;
- GLuint i;
-
- for (i = 0 ; i < n ; i++) {
- GLuint idx = inlist[i];
- GLfloat dp = CLIP_DOTPROD(idx);
-
- if (!NEGATIVE(dpPrev)) {
- outlist[outcount++] = idxPrev;
- clipmask[idxPrev] &= ~CLIP_USER_BIT;
- } else {
- clipmask[idxPrev] |= CLIP_USER_BIT;
- }
-
-
- if (DIFFERENT_SIGNS(dp, dpPrev)) {
- GLuint newvert;
- if (NEGATIVE(dp)) {
- /* Going out of bounds. Avoid division by zero as we
- * know dp != dpPrev from DIFFERENT_SIGNS, above.
- */
- GLfloat t = dp / (dp - dpPrev);
- newvert = interp( ctx, t, idx, idxPrev, GL_TRUE );
- } else {
- /* Coming back in.
- */
- GLfloat t = dpPrev / (dpPrev - dp);
- newvert = interp( ctx, t, idxPrev, idx, GL_FALSE );
- }
- clipmask[newvert] = 0;
- outlist[outcount++] = newvert;
- }
-
- idxPrev = idx;
- dpPrev = dp;
- }
-
- if (outcount < 3)
- return 0;
-
- {
- GLuint *tmp;
- tmp = inlist;
- inlist = outlist;
- outlist = tmp;
- n = outcount;
- }
- } /* if */
- } /* for p */
-
- if (inlist!=vlist) {
- GLuint i;
- for (i = 0 ; i < n ; i++)
- vlist[i] = inlist[i];
- }
-
- return n;
-}
-
-
-/* This now calls the user clip functions if required.
- */
-static void TAG(viewclip_line)( GLcontext *ctx,
- GLuint i, GLuint j,
- GLubyte mask )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- interp_func interp = (interp_func) VB->interpfunc;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint ii = i, jj = j;
- GLuint vlist[2];
- GLuint n;
-
- VB->LastClipped = VB->FirstClipped;
-
-/*
- * We use 6 instances of this code to clip against the 6 planes.
- */
-#define GENERAL_CLIP \
- if (mask & PLANE) { \
- GLfloat dpI = CLIP_DOTPROD( ii ); \
- GLfloat dpJ = CLIP_DOTPROD( jj ); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- if (NEGATIVE(dpJ)) { \
- GLfloat t = dpI / (dpI - dpJ); \
- VB->ClipMask[jj] |= PLANE; \
- jj = interp( ctx, t, ii, jj, GL_FALSE ); \
- VB->ClipMask[jj] = 0; \
- } else { \
- GLfloat t = dpJ / (dpJ - dpI); \
- VB->ClipMask[ii] |= PLANE; \
- ii = interp( ctx, t, jj, ii, GL_FALSE ); \
- VB->ClipMask[ii] = 0; \
- } \
- } \
- else if (NEGATIVE(dpI)) \
- return; \
- }
-
-#undef CLIP_DOTPROD
-#define PLANE CLIP_RIGHT_BIT
-#define CLIP_DOTPROD(K) (- X(K) + W(K))
-
- GENERAL_CLIP
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#define PLANE CLIP_LEFT_BIT
-#define CLIP_DOTPROD(K) (X(K) + W(K))
-
- GENERAL_CLIP
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#define PLANE CLIP_TOP_BIT
-#define CLIP_DOTPROD(K) (- Y(K) + W(K))
-
- GENERAL_CLIP
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#define PLANE CLIP_BOTTOM_BIT
-#define CLIP_DOTPROD(K) (Y(K) + W(K))
-
- GENERAL_CLIP
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#define PLANE CLIP_FAR_BIT
-#define CLIP_DOTPROD(K) (- Z(K) + W(K))
-
- if (SIZE >= 3) {
- GENERAL_CLIP
- }
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#define PLANE CLIP_NEAR_BIT
-#define CLIP_DOTPROD(K) (Z(K) + W(K))
-
- if (SIZE >=3 ) {
- GENERAL_CLIP
- }
-
-#undef CLIP_DOTPROD
-#undef PLANE
-#undef GENERAL_CLIP
-
-
- if (mask & CLIP_USER_BIT) {
- if ( TAG(userclip_line)( ctx, &ii, &jj, interp ) == 0 )
- return;
- }
-
- vlist[0] = ii;
- vlist[1] = jj;
- n = 2;
-
- /* If necessary, project new vertices.
- */
- {
- GLuint i, j;
- GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
- GLuint start = VB->FirstClipped;
-
- for (i = 0; i < n; i++) {
- j = vlist[i];
- if (j >= start) {
- if (SIZE == 4 && W(j) != 0.0F) {
- GLfloat wInv = 1.0F / W(j);
- proj[j][0] = X(j) * wInv;
- proj[j][1] = Y(j) * wInv;
- proj[j][2] = Z(j) * wInv;
- proj[j][3] = wInv;
- } else {
- proj[j][0] = X(j);
- proj[j][1] = Y(j);
- proj[j][2] = Z(j);
- proj[j][3] = W(j);
- }
- }
- }
- }
-
- if (ctx->Driver.BuildProjectedVertices)
- ctx->Driver.BuildProjectedVertices(ctx,
- VB->FirstClipped,
- VB->LastClipped,
- ~0);
-
-
- /* Render the new line.
- */
- ctx->Driver.LineFunc( ctx, ii, jj, j );
-}
-
-/* We now clip polygon triangles individually. This is necessary to
- * avoid artifacts dependent on where the boundary of the VB falls
- * within the polygon. As a result, there is an upper bound on the
- * number of vertices which may be created, and the test against VB_SIZE
- * is redundant.
- */
-static void TAG(viewclip_polygon)( GLcontext *ctx,
- GLuint n, GLuint vlist[], GLuint pv,
- GLubyte mask )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- interp_func interp = (interp_func) VB->interpfunc;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint vlist2[MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist, *outlist = vlist2;
- GLuint i;
- GLubyte *clipmask = VB->ClipMask;
-
- VB->LastClipped = VB->FirstClipped;
-
- if (mask & CLIP_ALL_BITS) {
-
-#define GENERAL_CLIP \
+#define POLY_CLIP( PLANE, A, B, C, D ) \
+do { \
if (mask & PLANE) { \
- GLuint idxPrev = inlist[n-1]; \
- GLfloat dpPrev = CLIP_DOTPROD(idxPrev); \
+ GLuint idxPrev = inlist[0]; \
+ GLfloat dpPrev = CLIP_DOTPROD(idxPrev, A, B, C, D ); \
GLuint outcount = 0; \
GLuint i; \
- \
- mask &= ~PLANE; \
- \
- for (i = 0; i < n; i++) { \
+ \
+ inlist[n] = inlist[0]; /* prevent rotation of vertices */ \
+ for (i = 1; i <= n; i++) { \
GLuint idx = inlist[i]; \
- GLfloat dp = CLIP_DOTPROD(idx); \
+ GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D ); \
\
+ clipmask[idxPrev] |= PLANE; \
if (!NEGATIVE(dpPrev)) { \
outlist[outcount++] = idxPrev; \
clipmask[idxPrev] &= ~PLANE; \
} \
\
if (DIFFERENT_SIGNS(dp, dpPrev)) { \
- GLuint newvert; \
+ GLuint newvert = VB->LastClipped++; \
+ VB->ClipMask[newvert] = 0; \
+ outlist[outcount++] = newvert; \
if (NEGATIVE(dp)) { \
/* Going out of bounds. Avoid division by zero as we \
* know dp != dpPrev from DIFFERENT_SIGNS, above. \
*/ \
GLfloat t = dp / (dp - dpPrev); \
- newvert = interp( ctx, t, idx, idxPrev, GL_TRUE ); \
- } else { \
+ LINTERP_SZ( t, coord, newvert, idx, idxPrev, SIZE ); \
+ interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \
+ } else { \
/* Coming back in. \
*/ \
GLfloat t = dpPrev / (dpPrev - dp); \
- newvert = interp( ctx, t, idxPrev, idx, GL_FALSE ); \
+ LINTERP_SZ( t, coord, newvert, idxPrev, idx, SIZE ); \
+ interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \
} \
- clipmask[newvert] = mask; \
- outlist[outcount++] = newvert; \
} \
\
idxPrev = idx; \
@@ -377,125 +82,184 @@ static void TAG(viewclip_polygon)( GLcontext *ctx,
outlist = tmp; \
n = outcount; \
} \
- }
-
-
-#define PLANE CLIP_RIGHT_BIT
-#define CLIP_DOTPROD(K) (- X(K) + W(K))
-
- GENERAL_CLIP
-
-#undef CLIP_DOTPROD
-#undef PLANE
-
-
-#define PLANE CLIP_LEFT_BIT
-#define CLIP_DOTPROD(K) (X(K) + W(K))
-
- GENERAL_CLIP
+ } \
+} while (0)
+
+
+#define LINE_CLIP(PLANE, A, B, C, D ) \
+do { \
+ if (mask & PLANE) { \
+ GLfloat dpI = CLIP_DOTPROD( ii, A, B, C, D ); \
+ GLfloat dpJ = CLIP_DOTPROD( jj, A, B, C, D ); \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ GLuint newvert = VB->LastClipped++; \
+ VB->ClipMask[newvert] = 0; \
+ if (NEGATIVE(dpJ)) { \
+ GLfloat t = dpI / (dpI - dpJ); \
+ VB->ClipMask[jj] |= PLANE; \
+ LINTERP_SZ( t, coord, newvert, ii, jj, SIZE ); \
+ interp( ctx, t, newvert, ii, jj, GL_FALSE ); \
+ jj = newvert; \
+ } else { \
+ GLfloat t = dpJ / (dpJ - dpI); \
+ VB->ClipMask[ii] |= PLANE; \
+ LINTERP_SZ( t, coord, newvert, jj, ii, SIZE ); \
+ interp( ctx, t, newvert, jj, ii, GL_FALSE ); \
+ ii = newvert; \
+ } \
+ } \
+ else if (NEGATIVE(dpI)) \
+ return; \
+ } \
+} while (0)
+
+
+/* Project if necessary.
+ */
+static void TAG(build_proj_verts)( GLcontext *ctx )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLuint last = VB->LastClipped;
+ GLuint i;
-#undef CLIP_DOTPROD
-#undef PLANE
+ for (i = VB->FirstClipped; i < last; i++) {
+ if (VB->ClipMask[i] == 0) {
+ if (SIZE == 4 && W(i) != 0.0F) {
+ GLfloat wInv = 1.0F / W(i);
+ proj[i][0] = X(i) * wInv;
+ proj[i][1] = Y(i) * wInv;
+ proj[i][2] = Z(i) * wInv;
+ proj[i][3] = wInv;
+ } else {
+ proj[i][0] = X(i);
+ proj[i][1] = Y(i);
+ proj[i][2] = Z(i);
+ proj[i][3] = W(i);
+ }
+ }
+ }
-#define PLANE CLIP_TOP_BIT
-#define CLIP_DOTPROD(K) (- Y(K) + W(K))
+ ctx->Driver.BuildProjectedVertices(ctx,
+ VB->FirstClipped,
+ VB->LastClipped,
+ ~0);
+}
- GENERAL_CLIP
+/* Clip a line against the viewport and user clip planes.
+ */
+static void TAG(clip_line)( GLcontext *ctx,
+ GLuint i, GLuint j,
+ GLubyte mask )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ interp_func interp = (interp_func) VB->interpfunc;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLuint ii = i, jj = j, p;
-#undef CLIP_DOTPROD
-#undef PLANE
+ VB->LastClipped = VB->FirstClipped;
-#define PLANE CLIP_BOTTOM_BIT
-#define CLIP_DOTPROD(K) (Y(K) + W(K))
+ if (mask & 0x3f) {
+ LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ LINE_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ LINE_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ LINE_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+ }
- GENERAL_CLIP
+ if (mask & CLIP_USER_BIT) {
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipEnabled[p]) {
+ GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
+ }
+ }
-#undef CLIP_DOTPROD
-#undef PLANE
+ TAG(build_proj_verts)( ctx );
-#define PLANE CLIP_FAR_BIT
-#define CLIP_DOTPROD(K) (- Z(K) + W(K))
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && j != jj)
+ VB->copypvfunc( ctx, jj, j );
- if (SIZE >= 3) {
- GENERAL_CLIP
- }
+ /* Render the new line.
+ */
+ ctx->Driver.LineFunc( ctx, ii, jj );
-#undef CLIP_DOTPROD
-#undef PLANE
+}
-#define PLANE CLIP_NEAR_BIT
-#define CLIP_DOTPROD(K) (Z(K) + W(K))
- if (SIZE >=3 ) {
- GENERAL_CLIP
- }
+/* Clip a triangle or quad against the viewport and user clip planes.
+ */
+static void TAG(clip_polygon)( GLcontext *ctx,
+ GLuint n, GLuint vlist[],
+ GLubyte mask )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ interp_func interp = (interp_func) VB->interpfunc;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLuint pv = vlist[0];
+ GLuint vlist2[MAX_CLIPPED_VERTICES];
+ GLuint *inlist = vlist, *outlist = vlist2;
+ GLuint p;
+ GLubyte *clipmask = VB->ClipMask;
-#undef CLIP_DOTPROD
-#undef PLANE
-#undef GENERAL_CLIP
+ VB->LastClipped = VB->FirstClipped;
- if (inlist != vlist)
- for (i = 0 ; i < n ; i++)
- vlist[i] = inlist[i];
+ if (mask & 0x3f) {
+ POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
}
- /* Clip against user clipping planes in clip space.
- */
if (mask & CLIP_USER_BIT) {
- n = TAG(userclip_polygon)( ctx, n, vlist, interp );
- if (n < 3) return;
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipEnabled[p]) {
+ GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
+ }
}
- /* Project if necessary.
- */
- {
- GLuint i;
- GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
- GLuint first = VB->FirstClipped;
-
- for (i = 0; i < n; i++) {
- GLuint j = vlist[i];
- if (j >= first) {
- if (SIZE == 4 && W(j) != 0.0F) {
- GLfloat wInv = 1.0F / W(j);
- proj[j][0] = X(j) * wInv;
- proj[j][1] = Y(j) * wInv;
- proj[j][2] = Z(j) * wInv;
- proj[j][3] = wInv;
- } else {
- proj[j][0] = X(j);
- proj[j][1] = Y(j);
- proj[j][2] = Z(j);
- proj[j][3] = W(j);
- }
- }
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (pv != inlist[0]) {
+ ASSERT( inlist[0] >= VB->FirstClipped );
+ VB->copypvfunc( ctx, inlist[0], pv );
}
}
- if (ctx->Driver.BuildProjectedVertices)
- ctx->Driver.BuildProjectedVertices(ctx,
- VB->FirstClipped,
- VB->LastClipped,
- ~0);
+ TAG(build_proj_verts)( ctx );
/* Render the new vertices as an unclipped polygon.
- * Argh - need to pass in pv...
*/
{
GLuint *tmp = VB->Elts;
- VB->Elts = vlist;
- render_poly_pv_raw_elts( ctx, 0, n, PRIM_BEGIN|PRIM_END, pv );
+ VB->Elts = inlist;
+ ctx->Driver.RenderTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
VB->Elts = tmp;
}
}
+
+
#undef W
#undef Z
#undef Y
#undef X
#undef SIZE
#undef TAG
-#undef INSIDE
-#undef OUTSIDE
+#undef POLY_CLIP
+#undef LINE_CLIP
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index b3fef23501..2616d294d3 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.5 2001/01/03 15:59:31 brianp Exp $ */
+/* $Id: t_vb_render.c,v 1.6 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -22,6 +22,9 @@
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <keithw@valinux.com>
*/
@@ -33,11 +36,16 @@
* and triangle rasterizers via the function pointers:
*
* context->Driver.BuildProjectedVertices()
+ *
* context->Driver.PointsFunc()
* context->Driver.LineFunc()
* context->Driver.TriangleFunc()
* context->Driver.QuadFunc()
*
+ * context->Driver.RenderTabVerts[]
+ * context->Driver.RenderTabElts[]
+ *
+ * None of these may be null.
*/
@@ -55,9 +63,6 @@
#include "t_pipeline.h"
-typedef GLuint (*interp_func)( GLcontext *ctx,
- GLfloat t, GLuint in, GLuint out,
- GLboolean force_boundary );
typedef void (*clip_line_func)( GLcontext *ctx,
GLuint i, GLuint j,
@@ -65,13 +70,8 @@ typedef void (*clip_line_func)( GLcontext *ctx,
typedef void (*clip_poly_func)( GLcontext *ctx,
GLuint n, GLuint vlist[],
- GLuint pv, GLubyte mask );
-
+ GLubyte mask );
-typedef void (*render_func)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags );
@@ -79,33 +79,19 @@ struct render_stage_data {
/* Clipping functions for current state.
*/
- interp_func interp; /* Clip interpolation function */
- GLuint _ClipInputs; /* Inputs referenced by interpfunc */
-
+ interp_func interp; /* Clip interpolation function */
+ copy_pv_func copypv; /* Flatshade fixup function */
+ GLuint _ClipInputs; /* Inputs referenced by interpfunc */
};
#define RENDER_STAGE_DATA(stage) ((struct render_stage_data *)stage->private)
-static void render_poly_pv_raw_elts( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags,
- GLuint pv );
/**********************************************************************/
/* Interpolate between pairs of vertices */
/**********************************************************************/
-#define INTERP_RGBA 0x1
-#define INTERP_TEX 0x2
-#define INTERP_INDEX 0x4
-#define INTERP_SPEC 0x8
-#define INTERP_FOG 0x10
-#define INTERP_EDGE 0x20
-#define MAX_INTERP 0x40
-
-
#define LINTERP_SZ( t, vec, to, a, b, sz ) \
do { \
switch (sz) { \
@@ -146,8 +132,50 @@ do { \
-static interp_func interp_tab[0x80];
+#define INTERP_RGBA 0x1
+#define INTERP_TEX 0x2
+#define INTERP_INDEX 0x4
+#define INTERP_SPEC 0x8
+#define INTERP_FOG 0x10
+#define INTERP_EDGE 0x20
+#define MAX_INTERP 0x40
+
+static interp_func interp_tab[MAX_INTERP];
+static copy_pv_func copy_tab[MAX_INTERP];
+
+
+#define IND (0)
+#define NAME interp_none
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_FOG)
+#define NAME interp_FOG
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_TEX)
+#define NAME interp_TEX
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_FOG|INTERP_TEX)
+#define NAME interp_FOG_TEX
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_EDGE)
+#define NAME interp_EDGE
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_FOG|INTERP_EDGE)
+#define NAME interp_FOG_EDGE
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_TEX|INTERP_EDGE)
+#define NAME interp_TEX_EDGE
+#include "t_vb_interptmp.h"
+
+#define IND (INTERP_FOG|INTERP_TEX|INTERP_EDGE)
+#define NAME interp_FOG_TEX_EDGE
+#include "t_vb_interptmp.h"
#define IND (INTERP_RGBA)
#define NAME interp_RGBA
@@ -246,15 +274,34 @@ static interp_func interp_tab[0x80];
#include "t_vb_interptmp.h"
+#define IND (INTERP_RGBA)
+#define NAME copy_RGBA
+#include "t_vb_flattmp.h"
+
+#define IND (INTERP_RGBA|INTERP_SPEC)
+#define NAME copy_RGBA_SPEC
+#include "t_vb_flattmp.h"
+
+#define IND (INTERP_INDEX)
+#define NAME copy_INDEX
+#include "t_vb_flattmp.h"
+
+
+
-static GLuint interp_invalid( GLcontext *ctx,
- GLfloat t,
- GLuint in, GLuint out,
- GLboolean boundary )
+static void interp_invalid( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint in, GLuint out,
+ GLboolean boundary )
{
(void)(ctx && t && in && out && boundary);
fprintf(stderr, "Invalid interpolation function in t_vbrender.c\n");
- return in;
+}
+
+static void copy_invalid( GLcontext *ctx, GLuint dst, GLuint src )
+{
+ (void)(ctx && dst && src);
+ fprintf(stderr, "Invalid copy function in t_vbrender.c\n");
}
@@ -266,8 +313,19 @@ static void interp_init( void )
* the non-implemented combinations are reachable, but this gives
* some safety from crashes.
*/
- for (i = 0 ; i < Elements(interp_tab) ; i++)
+ for (i = 0 ; i < Elements(interp_tab) ; i++) {
interp_tab[i] = interp_invalid;
+ copy_tab[i] = copy_invalid;
+ }
+
+ interp_tab[0] = interp_none;
+ interp_tab[INTERP_FOG] = interp_FOG;
+ interp_tab[INTERP_TEX] = interp_TEX;
+ interp_tab[INTERP_FOG|INTERP_TEX] = interp_FOG_TEX;
+ interp_tab[INTERP_EDGE] = interp_EDGE;
+ interp_tab[INTERP_FOG|INTERP_EDGE] = interp_FOG_EDGE;
+ interp_tab[INTERP_TEX|INTERP_EDGE] = interp_TEX_EDGE;
+ interp_tab[INTERP_FOG|INTERP_TEX|INTERP_EDGE] = interp_FOG_TEX_EDGE;
interp_tab[INTERP_RGBA] = interp_RGBA;
interp_tab[INTERP_RGBA|INTERP_SPEC] = interp_RGBA_SPEC;
@@ -276,7 +334,8 @@ static void interp_init( void )
interp_tab[INTERP_RGBA|INTERP_TEX] = interp_RGBA_TEX;
interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_TEX] = interp_RGBA_SPEC_TEX;
interp_tab[INTERP_RGBA|INTERP_FOG|INTERP_TEX] = interp_RGBA_FOG_TEX;
- interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_TEX] = interp_RGBA_SPEC_FOG_TEX;
+ interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_TEX] =
+ interp_RGBA_SPEC_FOG_TEX;
interp_tab[INTERP_INDEX] = interp_INDEX;
interp_tab[INTERP_FOG|INTERP_INDEX] = interp_FOG_INDEX;
interp_tab[INTERP_TEX|INTERP_INDEX] = interp_TEX_INDEX;
@@ -284,15 +343,26 @@ static void interp_init( void )
interp_tab[INTERP_RGBA|INTERP_EDGE] = interp_RGBA_EDGE;
interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_EDGE] = interp_RGBA_SPEC_EDGE;
interp_tab[INTERP_RGBA|INTERP_FOG|INTERP_EDGE] = interp_RGBA_FOG_EDGE;
- interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_EDGE] = interp_RGBA_SPEC_FOG_EDGE;
+ interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_EDGE] =
+ interp_RGBA_SPEC_FOG_EDGE;
interp_tab[INTERP_RGBA|INTERP_TEX|INTERP_EDGE] = interp_RGBA_TEX_EDGE;
- interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_TEX|INTERP_EDGE] = interp_RGBA_SPEC_TEX_EDGE;
- interp_tab[INTERP_RGBA|INTERP_FOG|INTERP_TEX|INTERP_EDGE] = interp_RGBA_FOG_TEX_EDGE;
- interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_TEX|INTERP_EDGE] = interp_RGBA_SPEC_FOG_TEX_EDGE;
+ interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_TEX|INTERP_EDGE] =
+ interp_RGBA_SPEC_TEX_EDGE;
+ interp_tab[INTERP_RGBA|INTERP_FOG|INTERP_TEX|INTERP_EDGE] =
+ interp_RGBA_FOG_TEX_EDGE;
+ interp_tab[INTERP_RGBA|INTERP_SPEC|INTERP_FOG|INTERP_TEX|INTERP_EDGE] =
+ interp_RGBA_SPEC_FOG_TEX_EDGE;
interp_tab[INTERP_INDEX|INTERP_EDGE] = interp_INDEX_EDGE;
interp_tab[INTERP_FOG|INTERP_INDEX|INTERP_EDGE] = interp_FOG_INDEX_EDGE;
interp_tab[INTERP_TEX|INTERP_INDEX|INTERP_EDGE] = interp_TEX_INDEX_EDGE;
- interp_tab[INTERP_FOG|INTERP_TEX|INTERP_INDEX|INTERP_EDGE] = interp_FOG_TEX_INDEX_EDGE;
+ interp_tab[INTERP_FOG|INTERP_TEX|INTERP_INDEX|INTERP_EDGE] =
+ interp_FOG_TEX_INDEX_EDGE;
+
+
+ copy_tab[INTERP_RGBA] = copy_RGBA;
+ copy_tab[INTERP_RGBA|INTERP_SPEC] = copy_RGBA_SPEC;
+ copy_tab[INTERP_INDEX] = copy_INDEX;
+
}
@@ -301,12 +371,15 @@ static void interp_init( void )
/**********************************************************************/
-#if 0
-#define NEGATIVE(x) ((*(int *)&x)<0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#if defined(USE_IEEE)
+#define NEGATIVE(x) ((*(GLuint *)&x) & (1<<31))
+#define DIFFERENT_SIGNS(x,y) (((*(GLuint *)&x)^(*(GLuint *)&y)) & (1<<31))
#else
#define NEGATIVE(x) (x < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
+#define DIFFERENT_SIGNS(x,y) (x * y <= 0 && x - y != 0)
+/* Could just use (x*y<0) except for the flatshading requirements.
+ * Maybe there's a better way?
+ */
#endif
#define W(i) coord[i][3]
@@ -336,176 +409,151 @@ static void interp_init( void )
static clip_poly_func clip_poly_tab[5] = {
0,
0,
- viewclip_polygon_2,
- viewclip_polygon_3,
- viewclip_polygon_4
+ clip_polygon_2,
+ clip_polygon_3,
+ clip_polygon_4
};
static clip_line_func clip_line_tab[5] = {
0,
0,
- viewclip_line_2,
- viewclip_line_3,
- viewclip_line_4
+ clip_line_2,
+ clip_line_3,
+ clip_line_4
};
-
/**********************************************************************/
-/* Clip and render single primitives */
-/**********************************************************************/
-
-
-
-static INLINE void draw_line(GLcontext *ctx, GLuint v1, GLuint v2 )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLubyte c1 = VB->ClipMask[v1], c2 = VB->ClipMask[v2];
- GLubyte ormask = c1|c2;
- if (!ormask)
- ctx->Driver.LineFunc( ctx, v1, v2, v2 );
- else if (!(c1 & c2 & 0x3f))
- clip_line_tab[VB->ClipPtr->size]( ctx, v1, v2, ormask );
-}
-
-static INLINE void draw_triangle(GLcontext *ctx,
- GLuint v1, GLuint v2, GLuint v3,
- GLuint pv )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLubyte c1 = VB->ClipMask[v1], c2 = VB->ClipMask[v2], c3 = VB->ClipMask[v3];
- GLubyte ormask = c1|c2|c3;
- if (!ormask)
- ctx->Driver.TriangleFunc( ctx, v1, v2, v3, pv );
- else if (!(c1 & c2 & c3 & 0x3f)) {
- GLuint vlist[MAX_CLIPPED_VERTICES];
- ASSIGN_3V(vlist, v1, v2, v3 );
- clip_poly_tab[VB->ClipPtr->size]( ctx, 3, vlist, pv, ormask );
- }
-}
-
-
-static INLINE void draw_quad( GLcontext *ctx,
- GLuint v1, GLuint v2, GLuint v3,
- GLuint v4, GLuint pv )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLubyte c1 = VB->ClipMask[v1], c2 = VB->ClipMask[v2];
- GLubyte c3 = VB->ClipMask[v3], c4 = VB->ClipMask[v4];
- GLubyte ormask = c1|c2|c3|c4;
- if (!ormask)
- ctx->Driver.QuadFunc( ctx, v1, v2, v3, v4, pv );
- else if (!(c1 & c2 & c3 & c4 & 0x3f)) {
- GLuint vlist[MAX_CLIPPED_VERTICES];
- ASSIGN_4V(vlist, v1, v2, v3, v4 );
- clip_poly_tab[VB->ClipPtr->size]( ctx, 4, vlist, pv, ormask );
- }
-}
-
-
-/**********************************************************************/
-/* Clip and render whole begin/end objects */
+/* Clip and render whole begin/end objects */
/**********************************************************************/
#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
-#define EDGEFLAG_GET(idx) VB->EdgeFlagPtr->data[idx]
-#define EDGEFLAG_SET(idx, val) VB->EdgeFlagPtr->data[idx] = val
+#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
+#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
-/* Vertices, no clipping.
+/* Vertices, with the possibility of clipping.
*/
#define RENDER_POINTS( start, count ) \
- ctx->Driver.PointsFunc( ctx, start, count-1 )
+ ctx->Driver.PointsFunc( ctx, start, count )
-#define RENDER_LINE( i1, i ) \
- ctx->Driver.LineFunc( ctx, i1, i, i )
+#define RENDER_LINE( v1, v2 ) \
+do { \
+ GLubyte c1 = mask[v1], c2 = mask[v2]; \
+ GLubyte ormask = c1|c2; \
+ if (!ormask) \
+ LineFunc( ctx, v1, v2 ); \
+ else if (!(c1 & c2 & 0x3f)) \
+ clip_line_tab[sz]( ctx, v1, v2, ormask ); \
+} while (0)
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
+#define RENDER_TRI( v1, v2, v3 ) \
do { \
- if (parity) \
- ctx->Driver.TriangleFunc( ctx, i1, i2, i, pv ); \
- else \
- ctx->Driver.TriangleFunc( ctx, i2, i1, i, pv ); \
+ GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
+ GLubyte ormask = c1|c2|c3; \
+ if (!ormask) \
+ TriangleFunc( ctx, v1, v2, v3 ); \
+ else if (!(c1 & c2 & c3 & 0x3f)) { \
+ GLuint vlist[MAX_CLIPPED_VERTICES]; \
+ ASSIGN_3V(vlist, v3, v1, v2 ); \
+ clip_poly_tab[sz]( ctx, 3, vlist, ormask ); \
+ } \
} while (0)
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
- ctx->Driver.QuadFunc( ctx, i3, i2, i1, i, pv );
-
-#define TAG(x) x##_raw
+#define RENDER_QUAD( v1, v2, v3, v4 ) \
+do { \
+ GLubyte c1 = mask[v1], c2 = mask[v2]; \
+ GLubyte c3 = mask[v3], c4 = mask[v4]; \
+ GLubyte ormask = c1|c2|c3|c4; \
+ if (!ormask) \
+ QuadFunc( ctx, v1, v2, v3, v4 ); \
+ else if (!(c1 & c2 & c3 & c4 & 0x3f)) { \
+ GLuint vlist[MAX_CLIPPED_VERTICES]; \
+ ASSIGN_4V(vlist, v4, v1, v2, v3 ); \
+ clip_poly_tab[sz]( ctx, 4, vlist, ormask ); \
+ } \
+} while (0)
-#define LOCAL_VARS \
- struct vertex_buffer *VB = &(TNL_CONTEXT(ctx)->vb); \
- (void) VB;
+#define LOCAL_VARS \
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; \
+ const GLuint * const elt = VB->Elts; \
+ const GLubyte *mask = VB->ClipMask; \
+ const GLuint sz = VB->ClipPtr->size; \
+ const line_func LineFunc = ctx->Driver.LineFunc; \
+ const triangle_func TriangleFunc = ctx->Driver.TriangleFunc; \
+ const quad_func QuadFunc = ctx->Driver.QuadFunc; \
+ (void) (LineFunc && TriangleFunc && QuadFunc); \
+ (void) elt; (void) mask; (void) sz;
+
+#define TAG(x) clip_##x##_verts
#define RESET_STIPPLE ctx->Driver.ResetLineStipple( ctx )
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE;
#define PRESERVE_VB_DEFS
#include "t_vb_rendertmp.h"
-/* Elts, no clipping.
+
+/* Elts, with the possibility of clipping.
*/
#undef ELT
#undef TAG
-#undef LOCAL_VARS
-#define TAG(x) x##_raw_elts
#define ELT(x) elt[x]
-#define LOCAL_VARS \
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; \
- const GLuint * const elt = VB->Elts; \
- (void) elt;
+#define TAG(x) clip_##x##_elts
#include "t_vb_rendertmp.h"
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+#define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
+#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
-/* Vertices, with the possibility of clipping.
+
+/* Vertices, no clipping.
*/
-#define RENDER_POINTS( start, count ) \
- ctx->Driver.PointsFunc( ctx, start, count-1 )
+#define RENDER_POINTS( start, count ) \
+ ctx->Driver.PointsFunc( ctx, start, count )
-#define RENDER_LINE( i1, i ) \
- draw_line( ctx, i1, i )
+#define RENDER_LINE( v1, v2 ) \
+ LineFunc( ctx, v1, v2 )
-#define RENDER_TRI( i2, i1, i, pv, parity) \
-do { \
- GLuint e2=i2, e1=i1; \
- if (parity) { GLuint t=e2; e2=e1; e1=t; } \
- draw_triangle(ctx,e2,e1,i,pv); \
-} while (0)
+#define RENDER_TRI( v1, v2, v3 ) \
+ TriangleFunc( ctx, v1, v2, v3 )
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
- draw_quad(ctx,i3,i2,i1,i,pv)
+#define RENDER_QUAD( v1, v2, v3, v4 ) \
+ QuadFunc( ctx, v1, v2, v3, v4 )
+#define TAG(x) _tnl_##x##_verts
#define LOCAL_VARS \
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; \
- (void)VB;
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; \
+ const GLuint * const elt = VB->Elts; \
+ const line_func LineFunc = ctx->Driver.LineFunc; \
+ const triangle_func TriangleFunc = ctx->Driver.TriangleFunc; \
+ const quad_func QuadFunc = ctx->Driver.QuadFunc; \
+ (void) (LineFunc && TriangleFunc && QuadFunc); \
+ (void) elt;
-#define TAG(x) x##_clipped
#define RESET_STIPPLE ctx->Driver.ResetLineStipple( ctx )
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE;
+#define RENDER_TAB_QUALIFIER
#define PRESERVE_VB_DEFS
#include "t_vb_rendertmp.h"
-
-/* Elts, with the possibility of clipping.
+/* Elts, no clipping.
*/
#undef ELT
-#undef TAG
-#undef LOCAL_VARS
+#define TAG(x) _tnl_##x##_elts
#define ELT(x) elt[x]
-#define LOCAL_VARS \
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; \
- const GLuint * const elt = VB->Elts; \
- (void) elt;
-#define TAG(x) x##_clipped_elts
-
#include "t_vb_rendertmp.h"
+
/**********************************************************************/
/* Clip and render whole vertex buffers */
/**********************************************************************/
@@ -520,40 +568,29 @@ static GLboolean run_render( GLcontext *ctx,
render_func *tab;
GLint pass = 0;
-/* return GL_FALSE; */
+ VB->interpfunc = RENDER_STAGE_DATA(stage)->interp;
+ VB->copypvfunc = RENDER_STAGE_DATA(stage)->copypv;
- VB->interpfunc = (void *)RENDER_STAGE_DATA(stage)->interp;
+ /* Allow the drivers to lock before projected verts are built so
+ * that window coordinates are guarenteed not to change before
+ * rendering.
+ */
+ if (ctx->Driver.RenderStart)
+ ctx->Driver.RenderStart( ctx );
- if (new_inputs) {
- GLuint importable = new_inputs & VB->importable_data;
- GLuint interested = 0;
-
- if (VB->ClipOrMask)
- interested = ~0;
-
- if (ctx->_TriangleCaps & DD_TRI_UNFILLED)
- interested |= VERT_EDGE;
-
- importable &= interested;
-
- if (importable)
- VB->import_data( ctx, importable, VEC_NOT_WRITEABLE|VEC_BAD_STRIDE);
-
- if (ctx->Driver.BuildProjectedVertices)
- ctx->Driver.BuildProjectedVertices( ctx, 0, VB->Count, new_inputs);
- }
+ if (VB->ClipOrMask) {
+ tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
- /* Rendering is considered a side-effect, and must be repeated each
- * time the stage is run, even if no inputs have changed.
- */
- if (VB->Elts) {
- tab = VB->ClipOrMask ? render_tab_clipped_elts : render_tab_raw_elts;
- } else {
- tab = VB->ClipOrMask ? render_tab_clipped : render_tab_raw;
+ if (new_inputs & VB->importable_data)
+ VB->import_data( ctx,
+ new_inputs & VB->importable_data,
+ VEC_NOT_WRITEABLE|VEC_BAD_STRIDE);
}
+ else {
+ tab = VB->Elts ? ctx->Driver.RenderTabElts : ctx->Driver.RenderTabVerts;
+ }
- if (ctx->Driver.RenderStart)
- ctx->Driver.RenderStart( ctx );
+ ctx->Driver.BuildProjectedVertices( ctx, 0, VB->Count, new_inputs );
do
{
@@ -564,9 +601,6 @@ static GLboolean run_render( GLcontext *ctx,
length= VB->PrimitiveLength[i];
ASSERT(length || (flags & PRIM_LAST));
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
-/* fprintf(stderr, "render %s %d..%d\n", */
-/* _mesa_prim_name[flags & PRIM_MODE_MASK], */
-/* i, i+length); */
if (length)
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
}
@@ -595,6 +629,7 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
{
struct render_stage_data *store = RENDER_STAGE_DATA(stage);
GLuint interp = 0;
+ GLuint copy = 0;
GLuint inputs = VERT_CLIP;
GLuint i;
@@ -643,6 +678,12 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
inputs |= VERT_TEX_ANY;
}
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ copy = interp & (INTERP_RGBA|INTERP_SPEC|INTERP_INDEX);
+ interp &= ~copy;
+ }
+
+ store->copypv = copy_tab[copy];
store->interp = interp_tab[interp];
stage->inputs = inputs;
}
@@ -688,6 +729,7 @@ const struct gl_pipeline_stage _tnl_render_stage =
"render",
(_NEW_BUFFERS |
_DD_NEW_SEPERATE_SPECULAR |
+ _DD_NEW_FLATSHADE |
_NEW_TEXTURE|
_NEW_LIGHT|
_NEW_POINT|
diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h
index 5712d342d2..9c9271ff22 100644
--- a/src/mesa/tnl/t_vb_rendertmp.h
+++ b/src/mesa/tnl/t_vb_rendertmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_rendertmp.h,v 1.3 2000/12/28 22:11:06 keithw Exp $ */
+/* $Id: t_vb_rendertmp.h,v 1.4 2001/01/05 02:26:49 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,6 +60,10 @@
#define ELT(x) x
#endif
+#ifndef RENDER_TAB_QUALIFIER
+#define RENDER_TAB_QUALIFIER static
+#endif
+
static void TAG(render_points)( GLcontext *ctx,
GLuint start,
GLuint count,
@@ -68,7 +72,6 @@ static void TAG(render_points)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
RESET_OCCLUSION;
INIT(GL_POINTS);
RENDER_POINTS( start, count );
@@ -84,7 +87,6 @@ static void TAG(render_lines)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
RESET_OCCLUSION;
INIT(GL_LINES);
for (j=start+1; j<count; j+=2 ) {
@@ -104,7 +106,6 @@ static void TAG(render_line_strip)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
RESET_OCCLUSION;
INIT(GL_LINES);
@@ -128,7 +129,6 @@ static void TAG(render_line_loop)( GLcontext *ctx,
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
RESET_OCCLUSION;
INIT(GL_LINES);
@@ -160,18 +160,17 @@ static void TAG(render_triangles)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
for (j=start+2; j<count; j+=3) {
/* Leave the edgeflags as supplied by the user.
*/
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j), ELT(j), 0 );
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
RESET_STIPPLE;
}
} else {
for (j=start+2; j<count; j+=3) {
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j), ELT(j), 0 );
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
}
}
POSTFIX;
@@ -191,15 +190,11 @@ static void TAG(render_tri_strip)( GLcontext *ctx,
if (TEST_PRIM_PARITY(flags))
parity = 1;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
for (j=start+2;j<count;j++,parity^=1) {
- /* All edges are boundary. Set edgeflags to 1, draw the
- * triangle, and restore them to the original values.
- */
- GLuint ej2 = ELT(j-2);
- GLuint ej1 = ELT(j-1);
+ GLuint ej2 = ELT(j-2+parity);
+ GLuint ej1 = ELT(j-1-parity);
GLuint ej = ELT(j);
GLboolean ef2 = EDGEFLAG_GET( ej2 );
GLboolean ef1 = EDGEFLAG_GET( ej1 );
@@ -207,15 +202,15 @@ static void TAG(render_tri_strip)( GLcontext *ctx,
EDGEFLAG_SET( ej2, GL_TRUE );
EDGEFLAG_SET( ej1, GL_TRUE );
EDGEFLAG_SET( ej, GL_TRUE );
- RENDER_TRI( ej2, ej1, ej, ej, parity );
+ RENDER_TRI( ej2, ej1, ej );
EDGEFLAG_SET( ej2, ef2 );
EDGEFLAG_SET( ej1, ef1 );
EDGEFLAG_SET( ej, ef );
RESET_STIPPLE;
}
} else {
- for (j=start+2;j<count;j++,parity^=1) {
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j), ELT(j), parity );
+ for (j=start+2; j<count ; j++, parity^=1) {
+ RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
}
}
POSTFIX;
@@ -231,7 +226,6 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
for (j=start+2;j<count;j++) {
@@ -246,7 +240,7 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
EDGEFLAG_SET( ejs, GL_TRUE );
EDGEFLAG_SET( ej1, GL_TRUE );
EDGEFLAG_SET( ej, GL_TRUE );
- RENDER_TRI( ejs, ej1, ej, ej, 0);
+ RENDER_TRI( ejs, ej1, ej);
EDGEFLAG_SET( ejs, efs );
EDGEFLAG_SET( ej1, ef1 );
EDGEFLAG_SET( ej, ef );
@@ -254,7 +248,7 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
}
} else {
for (j=start+2;j<count;j++) {
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j), ELT(j), 0 );
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
}
}
@@ -262,22 +256,15 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
}
-/* This is a bit of a hack. Clipping produces polygons and really
- * wants to use this function to render them (in particular to get the
- * edgeflags right). However, the rule that pv==start for polys
- * doens't hold there, hence the extra arg and the wrapper below.
- */
-static void TAG(render_poly_pv)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags,
- GLuint pv )
+static void TAG(render_poly)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
{
GLuint j = start+2;
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
GLboolean efstart = EDGEFLAG_GET( ELT(start) );
@@ -300,7 +287,7 @@ static void TAG(render_poly_pv)( GLcontext *ctx,
if (j<count-1) {
GLboolean ef = EDGEFLAG_GET( ELT(j) );
EDGEFLAG_SET( ELT(j), GL_FALSE );
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j), ELT(pv), 0 );
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
EDGEFLAG_SET( ELT(j), ef );
j++;
@@ -311,7 +298,7 @@ static void TAG(render_poly_pv)( GLcontext *ctx,
for (;j<count-1;j++) {
GLboolean efj = EDGEFLAG_GET( ELT(j) );
EDGEFLAG_SET( ELT(j), GL_FALSE );
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j), ELT(pv), 0 );
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
EDGEFLAG_SET( ELT(j), efj );
}
}
@@ -319,7 +306,7 @@ static void TAG(render_poly_pv)( GLcontext *ctx,
/* Draw the last or only triangle
*/
if (j < count)
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j), ELT(pv), 0 );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
/* Restore the first and last edgeflags:
*/
@@ -332,21 +319,12 @@ static void TAG(render_poly_pv)( GLcontext *ctx,
}
else {
for (j=start+2;j<count;j++) {
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j), ELT(start), 0 );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
}
}
POSTFIX;
}
-static void TAG(render_poly)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
- TAG(render_poly_pv)( ctx, start, count, flags, start );
-}
-
static void TAG(render_quads)( GLcontext *ctx,
GLuint start,
GLuint count,
@@ -356,18 +334,17 @@ static void TAG(render_quads)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
for (j=start+3; j<count; j+=4) {
/* Use user-specified edgeflags for quads.
*/
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j), ELT(j) );
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
RESET_STIPPLE;
}
} else {
for (j=start+3; j<count; j+=4) {
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j), ELT(j) );
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
}
}
POSTFIX;
@@ -382,7 +359,6 @@ static void TAG(render_quad_strip)( GLcontext *ctx,
LOCAL_VARS;
(void) flags;
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
INIT(GL_POLYGON);
if (NEED_EDGEFLAG_SETUP) {
for (j=start+3;j<count;j+=2) {
@@ -397,7 +373,7 @@ static void TAG(render_quad_strip)( GLcontext *ctx,
EDGEFLAG_SET( ELT(j-2), GL_TRUE );
EDGEFLAG_SET( ELT(j-1), GL_TRUE );
EDGEFLAG_SET( ELT(j), GL_TRUE );
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j), ELT(j-1), ELT(j) );
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
EDGEFLAG_SET( ELT(j-3), ef3 );
EDGEFLAG_SET( ELT(j-2), ef2 );
EDGEFLAG_SET( ELT(j-1), ef1 );
@@ -406,7 +382,7 @@ static void TAG(render_quad_strip)( GLcontext *ctx,
}
} else {
for (j=start+3;j<count;j+=2) {
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j), ELT(j-1), ELT(j) );
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
}
}
POSTFIX;
@@ -417,14 +393,13 @@ static void TAG(render_noop)( GLcontext *ctx,
GLuint count,
GLuint flags )
{
-/* fprintf(stderr, "%s %d..%d\n", __FUNCTION__, start, count); */
(void)(ctx && start && count && flags);
}
-static void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
- GLuint,
- GLuint,
- GLuint) =
+RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
{
TAG(render_points),
TAG(render_lines),
@@ -452,6 +427,7 @@ static void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
#undef RESET_STIPPLE
#undef DBG
#undef ELT
+#undef RENDER_TAB_QUALIFIER
#endif
#ifndef PRESERVE_TAG