diff options
Diffstat (limited to 'src/mesa/tnl/t_array_api.c')
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 162 |
1 files changed, 79 insertions, 83 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 0c61dee780..900467c98d 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.5 2001/02/04 00:44:36 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.6 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -90,6 +90,79 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, } +static void _tnl_draw_elements( GLcontext *ctx, GLenum mode, GLsizei count, + const GLuint *indices) +{ +#if 1 + /* Optimized code that fakes the effect of calling + * _tnl_array_element for each index in the list. + */ + if (_tnl_hard_begin( ctx, mode )) { + GLuint i,j; + for (j = 0 ; j < count ; ) { + struct immediate *IM = TNL_CURRENT_IM(ctx); + GLuint start = IM->Start; + GLuint nr = MIN2( IMM_MAXDATA - start, count - j ) + start; + GLuint sf = IM->Flag[start]; + IM->FlushElt |= 1; + + for (i = start ; i < nr ; i++) { + IM->Elt[i] = (GLuint) *indices++; + IM->Flag[i] = VERT_ELT; + } + + if (j == 0) IM->Flag[start] |= sf; + + IM->Count = nr; + j += nr - start; + + if (j == count) + _tnl_end( ctx ); + + _tnl_flush_immediate( IM ); + } + } +#else + /* Simple version of the above code. + */ + if (_tnl_hard_begin(ctx, mode)) { + GLuint i; + for (i = 0 ; i < count ; i++) + _tnl_array_element( ctx, indices[i] ); + _tnl_end( ctx ); + } +#endif +} + + +static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, + GLuint start, GLuint end, + GLsizei count, const GLuint *indices ) + +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + FLUSH_CURRENT( ctx, 0 ); + + _tnl_vb_bind_arrays( ctx, start, end ); + + tnl->vb.FirstPrimitive = 0; + tnl->vb.Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + tnl->vb.PrimitiveLength[0] = count; + tnl->vb.Elts = (GLuint *)indices; + + if (ctx->Array.LockCount) + _tnl_run_pipeline( ctx ); + else { + /* Note that arrays may have changed before/after execution. + */ + tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + _tnl_run_pipeline( ctx ); + tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + } +} + + + void _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) @@ -162,81 +235,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) } - -static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, - GLsizei count, const GLuint *indices ) - -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - FLUSH_CURRENT( ctx, 0 ); - - _tnl_vb_bind_arrays( ctx, start, end ); - - tnl->vb.FirstPrimitive = 0; - tnl->vb.Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; - tnl->vb.PrimitiveLength[0] = count; - tnl->vb.Elts = (GLuint *)indices; - - if (ctx->Array.LockCount) - _tnl_run_pipeline( ctx ); - else { - /* Note that arrays may have changed before/after execution. - */ - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; - _tnl_run_pipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; - } -} - - - - -static void _tnl_draw_elements( GLcontext *ctx, GLenum mode, GLsizei count, - const GLuint *indices) -{ -#if 1 - /* Optimized code that fakes the effect of calling - * _tnl_array_element for each index in the list. - */ - if (_tnl_hard_begin( ctx, mode )) { - GLuint i,j; - for (j = 0 ; j < count ; ) { - struct immediate *IM = TNL_CURRENT_IM(ctx); - GLuint start = IM->Start; - GLuint nr = MIN2( IMM_MAXDATA - start, count - j ) + start; - GLuint sf = IM->Flag[start]; - IM->FlushElt |= 1; - - for (i = start ; i < nr ; i++) { - IM->Elt[i] = (GLuint) *indices++; - IM->Flag[i] = VERT_ELT; - } - - if (j == 0) IM->Flag[start] |= sf; - - IM->Count = nr; - j += nr - start; - - if (j == count) - _tnl_end( ctx ); - - _tnl_flush_immediate( IM ); - } - } -#else - /* Simple version of the above code. - */ - if (_tnl_hard_begin(ctx, mode)) { - GLuint i; - for (i = 0 ; i < count ; i++) - _tnl_array_element( ctx, indices[i] ); - _tnl_end( ctx ); - } -#endif -} - - void _tnl_DrawRangeElements(GLenum mode, GLuint start, GLuint end, @@ -276,6 +274,8 @@ _tnl_DrawRangeElements(GLenum mode, * May be able to get away with just setting LockCount==0, * though this raises the problems of dependent state. May * have to call glUnlockArrays() directly? + * + * Or scan the list and replace bad indices? */ gl_problem( ctx, "DrawRangeElements references " @@ -283,8 +283,8 @@ _tnl_DrawRangeElements(GLenum mode, } } else if (end + 1 - start < ctx->Const.MaxArrayLockSize) { - /* The arrays aren't locked but we can still fit them inside a single - * vertexbuffer. + /* The arrays aren't locked but we can still fit them inside a + * single vertexbuffer. */ _tnl_draw_range_elements( ctx, mode, start, end + 1, count, ui_indices ); } else { @@ -315,7 +315,6 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); -#if 1 if (ctx->Array.LockCount) { _tnl_draw_range_elements( ctx, mode, ctx->Array.LockFirst, @@ -333,13 +332,10 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, if (max_elt < ctx->Const.MaxArrayLockSize && /* can we use it? */ max_elt < count) /* do we want to use it? */ - _tnl_draw_range_elements( ctx, mode, 0, max_elt + 1, count, ui_indices ); + _tnl_draw_range_elements( ctx, mode, 0, max_elt+1, count, ui_indices ); else _tnl_draw_elements( ctx, mode, count, ui_indices ); } -#else - _tnl_draw_elements( ctx, mode, count, ui_indices ); -#endif } |