diff options
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r-- | src/mesa/tnl/t_context.c | 12 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 106 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_cliptmp.h | 29 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_fog.c | 16 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 108 |
7 files changed, 201 insertions, 86 deletions
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 916f14bc57b..bea2e376508 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.15 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_context.c,v 1.16 2001/03/19 02:25:36 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -70,9 +70,6 @@ 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,9 +108,9 @@ _tnl_CreateContext( GLcontext *ctx ) */ _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt ); - ctx->Save->CallList = _mesa_save_CallList; /* fixme */ + ctx->Save->CallList = _mesa_save_CallList; ctx->Save->CallLists = _mesa_save_CallLists; - ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1; /* fixme */ + ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1; ctx->Save->EvalMesh2 = _mesa_save_EvalMesh2; ctx->Save->Begin = _tnl_save_Begin; @@ -123,6 +120,9 @@ _tnl_CreateContext( GLcontext *ctx ) ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT; ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; + + tnl->Driver.RenderTabElts = _tnl_render_tab_elts; + tnl->Driver.RenderTabVerts = _tnl_render_tab_verts; return GL_TRUE; } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 22d0423d162..f7465d98a82 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.17 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_context.h,v 1.18 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -364,8 +364,107 @@ struct tnl_eval_store { GLuint Elts[IMM_SIZE]; }; + +typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last ); +typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 ); +typedef void (*triangle_func)( GLcontext *ctx, + GLuint v1, GLuint v2, GLuint v3 ); +typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2, + GLuint v3, GLuint v4 ); +typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count, + GLuint flags ); +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 ); + + +struct tnl_device_driver { + /*** + *** TNL Pipeline + ***/ + + void (*PipelineStart)(GLcontext *ctx); + void (*PipelineFinish)(GLcontext *ctx); + /* Called before and after all pipeline stages. + * These are a suitable place for grabbing/releasing hardware locks. + */ + + /*** + *** Rendering + ***/ + + void (*RenderStart)(GLcontext *ctx); + void (*RenderFinish)(GLcontext *ctx); + /* Called before and after all rendering operations, including DrawPixels, + * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. + * These are a suitable place for grabbing/releasing hardware locks. + */ + + void (*RenderPrimitive)(GLcontext *ctx, GLenum mode); + /* Called between RednerStart() and RenderFinish() to indicate the + * type of primitive we're about to draw. Mode will be one of the + * modes accepted by glBegin(). + */ + + interp_func RenderInterp; + copy_pv_func RenderCopyPV; + void (*RenderClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n ); + void (*RenderClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 ); + /* Functions to interpolate between prebuilt vertices, copy flat-shade + * provoking color, and to render clipped primitives. + */ + + points_func PointsFunc; /* must now respect vb->elts */ + line_func LineFunc; + triangle_func TriangleFunc; + quad_func QuadFunc; + /* These functions are called in order to render points, lines, + * triangles and quads. These are only called via the T&L module. + */ + + render_func *RenderTabVerts; + render_func *RenderTabElts; + /* Render whole unclipped primitives (points, lines, linestrips, + * lineloops, etc). The tables are indexed by the GL enum of the + * primitive to be rendered. + */ + + void (*ResetLineStipple)( GLcontext *ctx ); + /* Reset the hardware's line stipple counter. + */ + + void (*BuildProjectedVertices)( GLcontext *ctx, + GLuint start, GLuint end, + GLuint new_inputs); + /* 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. + */ + + + GLboolean (*MultipassFunc)( GLcontext *ctx, GLuint passno ); + /* Driver may request additional render passes by returning GL_TRUE + * when this function is called. This function will be called + * after the first pass, and passes will be made until the function + * returns GL_FALSE. If no function is registered, only one pass + * is made. + * + * This function will be first invoked with passno == 1. + */ +}; + + typedef struct { + /* Driver interface. + */ + struct tnl_device_driver Driver; + /* Track whether the module is active. */ GLboolean bound_exec; @@ -386,7 +485,10 @@ typedef struct { GLuint *tmp_primitive; GLuint *tmp_primitive_length; - /* Set when executing an internally generated immediate. + /* Set when executing an internally generated begin/end object. If + * such an object is encountered in a display list, it will be + * replayed only if the list is outside any existing begin/end + * objects. */ GLboolean ReplayHardBeginEnd; GLenum CurrentPrimitive; diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index d6cc0ecb09c..4a7ed8d94f6 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_api.c,v 1.8 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_imm_api.c,v 1.9 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -199,8 +199,6 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p ) */ ASSERT (IM->SavedBeginState == 0); -/* ASSERT (ctx->Driver.CurrentSavePrimitive >= GL_POLYGON+1); */ - /* Push current beginstate, to be restored later. Don't worry * about raising errors. */ @@ -330,8 +328,6 @@ _tnl_end( GLcontext *ctx ) _tnl_translate_array_elts( ctx, IM, last, count ); IM->FlushElt = 0; } - -/* ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; */ } IM->BeginState = state; diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index 0d43a1fbcab..2cbbb4d6a40 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.c,v 1.14 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_pipeline.c,v 1.15 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -132,8 +132,8 @@ void _tnl_run_pipeline( GLcontext *ctx ) ASSERT(pipe->build_state_changes == 0); START_FAST_MATH(__tmp); - if (ctx->Driver.PipelineStart) - ctx->Driver.PipelineStart( ctx ); + if (tnl->Driver.PipelineStart) + tnl->Driver.PipelineStart( ctx ); /* If something changes in the pipeline, tag all subsequent stages * using this value for recalculation. @@ -160,8 +160,8 @@ void _tnl_run_pipeline( GLcontext *ctx ) } } - if (ctx->Driver.PipelineFinish) - ctx->Driver.PipelineFinish( ctx ); + if (tnl->Driver.PipelineFinish) + tnl->Driver.PipelineFinish( ctx ); END_FAST_MATH(__tmp); pipe->run_state_changes = 0; diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 371563a6b02..6ecd1c3c605 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.9 2001/03/12 00:48:43 gareth Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.10 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -122,8 +122,9 @@ static __inline void TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask ) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - interp_func interp = ctx->Driver.RenderInterp; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + interp_func interp = tnl->Driver.RenderInterp; GLfloat (*coord)[4] = VB->ClipPtr->data; GLuint ii = i, jj = j, p; @@ -151,9 +152,9 @@ static __inline void TAG(clip_line)( GLcontext *ctx, } if ((ctx->_TriangleCaps & DD_FLATSHADE) && j != jj) - ctx->Driver.RenderCopyPV( ctx, jj, j ); + tnl->Driver.RenderCopyPV( ctx, jj, j ); - ctx->Driver.RenderClippedLine( ctx, ii, jj ); + tnl->Driver.RenderClippedLine( ctx, ii, jj ); } @@ -163,8 +164,9 @@ static __inline void TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - interp_func interp = ctx->Driver.RenderInterp; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + interp_func interp = tnl->Driver.RenderInterp; GLfloat (*coord)[4] = VB->ClipPtr->data; GLuint pv = v0; GLuint vlist[2][MAX_CLIPPED_VERTICES]; @@ -201,11 +203,11 @@ static __inline void TAG(clip_tri)( GLcontext *ctx, if (ctx->_TriangleCaps & DD_FLATSHADE) { if (pv != inlist[0]) { ASSERT( inlist[0] >= VB->FirstClipped ); - ctx->Driver.RenderCopyPV( ctx, inlist[0], pv ); + tnl->Driver.RenderCopyPV( ctx, inlist[0], pv ); } } - ctx->Driver.RenderClippedPolygon( ctx, inlist, n ); + tnl->Driver.RenderClippedPolygon( ctx, inlist, n ); } @@ -215,8 +217,9 @@ static __inline void TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLubyte mask ) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - interp_func interp = ctx->Driver.RenderInterp; + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + interp_func interp = tnl->Driver.RenderInterp; GLfloat (*coord)[4] = VB->ClipPtr->data; GLuint pv = v0; GLuint vlist[2][MAX_CLIPPED_VERTICES]; @@ -253,11 +256,11 @@ static __inline void TAG(clip_quad)( GLcontext *ctx, if (ctx->_TriangleCaps & DD_FLATSHADE) { if (pv != inlist[0]) { ASSERT( inlist[0] >= VB->FirstClipped ); - ctx->Driver.RenderCopyPV( ctx, inlist[0], pv ); + tnl->Driver.RenderCopyPV( ctx, inlist[0], pv ); } } - ctx->Driver.RenderClippedPolygon( ctx, inlist, n ); + tnl->Driver.RenderClippedPolygon( ctx, inlist, n ); } #undef W diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 0cffbbb0d15..79d72e45676 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_fog.c,v 1.8 2001/03/12 00:48:44 gareth Exp $ */ +/* $Id: t_vb_fog.c,v 1.9 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -135,12 +135,15 @@ static GLboolean run_fog_stage( GLcontext *ctx, struct fog_stage_data *store = FOG_STAGE_DATA(stage); GLvector1f *input; - VB->FogCoordPtr = &store->fogcoord; - if (stage->changed_inputs == 0) return GL_TRUE; if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { + /* fog computed from Z depth */ + /* source = VB->ObjPtr or VB->EyePtr coords */ + /* dest = VB->FogCoordPtr = fog stage private storage */ + VB->FogCoordPtr = &store->fogcoord; + if (!ctx->_NeedEyeCoords) { GLfloat *m = ctx->ModelView.m; GLfloat plane[4]; @@ -174,8 +177,13 @@ static GLboolean run_fog_stage( GLcontext *ctx, input->stride = VB->EyePtr->stride; input->count = VB->EyePtr->count; } - } else + } else { + /* use glFogCoord() coordinates */ + /* source = VB->FogCoordPtr */ input = VB->FogCoordPtr; + /* dest = fog stage private storage */ + VB->FogCoordPtr = &store->fogcoord; + } make_win_fog_coords( ctx, VB->FogCoordPtr, input ); return GL_TRUE; diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 03c8943de19..95bc403e70b 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.15 2001/03/12 00:48:44 gareth Exp $ */ +/* $Id: t_vb_render.c,v 1.16 2001/03/19 02:25:37 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -123,7 +123,7 @@ do { \ /* Vertices, with the possibility of clipping. */ #define RENDER_POINTS( start, count ) \ - ctx->Driver.PointsFunc( ctx, start, count ) + tnl->Driver.PointsFunc( ctx, start, count ) #define RENDER_LINE( v1, v2 ) \ do { \ @@ -157,21 +157,22 @@ do { \ } while (0) -#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; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) (LineFunc && TriangleFunc && QuadFunc); \ - (void) elt; (void) mask; (void) sz; (void) stipple; +#define LOCAL_VARS \ + TNLcontext *tnl = TNL_CONTEXT(ctx); \ + struct vertex_buffer *VB = &tnl->vb; \ + const GLuint * const elt = VB->Elts; \ + const GLubyte *mask = VB->ClipMask; \ + const GLuint sz = VB->ClipPtr->size; \ + const line_func LineFunc = tnl->Driver.LineFunc; \ + const triangle_func TriangleFunc = tnl->Driver.TriangleFunc; \ + const quad_func QuadFunc = tnl->Driver.QuadFunc; \ + const GLboolean stipple = ctx->Line.StippleFlag; \ + (void) (LineFunc && TriangleFunc && QuadFunc); \ + (void) elt; (void) mask; (void) sz; (void) stipple; #define TAG(x) clip_##x##_verts -#define INIT(x) ctx->Driver.RenderPrimitive( ctx, x ) -#define RESET_STIPPLE if (stipple) ctx->Driver.ResetLineStipple( ctx ) +#define INIT(x) tnl->Driver.RenderPrimitive( ctx, x ) +#define RESET_STIPPLE if (stipple) tnl->Driver.ResetLineStipple( ctx ) #define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE #define PRESERVE_VB_DEFS #include "t_vb_rendertmp.h" @@ -193,15 +194,16 @@ static void clip_elt_triangles( GLcontext *ctx, GLuint count, GLuint flags ) { - GLuint j; - GLuint last = count-2; - render_func render_tris = ctx->Driver.RenderTabElts[GL_TRIANGLES]; - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + TNLcontext *tnl = TNL_CONTEXT(ctx); + render_func render_tris = tnl->Driver.RenderTabElts[GL_TRIANGLES]; + struct vertex_buffer *VB = &tnl->vb; const GLuint * const elt = VB->Elts; GLubyte *mask = VB->ClipMask; + GLuint last = count-2; + GLuint j; (void) flags; - ctx->Driver.RenderPrimitive( ctx, GL_TRIANGLES ); + tnl->Driver.RenderPrimitive( ctx, GL_TRIANGLES ); for (j=start; j < last; j+=3 ) { GLubyte c1 = mask[elt[j]]; @@ -233,7 +235,7 @@ static void clip_elt_triangles( GLcontext *ctx, /* Vertices, no clipping. */ #define RENDER_POINTS( start, count ) \ - ctx->Driver.PointsFunc( ctx, start, count ) + tnl->Driver.PointsFunc( ctx, start, count ) #define RENDER_LINE( v1, v2 ) \ LineFunc( ctx, v1, v2 ) @@ -246,18 +248,19 @@ static void clip_elt_triangles( GLcontext *ctx, #define TAG(x) _tnl_##x##_verts -#define LOCAL_VARS \ - 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 RESET_STIPPLE ctx->Driver.ResetLineStipple( ctx ) +#define LOCAL_VARS \ + TNLcontext *tnl = TNL_CONTEXT(ctx); \ + struct vertex_buffer *VB = &tnl->vb; \ + const GLuint * const elt = VB->Elts; \ + const line_func LineFunc = tnl->Driver.LineFunc; \ + const triangle_func TriangleFunc = tnl->Driver.TriangleFunc; \ + const quad_func QuadFunc = tnl->Driver.QuadFunc; \ + (void) (LineFunc && TriangleFunc && QuadFunc); \ + (void) elt; + +#define RESET_STIPPLE tnl->Driver.ResetLineStipple( ctx ) #define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE -#define INIT(x) ctx->Driver.RenderPrimitive( ctx, x ) +#define INIT(x) tnl->Driver.RenderPrimitive( ctx, x ) #define RENDER_TAB_QUALIFIER #define PRESERVE_VB_DEFS #include "t_vb_rendertmp.h" @@ -292,28 +295,31 @@ static GLboolean run_render( GLcontext *ctx, * that window coordinates are guarenteed not to change before * rendering. */ - ctx->Driver.RenderStart( ctx ); - - ASSERT(ctx->Driver.BuildProjectedVertices); - ASSERT(ctx->Driver.RenderPrimitive); - ASSERT(ctx->Driver.PointsFunc); - ASSERT(ctx->Driver.LineFunc); - ASSERT(ctx->Driver.TriangleFunc); - ASSERT(ctx->Driver.QuadFunc); - ASSERT(ctx->Driver.ResetLineStipple); - ASSERT(ctx->Driver.RenderInterp); - ASSERT(ctx->Driver.RenderCopyPV); - ASSERT(ctx->Driver.RenderClippedLine); - ASSERT(ctx->Driver.RenderClippedPolygon); - - ctx->Driver.BuildProjectedVertices( ctx, 0, VB->Count, new_inputs ); + ASSERT(tnl->Driver.RenderStart); + + tnl->Driver.RenderStart( ctx ); + + ASSERT(tnl->Driver.BuildProjectedVertices); + ASSERT(tnl->Driver.RenderPrimitive); + ASSERT(tnl->Driver.PointsFunc); + ASSERT(tnl->Driver.LineFunc); + ASSERT(tnl->Driver.TriangleFunc); + ASSERT(tnl->Driver.QuadFunc); + ASSERT(tnl->Driver.ResetLineStipple); + ASSERT(tnl->Driver.RenderInterp); + ASSERT(tnl->Driver.RenderCopyPV); + ASSERT(tnl->Driver.RenderClippedLine); + ASSERT(tnl->Driver.RenderClippedPolygon); + ASSERT(tnl->Driver.RenderFinish); + + tnl->Driver.BuildProjectedVertices( ctx, 0, VB->Count, new_inputs ); if (VB->ClipOrMask) { tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts; clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles; } else { - tab = VB->Elts ? ctx->Driver.RenderTabElts : ctx->Driver.RenderTabVerts; + tab = VB->Elts ? tnl->Driver.RenderTabElts : tnl->Driver.RenderTabVerts; } do @@ -328,11 +334,11 @@ static GLboolean run_render( GLcontext *ctx, if (length) tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); } - } while (ctx->Driver.MultipassFunc && - ctx->Driver.MultipassFunc( ctx, ++pass )); + } while (tnl->Driver.MultipassFunc && + tnl->Driver.MultipassFunc( ctx, ++pass )); - ctx->Driver.RenderFinish( ctx ); + tnl->Driver.RenderFinish( ctx ); return GL_FALSE; /* finished the pipe */ } |