/*
* Mesa 3-D graphics library
- * Version: 6.0
+ * Version: 6.1
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
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)();
}
/* 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 {
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;
-*/
}
/* 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;
*/
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;
skip = 0;
}
else {
- fallback_drawarrays( ctx, mode, start, start + count );
+ fallback_drawarrays( ctx, mode, start, count );
return;
}
}
/* 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:
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.
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 );
}
/* 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);
}
*/
void _tnl_array_destroy( GLcontext *ctx )
{
+ (void) ctx;
}