diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2001-01-16 05:29:42 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2001-01-16 05:29:42 +0000 |
commit | d43a5943d8952367d9292653800b47a85f905343 (patch) | |
tree | a33ce0af1f3396c6921643f4662df2ad719a0a34 | |
parent | 230928ad5f325614288bc481d7135388c052f3ab (diff) |
Fix several conformance problems. Hack solution to line stipple problem.
-rw-r--r-- | src/mesa/drivers/glide/fxdd.c | 36 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxdrv.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 21 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_context.c | 138 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_context.h | 1 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_triangle.c | 95 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_tritmp.h | 10 | ||||
-rw-r--r-- | src/mesa/swrast_setup/swrast_setup.h | 12 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_rendertmp.h | 4 |
10 files changed, 198 insertions, 128 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 08285f67e8..fe918a7eac 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1028,10 +1028,40 @@ static void fxDDUpdateDDPointers(GLcontext *ctx, GLuint new_state) static void fxDDRenderPrimitive( GLcontext *ctx, GLenum mode ) { - (void) ctx; (void) mode; + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + + if (!fxMesa->is_in_hardware) { + _swsetup_RenderPrimitive( ctx, mode ); + } + else { + fxMesa->render_prim = mode; + } +} + + +static void fxDDRenderStart( GLcontext *ctx ) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + + if (!fxMesa->is_in_hardware) { + _swsetup_RenderStart( ctx ); + } + else if (fxMesa->new_state) { + fxSetupFXUnits( ctx ); + } +} + +static void fxDDRenderFinish( GLcontext *ctx ) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + + if (!fxMesa->is_in_hardware) { + _swsetup_RenderFinish( ctx ); + } } + void fxSetupDDPointers(GLcontext *ctx) { if (MESA_VERBOSE&VERBOSE_DRIVER) { @@ -1062,8 +1092,8 @@ void fxSetupDDPointers(GLcontext *ctx) ctx->Driver.Finish=fxDDFinish; ctx->Driver.Flush=NULL; - ctx->Driver.RenderStart=fxSetupFXUnits; - ctx->Driver.RenderFinish=_swrast_flush; + ctx->Driver.RenderStart=fxDDRenderStart; + ctx->Driver.RenderFinish=fxDDRenderFinish; ctx->Driver.ResetLineStipple=_swrast_ResetLineStipple; ctx->Driver.RenderPrimitive=fxDDRenderPrimitive; diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index cefd6d0e1a..6861160c1a 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -424,6 +424,7 @@ struct tfxMesaContext { GLuint render_index; GLuint passes, multipass; GLuint is_in_hardware; + GLenum render_prim; /* Current rasterization functions */ diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 21fe98cb49..77e4ab58c4 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -1,4 +1,4 @@ -/* $Id: xm_dd.c,v 1.9 2001/01/08 04:06:20 keithw Exp $ */ +/* $Id: xm_dd.c,v 1.10 2001/01/16 05:29:43 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -922,9 +922,16 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.Flush = flush; ctx->Driver.Finish = finish; - ctx->Driver.RenderStart = 0; - ctx->Driver.RenderPrimitive = _swsetup_RenderPrimNoop; - ctx->Driver.RenderFinish = _swrast_flush; + ctx->Driver.RenderStart = _swsetup_RenderStart; + ctx->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices; + ctx->Driver.RenderPrimitive = _swsetup_RenderPrimitive; + ctx->Driver.PointsFunc = _swsetup_Points; + ctx->Driver.LineFunc = _swsetup_Line; + ctx->Driver.TriangleFunc = _swsetup_Triangle; + ctx->Driver.QuadFunc = _swsetup_Quad; + ctx->Driver.ResetLineStipple = _swrast_ResetLineStipple; + ctx->Driver.RenderFinish = _swsetup_RenderFinish; + ctx->Driver.SetDrawBuffer = set_draw_buffer; ctx->Driver.SetReadBuffer = set_read_buffer; @@ -936,11 +943,5 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.ColorMask = color_mask; ctx->Driver.Enable = enable; - ctx->Driver.PointsFunc = _swsetup_Points; - ctx->Driver.LineFunc = _swsetup_Line; - ctx->Driver.TriangleFunc = _swsetup_Triangle; - ctx->Driver.QuadFunc = _swsetup_Quad; - ctx->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices; - ctx->Driver.ResetLineStipple = _swrast_ResetLineStipple; (void) DitherValues; /* silenced unused var warning */ } diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index de3f36288a..a6c7aa8740 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.7 2001/01/08 04:09:41 keithw Exp $ */ +/* $Id: ss_context.c,v 1.8 2001/01/16 05:29:43 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -27,64 +27,17 @@ * Keith Whitwell <keithw@valinux.com> */ - #include "glheader.h" #include "mem.h" - - #include "ss_context.h" #include "ss_triangle.h" #include "ss_vb.h" - #include "swrast_setup.h" - #include "tnl/t_context.h" -/* Stub for swsetup->Triangle to select a true triangle function - * after a state change. - */ -static void -_swsetup_validate_quad( GLcontext *ctx, GLuint v0, GLuint v1, - GLuint v2, GLuint v3 ) -{ - _swsetup_choose_trifuncs( ctx ); - SWSETUP_CONTEXT(ctx)->Quad( ctx, v0, v1, v2, v3 ); -} - -static void -_swsetup_validate_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2 ) -{ - _swsetup_choose_trifuncs( ctx ); - SWSETUP_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 ); -} - -static void -_swsetup_validate_line( GLcontext *ctx, GLuint v0, GLuint v1 ) -{ - _swsetup_choose_trifuncs( ctx ); - SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1 ); -} - - -static void -_swsetup_validate_points( GLcontext *ctx, GLuint first, GLuint last ) -{ - _swsetup_choose_trifuncs( ctx ); - SWSETUP_CONTEXT(ctx)->Points( ctx, first, last ); -} - - - -static void -_swsetup_validate_buildprojverts( GLcontext *ctx, - GLuint start, GLuint end, GLuint new_inputs ) -{ - _swsetup_choose_rastersetup_func( ctx ); - SWSETUP_CONTEXT(ctx)->BuildProjVerts( ctx, start, end, new_inputs ); -} - - + #define _SWSETUP_NEW_VERTS (_NEW_RENDERMODE| \ + _NEW_LIGHT| \ _NEW_TEXTURE| \ _NEW_COLOR| \ _NEW_FOG| \ @@ -93,38 +46,13 @@ _swsetup_validate_buildprojverts( GLcontext *ctx, #define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT) -#if 0 -/* TODO: sleep/wakeup mechanism - */ -static void -_swsetup_sleep( GLcontext *ctx, GLuint new_state ) -{ -} -#endif - -static void -_swsetup_invalidate_state( GLcontext *ctx, GLuint new_state ) -{ - SScontext *swsetup = SWSETUP_CONTEXT(ctx); - - swsetup->NewState |= new_state; - - if (new_state & _SWSETUP_NEW_RENDERINDEX) { - swsetup->Triangle = _swsetup_validate_triangle; - swsetup->Line = _swsetup_validate_line; - swsetup->Points = _swsetup_validate_points; - swsetup->Quad = _swsetup_validate_quad; - } - - if (new_state & _SWSETUP_NEW_VERTS) { - swsetup->BuildProjVerts = _swsetup_validate_buildprojverts; - } -} - - - /* Dispatch from these fixed entrypoints to the state-dependent - * functions: + * functions. + * + * The design of swsetup suggests that we could really program + * ctx->Driver.TriangleFunc directly from _swsetup_RenderStart, and + * avoid this second level of indirection. However, this is more + * convient for fallback cases in hardware rasterization drivers. */ void _swsetup_Quad( GLcontext *ctx, GLuint v0, GLuint v1, @@ -146,7 +74,6 @@ _swsetup_Line( GLcontext *ctx, GLuint v0, GLuint v1 ) SWSETUP_CONTEXT(ctx)->Line( ctx, v0, v1 ); } - void _swsetup_Points( GLcontext *ctx, GLuint first, GLuint last ) { @@ -160,12 +87,6 @@ _swsetup_BuildProjectedVertices( GLcontext *ctx, GLuint start, GLuint end, SWSETUP_CONTEXT(ctx)->BuildProjVerts( ctx, start, end, new_inputs ); } -void -_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ) -{ - SWSETUP_CONTEXT(ctx)->InvalidateState( ctx, new_state ); -} - GLboolean _swsetup_CreateContext( GLcontext *ctx ) @@ -185,13 +106,6 @@ _swsetup_CreateContext( GLcontext *ctx ) ctx->swsetup_context = swsetup; swsetup->NewState = ~0; - swsetup->InvalidateState = _swsetup_invalidate_state; - swsetup->Quad = _swsetup_validate_quad; - swsetup->Triangle = _swsetup_validate_triangle; - swsetup->Line = _swsetup_validate_line; - swsetup->Points = _swsetup_validate_points; - swsetup->BuildProjVerts = _swsetup_validate_buildprojverts; - _swsetup_vb_init( ctx ); _swsetup_trifuncs_init( ctx ); @@ -210,10 +124,38 @@ _swsetup_DestroyContext( GLcontext *ctx ) } } +void +_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode ) +{ + SWSETUP_CONTEXT(ctx)->render_prim = mode; +} + +void +_swsetup_RenderStart( GLcontext *ctx ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + GLuint new_state = swsetup->NewState; + + if (new_state & _SWSETUP_NEW_RENDERINDEX) { + _swsetup_choose_trifuncs( ctx ); + } + + if (new_state & _SWSETUP_NEW_VERTS) { + _swsetup_choose_rastersetup_func( ctx ); + } + + swsetup->NewState = 0; +} + +void +_swsetup_RenderFinish( GLcontext *ctx ) +{ + _swrast_flush( ctx ); +} void -_swsetup_RenderPrimNoop( GLcontext *ctx, GLenum mode ) +_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state ) { - (void) ctx; - (void) mode; + SWSETUP_CONTEXT(ctx)->NewState |= new_state; } + diff --git a/src/mesa/swrast_setup/ss_context.h b/src/mesa/swrast_setup/ss_context.h index 601ae9eb34..957a8fc3fc 100644 --- a/src/mesa/swrast_setup/ss_context.h +++ b/src/mesa/swrast_setup/ss_context.h @@ -54,6 +54,7 @@ typedef struct { void (*Points)( GLcontext *ctx, GLuint first, GLuint last ); SWvertex *verts; + GLenum render_prim; } SScontext; diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index 73a19ad38a..337a45acc5 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -26,6 +26,7 @@ */ #include "glheader.h" +#include "colormac.h" #include "macros.h" #include "mtypes.h" @@ -44,6 +45,100 @@ static triangle_func tri_tab[SS_MAX_TRIFUNC]; static quad_func quad_tab[SS_MAX_TRIFUNC]; +static void _swsetup_render_line_tri( GLcontext *ctx, + GLuint e0, GLuint e1, GLuint e2 ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + SWvertex *verts = swsetup->verts; + SWvertex *v0 = &verts[e0]; + SWvertex *v1 = &verts[e1]; + SWvertex *v2 = &verts[e2]; + GLchan c[2][4]; + GLchan s[2][4]; + GLuint i[2]; + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + COPY_CHAN4(c[0], v0->color); + COPY_CHAN4(c[1], v1->color); + COPY_CHAN4(s[0], v0->specular); + COPY_CHAN4(s[1], v1->specular); + i[0] = v0->index; + i[1] = v1->index; + + COPY_CHAN4(v0->color, v2->color); + COPY_CHAN4(v1->color, v2->color); + COPY_CHAN4(v0->specular, v2->specular); + COPY_CHAN4(v1->specular, v2->specular); + v0->index = v2->index; + v1->index = v2->index; + } + + if (swsetup->render_prim == GL_POLYGON) { + if (ef[e2]) _swrast_Line( ctx, v2, v0 ); + if (ef[e0]) _swrast_Line( ctx, v0, v1 ); + if (ef[e1]) _swrast_Line( ctx, v1, v2 ); + } else { + if (ef[e0]) _swrast_Line( ctx, v0, v1 ); + if (ef[e1]) _swrast_Line( ctx, v1, v2 ); + if (ef[e2]) _swrast_Line( ctx, v2, v0 ); + } + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + COPY_CHAN4(v0->color, c[0]); + COPY_CHAN4(v1->color, c[1]); + COPY_CHAN4(v0->specular, s[0]); + COPY_CHAN4(v1->specular, s[1]); + v0->index = i[0]; + v1->index = i[1]; + } +} + +static void _swsetup_render_point_tri( GLcontext *ctx, + GLuint e0, GLuint e1, GLuint e2 ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLubyte *ef = VB->EdgeFlag; + SWvertex *verts = swsetup->verts; + SWvertex *v0 = &verts[e0]; + SWvertex *v1 = &verts[e1]; + SWvertex *v2 = &verts[e2]; + GLchan c[2][4]; + GLchan s[2][4]; + GLuint i[2]; + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + COPY_CHAN4(c[0], v0->color); + COPY_CHAN4(c[1], v1->color); + COPY_CHAN4(s[0], v0->specular); + COPY_CHAN4(s[1], v1->specular); + i[0] = v0->index; + i[1] = v1->index; + + COPY_CHAN4(v0->color, v2->color); + COPY_CHAN4(v1->color, v2->color); + COPY_CHAN4(v0->specular, v2->specular); + COPY_CHAN4(v1->specular, v2->specular); + v0->index = v2->index; + v1->index = v2->index; + } + + if (ef[e0]) _swrast_Point( ctx, v0 ); + if (ef[e1]) _swrast_Point( ctx, v1 ); + if (ef[e2]) _swrast_Point( ctx, v2 ); + + if (ctx->_TriangleCaps & DD_FLATSHADE) { + COPY_CHAN4(v0->color, c[0]); + COPY_CHAN4(v1->color, c[1]); + COPY_CHAN4(v0->specular, s[0]); + COPY_CHAN4(v1->specular, s[1]); + v0->index = i[0]; + v1->index = i[1]; + } +} + #define SS_COLOR(a,b) COPY_4UBV(a,b) #define SS_SPEC(a,b) COPY_4UBV(a,b) #define SS_IND(a,b) (a = b) diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h index 936774aba4..cc0c511c35 100644 --- a/src/mesa/swrast_setup/ss_tritmp.h +++ b/src/mesa/swrast_setup/ss_tritmp.h @@ -99,25 +99,19 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } if (mode == GL_POINT) { - GLubyte *ef = VB->EdgeFlag; if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { v[0]->win[2] += offset; v[1]->win[2] += offset; v[2]->win[2] += offset; } - if (ef[e0]) _swrast_Point( ctx, v[0] ); - if (ef[e1]) _swrast_Point( ctx, v[1] ); - if (ef[e2]) _swrast_Point( ctx, v[2] ); + _swsetup_render_point_tri( ctx, e0, e1, e2 ); } else if (mode == GL_LINE) { - GLubyte *ef = VB->EdgeFlag; if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { v[0]->win[2] += offset; v[1]->win[2] += offset; v[2]->win[2] += offset; } - if (ef[e0]) _swrast_Line( ctx, v[0], v[1] ); - if (ef[e1]) _swrast_Line( ctx, v[1], v[2] ); - if (ef[e2]) _swrast_Line( ctx, v[2], v[0] ); + _swsetup_render_line_tri( ctx, e0, e1, e2 ); } else { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { v[0]->win[2] += offset; diff --git a/src/mesa/swrast_setup/swrast_setup.h b/src/mesa/swrast_setup/swrast_setup.h index 70b1113c90..f3607c75e9 100644 --- a/src/mesa/swrast_setup/swrast_setup.h +++ b/src/mesa/swrast_setup/swrast_setup.h @@ -25,7 +25,9 @@ * Keith Whitwell <keithw@valinux.com> */ -/* Public interface to the swrast_setup module. +/* Public interface to the swrast_setup module. This module provides + * an implementation of the driver interface to t_vb_render.c, and uses + * the software rasterizer (swrast) to perform actual rasterization. */ #ifndef SWRAST_SETUP_H @@ -59,6 +61,12 @@ extern void _swsetup_Points( GLcontext *ctx, GLuint first, GLuint last ); extern void -_swsetup_RenderPrimNoop( GLcontext *ctx, GLenum mode ); +_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode ); + +extern void +_swsetup_RenderStart( GLcontext *ctx ); + +extern void +_swsetup_RenderFinish( GLcontext *ctx ); #endif diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 684cb0212e..02d97f46d2 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.9 2001/01/08 21:56:00 keithw Exp $ */ +/* $Id: t_vb_render.c,v 1.10 2001/01/16 05:29:43 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -577,8 +577,7 @@ static GLboolean run_render( GLcontext *ctx, * that window coordinates are guarenteed not to change before * rendering. */ - if (ctx->Driver.RenderStart) - ctx->Driver.RenderStart( ctx ); + ctx->Driver.RenderStart( ctx ); if (VB->ClipOrMask) { tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts; @@ -611,9 +610,8 @@ static GLboolean run_render( GLcontext *ctx, } while (ctx->Driver.MultipassFunc && ctx->Driver.MultipassFunc( ctx, ++pass )); - if (ctx->Driver.RenderFinish) - ctx->Driver.RenderFinish( ctx ); + ctx->Driver.RenderFinish( ctx ); return GL_FALSE; /* finished the pipe */ } diff --git a/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h index c2e1c9051e..b6c2933ae8 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.6 2001/01/14 06:14:21 keithw Exp $ */ +/* $Id: t_vb_rendertmp.h,v 1.7 2001/01/16 05:29:43 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -348,7 +348,7 @@ static void TAG(render_quads)( GLcontext *ctx, } } POSTFIX; -} +} static void TAG(render_quad_strip)( GLcontext *ctx, GLuint start, |