diff options
author | Keith Whitwell <[email protected]> | 2002-04-09 16:56:50 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2002-04-09 16:56:50 +0000 |
commit | 306d3fcdbad523428501833405e47e9897896def (patch) | |
tree | 1d26788cd7848fa776d4ab9b89ef72f524ec8bed /src/mesa/tnl/t_imm_api.c | |
parent | e503d8b56f45aceb719adc3db3a855a0bda6bb13 (diff) |
bring in changes from dri tcl branch
Diffstat (limited to 'src/mesa/tnl/t_imm_api.c')
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 149 |
1 files changed, 89 insertions, 60 deletions
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index d19f6a6e007..a67851df139 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.25 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_imm_api.c,v 1.26 2002/04/09 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -53,6 +53,10 @@ void _tnl_flush_immediate( struct immediate *IM ) { GLcontext *ctx = IM->backref; + if (MESA_VERBOSE & VERBOSE_IMMEDIATE) + fprintf(stderr, "_tnl_flush_immediate IM: %d compiling: %d\n", + IM->id, ctx->CompileFlag); + if (IM->FlushElt == FLUSH_ELT_EAGER) { _tnl_translate_array_elts( ctx, IM, IM->LastPrimitive, IM->Count ); } @@ -69,10 +73,18 @@ void _tnl_flush_immediate( struct immediate *IM ) } +/* Hook for ctx->Driver.FlushVertices: + */ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) { struct immediate *IM = TNL_CURRENT_IM(ctx); + if (MESA_VERBOSE & VERBOSE_IMMEDIATE) + fprintf( stderr, + "_tnl_flush_vertices flags %x IM(%d) %d..%d Flag[%d]: %x\n", + flags, IM->id, IM->Start, IM->Count, IM->Start, + IM->Flag[IM->Start]); + if (IM->Flag[IM->Start]) if ((flags & FLUSH_UPDATE_CURRENT) || IM->Count > IM->Start) _tnl_flush_immediate( IM ); @@ -81,29 +93,23 @@ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags ) -/* Note the ctx argument. This function called only by _tnl_Begin, - * _tnl_save_Begin and _tnl_hard_begin() in this file. - */ -static void -_tnl_begin( GLcontext *ctx, GLenum p ) +void +_tnl_save_Begin( GLenum mode ) { + GET_CURRENT_CONTEXT(ctx); struct immediate *IM = TNL_CURRENT_IM(ctx); GLuint inflags, state; - if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glBegin(IM %d) %s\n", IM->id, - _mesa_lookup_enum_by_nr(p)); +/* fprintf(stderr, "%s: before: %x\n", __FUNCTION__, IM->BeginState); */ + + if (mode > GL_POLYGON) { + _mesa_compile_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" ); + return; + } if (ctx->NewState) _mesa_update_state(ctx); - /* if only a very few slots left, might as well flush now - */ - if (IM->Count > IMM_MAXDATA-8) { - _tnl_flush_immediate( IM ); - IM = TNL_CURRENT_IM(ctx); - } - /* Check for and flush buffered vertices from internal operations. */ if (IM->SavedBeginState) { @@ -124,7 +130,7 @@ _tnl_begin( GLcontext *ctx, GLenum p ) state |= (VERT_BEGIN_0|VERT_BEGIN_1); IM->Flag[count] |= VERT_BIT_BEGIN; - IM->Primitive[count] = p | PRIM_BEGIN; + IM->Primitive[count] = mode | PRIM_BEGIN; IM->PrimitiveLength[IM->LastPrimitive] = count - IM->LastPrimitive; IM->LastPrimitive = count; @@ -139,20 +145,15 @@ _tnl_begin( GLcontext *ctx, GLenum p ) ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; IM->BeginState = state; -} - -void -_tnl_save_Begin( GLenum mode ) -{ - GET_CURRENT_CONTEXT(ctx); - - if (mode > GL_POLYGON) { - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" ); - return; + if (ctx->ExecuteFlag) { + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" ); + } + else + ctx->Driver.CurrentExecPrimitive = mode; } - _tnl_begin( ctx, mode ); /* Update save_primitive now. */ @@ -167,18 +168,52 @@ void _tnl_Begin( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); + TNLcontext *tnl = TNL_CONTEXT(ctx); + ASSERT (!ctx->CompileFlag); if (mode > GL_POLYGON) { - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" ); + _mesa_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" ); return; } - _tnl_begin(ctx, mode); + if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" ); + return; + } - /* Update exec_primitive now. - */ - ASSERT (!ctx->CompileFlag); - if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) { + if (ctx->NewState) + _mesa_update_state(ctx); + + { + struct immediate *IM = TNL_CURRENT_IM(ctx); + GLuint count = IM->Count; + GLuint last = IM->LastPrimitive; + + if (IM->Start == IM->Count && + tnl->Driver.NotifyBegin && + tnl->Driver.NotifyBegin( ctx, mode )) + return; + + assert( IM->SavedBeginState == 0 ); + assert( IM->BeginState == 0 ); + + /* Not quite right. Need to use the fallback '_aa_ArrayElement' + * when not known to be inside begin/end and arrays are + * unlocked. + */ + if (IM->FlushElt == FLUSH_ELT_EAGER) { + _tnl_translate_array_elts( ctx, IM, last, count ); + } + + IM->Flag[count] |= VERT_BIT_BEGIN; + IM->Primitive[count] = mode | PRIM_BEGIN; + IM->PrimitiveLength[last] = count - last; + IM->LastPrimitive = count; + IM->BeginState = (VERT_BEGIN_0|VERT_BEGIN_1); + +/* fprintf(stderr, "%s: %x\n", __FUNCTION__, IM->BeginState); */ + + ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; ctx->Driver.CurrentExecPrimitive = mode; } } @@ -191,12 +226,13 @@ _tnl_Begin( GLenum mode ) GLboolean _tnl_hard_begin( GLcontext *ctx, GLenum p ) { +/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (!ctx->CompileFlag) { /* If not compiling, treat as a normal begin(). */ - _tnl_begin( ctx, p ); - ASSERT(ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END); - ctx->Driver.CurrentExecPrimitive = p; +/* fprintf(stderr, "%s: treating as glBegin\n", __FUNCTION__); */ + glBegin( p ); return GL_TRUE; } else { @@ -262,7 +298,7 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p ) return GL_TRUE; default: - ASSERT (0); + assert (0); return GL_TRUE; } } @@ -285,6 +321,8 @@ _tnl_end( GLcontext *ctx ) GLuint state = IM->BeginState; GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1); + assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES ); + state |= inflags << 2; /* errors */ if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1)) @@ -308,8 +346,11 @@ _tnl_end( GLcontext *ctx ) IM->BeginState = state; - if (!ctx->CompileFlag) { - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; + if (ctx->ExecuteFlag) { + if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) + _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_End" ); + else + ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; } /* You can set this flag to get the old 'flush_vb on glEnd()' @@ -1076,19 +1117,6 @@ _tnl_eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v ) EVALCOORD2( i, u, v ); } -void -_tnl_array_element( GLcontext *CC, GLint i ) -{ - struct immediate *im = TNL_CURRENT_IM(CC); - ARRAY_ELT( im, i ); -} - -void -_tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) -{ - struct immediate *im = TNL_CURRENT_IM(ctx); - VERTEX2( im, x, y ); -} @@ -1141,14 +1169,12 @@ _tnl_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) { GET_CURRENT_CONTEXT(ctx); -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - if (_tnl_hard_begin( ctx, GL_QUADS )) { - _tnl_vertex2f( ctx, x1, y1 ); - _tnl_vertex2f( ctx, x2, y1 ); - _tnl_vertex2f( ctx, x2, y2 ); - _tnl_vertex2f( ctx, x1, y2 ); - _tnl_end( ctx ); + glVertex2f( x1, y1 ); + glVertex2f( x2, y1 ); + glVertex2f( x2, y2 ); + glVertex2f( x1, y2 ); + glEnd(); } } @@ -1164,6 +1190,9 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (bitmask == 0) return; + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_Materialfv\n"); if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ |