diff options
Diffstat (limited to 'src/mesa/tnl/t_array_api.c')
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 1187538c736..0ad9ca419b3 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.24 2002/01/22 14:35:16 brianp Exp $ */ +/* $Id: t_array_api.c,v 1.25 2002/04/09 16:56:50 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -53,10 +53,9 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, { if (_tnl_hard_begin( ctx, mode )) { GLint i; - for (i = start; i < count; i++) { - _tnl_array_element( ctx, i ); - } - _tnl_end( ctx ); + for (i = start; i < count; i++) + glArrayElement( i ); + glEnd(); } } @@ -64,13 +63,11 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count, const GLuint *indices) { - /* Simple version of the above code. - */ if (_tnl_hard_begin(ctx, mode)) { GLint i; for (i = 0 ; i < count ; i++) - _tnl_array_element( ctx, indices[i] ); - _tnl_end( ctx ); + glArrayElement( indices[i] ); + glEnd(); } } @@ -82,6 +79,10 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, { TNLcontext *tnl = TNL_CONTEXT(ctx); FLUSH_CURRENT( ctx, 0 ); + + /* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (tnl->pipeline.build_state_changes) + _tnl_validate_pipeline( ctx ); _tnl_vb_bind_arrays( ctx, start, end ); @@ -112,8 +113,10 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) GET_CURRENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - -/* fprintf(stderr, "%s %d %d\n", __FUNCTION__, start, count); */ + GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10; + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawArrays %d %d\n", start, count); /* Check arguments, etc. */ @@ -126,10 +129,16 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) if (ctx->CompileFlag) { fallback_drawarrays( ctx, mode, start, start + count ); } + else if (!ctx->Array.LockCount && count < thresh) { + /* Small primitives: attempt to share a vb (at the expense of + * using the immediate interface). + */ + fallback_drawarrays( ctx, mode, start, start + count ); + } else if (ctx->Array.LockCount && count < (GLint) ctx->Const.MaxArrayLockSize) { - /* Small primitives which can fit in a single vertex buffer: + /* Locked primitives which can fit in a single vertex buffer: */ FLUSH_CURRENT( ctx, 0 ); @@ -210,10 +219,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) FLUSH_CURRENT( ctx, 0 ); -/* fprintf(stderr, "start %d count %d min %d modulo %d skip %d\n", */ -/* start, count, minimum, modulo, skip); */ - - bufsz -= bufsz % modulo; bufsz -= minimum; count += start; @@ -222,8 +227,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) nr = MIN2( bufsz, count - j ); -/* fprintf(stderr, "%d..%d\n", j - minimum, j+nr); */ - _tnl_vb_bind_arrays( ctx, j - minimum, j + nr ); VB->FirstPrimitive = 0; @@ -246,10 +249,10 @@ _tnl_DrawRangeElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint *ui_indices; - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ + + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawRangeElements %d %d %d\n", start, end, count); /* Check arguments, etc. */ @@ -257,9 +260,6 @@ _tnl_DrawRangeElements(GLenum mode, type, indices )) return; - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); @@ -316,19 +316,16 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint *ui_indices; -/* fprintf(stderr, "%s\n", __FUNCTION__); */ + if (MESA_VERBOSE & VERBOSE_API) + fprintf(stderr, "_tnl_DrawElements %d\n", count); /* Check arguments, etc. */ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) return; - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); |