X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_array_api.c;h=3aa91f9d906f194fda062530cc40c6dea94bab31;hb=5a382001224df9aad6137c825fbfc2d058b220b1;hp=818a15b6b8d4609ebcc8657402e3e14cee6025e6;hpb=8bec7c09bbe3a22109f97312ca2cc4e46da282a1;p=mesa.git diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 818a15b6b8d..3aa91f9d906 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.0 + * Version: 6.1 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -52,10 +52,10 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, assert(!ctx->CompileFlag); assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1); - glBegin(mode); - for (i = start; i < count; i++) - glArrayElement( i ); - glEnd(); + GL_CALL(Begin)(mode); + for (i = 0; i < count; i++) + GL_CALL(ArrayElement)( start + i ); + GL_CALL(End)(); } @@ -69,48 +69,41 @@ static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count, /* Here, indices will already reflect the buffer object if active */ - glBegin(mode); + GL_CALL(Begin)(mode); for (i = 0 ; i < count ; i++) { - glArrayElement( indices[i] ); + GL_CALL(ArrayElement)( indices[i] ); } - glEnd(); + GL_CALL(End)(); } +/* Note this function no longer takes a 'start' value, the range is + * assumed to start at zero. The old trick of subtracting 'start' + * from each index won't work if the indices are not in writeable + * memory. + */ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLuint *indices ) + GLuint max_index, + GLsizei index_count, GLuint *indices ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct tnl_prim prim; - int i; FLUSH_CURRENT( ctx, 0 ); if (tnl->pipeline.build_state_changes) _tnl_validate_pipeline( ctx ); - /* XXX is "end" correct? Looking at the implementation of - * _tnl_vb_bind_arrays(), perhaps we should pass end-start. - */ - _tnl_vb_bind_arrays( ctx, start, end ); + _tnl_vb_bind_arrays( ctx, 0, max_index ); tnl->vb.Primitive = &prim; tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END; tnl->vb.Primitive[0].start = 0; - tnl->vb.Primitive[0].count = count; + tnl->vb.Primitive[0].count = index_count; tnl->vb.PrimitiveCount = 1; tnl->vb.Elts = (GLuint *)indices; - assert (start == 0); - -/* XXX - indices may be read only - if (start) - for (i = 0 ; i < count ; i++) - indices[i] -= start; -*/ - if (ctx->Array.LockCount) tnl->Driver.RunPipeline( ctx ); else { @@ -121,16 +114,10 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, GLuint enabledArrays = ctx->Array._Enabled | (ctx->Array._Enabled >> 16); /* Note that arrays may have changed before/after execution. */ - tnl->pipeline.run_input_changes |= enabledArrays; + tnl->pipeline.run_input_changes |= enabledArrays & 0xffff; tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= enabledArrays; + tnl->pipeline.run_input_changes |= enabledArrays & 0xffff; } - -/* XXX - indices may be read only - if (start) - for (i = 0 ; i < count ; i++) - indices[i] += start; -*/ } @@ -163,10 +150,10 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) /* Small primitives: attempt to share a vb (at the expense of * using the immediate interface). */ - fallback_drawarrays( ctx, mode, start, start + count ); + fallback_drawarrays( ctx, mode, start, count ); } - else if (ctx->Array.LockCount && - count <= (GLint) ctx->Const.MaxArrayLockSize) { + else if (start >= (GLint) ctx->Array.LockFirst && + start + count <= (GLint)(ctx->Array.LockFirst + ctx->Array.LockCount)) { struct tnl_prim prim; @@ -174,14 +161,10 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) */ FLUSH_CURRENT( ctx, 0 ); - if (start < (GLint) ctx->Array.LockFirst) - start = ctx->Array.LockFirst; - if (start + count > (GLint) ctx->Array.LockCount) - count = ctx->Array.LockCount - start; - /* Locked drawarrays. Reuse any previously transformed data. */ - _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount ); + _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, + ctx->Array.LockFirst + ctx->Array.LockCount ); tnl->vb.Primitive = &prim; tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END; @@ -250,7 +233,7 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) skip = 0; } else { - fallback_drawarrays( ctx, mode, start, start + count ); + fallback_drawarrays( ctx, mode, start, count ); return; } } @@ -341,34 +324,21 @@ _tnl_DrawRangeElements(GLenum mode, /* Are the arrays already locked? If so we currently have to look * at the whole locked range. */ - if (start == 0 && - start >= ctx->Array.LockFirst && end <= ctx->Array.LockCount) + + if (start == 0 && ctx->Array.LockFirst == 0 && + end < (ctx->Array.LockFirst + ctx->Array.LockCount)) _tnl_draw_range_elements( ctx, mode, - ctx->Array.LockFirst, ctx->Array.LockCount, count, ui_indices ); else { - /* The spec says referencing elements outside the locked - * range is undefined. I'm going to make it a noop this time - * round, maybe come up with something beter before 3.6. - * - * 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? - */ - _mesa_problem( ctx, - "DrawRangeElements references " - "elements outside locked range."); + fallback_drawelements( ctx, mode, count, ui_indices ); } } - else if (start == 0 && - end - start + 1 <= ctx->Const.MaxArrayLockSize) { + else if (start == 0 && end < ctx->Const.MaxArrayLockSize) { /* 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 ); + _tnl_draw_range_elements( ctx, mode, end + 1, count, ui_indices ); } else { /* Range is too big to optimize: @@ -408,12 +378,13 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, assert(!ctx->CompileFlag); - if (ctx->Array.LockFirst == 0 && - ctx->Array.LockCount) { - _tnl_draw_range_elements( ctx, mode, - ctx->Array.LockFirst, - ctx->Array.LockCount, - count, ui_indices ); + if (ctx->Array.LockCount) { + if (ctx->Array.LockFirst == 0) + _tnl_draw_range_elements( ctx, mode, + ctx->Array.LockCount, + count, ui_indices ); + else + fallback_drawelements( ctx, mode, count, ui_indices ); } else { /* Scan the index list and see if we can use the locked path anyway. @@ -425,10 +396,9 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, if (ui_indices[i] > max_elt) max_elt = ui_indices[i]; - /* XXX should this < really be <= ??? */ if (max_elt < ctx->Const.MaxArrayLockSize && /* can we use it? */ max_elt < (GLuint) 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, max_elt+1, count, ui_indices ); else fallback_drawelements( ctx, mode, count, ui_indices ); } @@ -452,13 +422,13 @@ void _tnl_array_init( GLcontext *ctx ) /* Setup vector pointers that will be used to bind arrays to VB's. */ - _mesa_vector4f_init( &tmp->Obj, 0, 0 ); - _mesa_vector4f_init( &tmp->Normal, 0, 0 ); - _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); - _mesa_vector4f_init( &tmp->Index, 0, 0 ); + _mesa_vector4f_init( &tmp->Obj, 0, NULL); + _mesa_vector4f_init( &tmp->Normal, 0, NULL); + _mesa_vector4f_init( &tmp->FogCoord, 0, NULL); + _mesa_vector4f_init( &tmp->Index, 0, NULL); for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - _mesa_vector4f_init( &tmp->TexCoord[i], 0, 0); + _mesa_vector4f_init( &tmp->TexCoord[i], 0, NULL); } @@ -468,4 +438,5 @@ void _tnl_array_init( GLcontext *ctx ) */ void _tnl_array_destroy( GLcontext *ctx ) { + (void) ctx; }