cassettes. Fixes problem with isosurf/compiled-array-elt/strips.
-/* $Id: t_array_api.c,v 1.13 2001/05/10 12:18:38 keithw Exp $ */
+/* $Id: t_array_api.c,v 1.14 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
GLuint start = IM->Start;
GLint nr = MIN2( (GLint) (IMM_MAXDATA - start), count - j ) + start;
GLuint sf = IM->Flag[start];
- IM->FlushElt |= 1;
+ IM->FlushElt = IM->ArrayEltFlush;
for (i = start ; i < nr ; i++) {
IM->Elt[i] = (GLuint) *indices++;
-/* $Id: t_array_import.c,v 1.14 2001/04/28 08:39:18 keithw Exp $ */
+/* $Id: t_array_import.c,v 1.15 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
#include "t_array_import.h"
#include "t_context.h"
+#include "t_imm_debug.h"
static void _tnl_import_vertex( GLcontext *ctx,
GLboolean is_writeable = 0;
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-
tmp = _ac_import_color(ctx,
type,
stride ? 4*sizeof(GLfloat) : 0,
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
GLuint inputs = tnl->pipeline.inputs;
- GLuint imports;
struct vertex_arrays *tmp = &tnl->array_inputs;
+ GLuint i;
-/* fprintf(stderr, "_tnl_vb_bind_arrays %d..%d // %d..%d\n", */
-/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */
-
- if (ctx->Array.LockCount) {
- ASSERT(start == (GLint) ctx->Array.LockFirst);
- ASSERT(count == (GLint) ctx->Array.LockCount);
+ if (0) {
+ fprintf(stderr, "%s %d..%d // %d..%d\n", __FUNCTION__,
+ start, count, ctx->Array.LockFirst, ctx->Array.LockCount);
+ _tnl_print_vert_flags(" inputs", inputs);
+ _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled);
+ _tnl_print_vert_flags(" importable", inputs & VERT_FIXUP);
}
- imports = tnl->pipeline.inputs;
-
- _ac_import_range( ctx, start, count );
-
VB->Count = count - start;
VB->FirstClipped = VB->Count;
-
VB->Elts = 0;
VB->MaterialMask = 0;
VB->Material = 0;
VB->Flag = 0;
+ VB->Primitive = tnl->tmp_primitive;
+ VB->PrimitiveLength = tnl->tmp_primitive_length;
+ VB->import_data = _tnl_upgrade_client_data;
+ VB->importable_data = inputs & VERT_FIXUP;
+
+ if (ctx->Array.LockCount) {
+ ASSERT(start == (GLint) ctx->Array.LockFirst);
+ ASSERT(count == (GLint) ctx->Array.LockCount);
+ }
-/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: inputs", inputs); */
-/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: imports", imports); */
-/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: _Enabled", ctx->Array._Enabled); */
+ _ac_import_range( ctx, start, count );
if (inputs & VERT_OBJ) {
- if (imports & VERT_OBJ) {
- _tnl_import_vertex( ctx, 0, 0 );
- tmp->Obj.count = VB->Count;
- }
+ _tnl_import_vertex( ctx, 0, 0 );
+ tmp->Obj.count = VB->Count;
VB->ObjPtr = &tmp->Obj;
}
if (inputs & VERT_NORM) {
- if (imports & VERT_NORM) {
- _tnl_import_normal( ctx, 0, 0 );
- tmp->Normal.count = VB->Count;
- }
+ _tnl_import_normal( ctx, 0, 0 );
+ tmp->Normal.count = VB->Count;
VB->NormalPtr = &tmp->Normal;
}
if (inputs & VERT_RGBA) {
- if (imports & VERT_RGBA) {
- _tnl_import_color( ctx, 0, 0, 0 );
- }
+ _tnl_import_color( ctx, 0, 0, 0 );
VB->ColorPtr[0] = &tmp->Color;
VB->ColorPtr[1] = 0;
-/* fprintf(stderr, "VB->ColorPtr[0]->StrideB %d Type %s\n", */
-/* VB->ColorPtr[0]->StrideB, */
-/* _mesa_lookup_enum_by_nr(VB->ColorPtr[0]->Type)); */
}
- if (inputs & VERT_INDEX) {
- if (imports & VERT_INDEX) {
- _tnl_import_index( ctx, 0, 0 );
- tmp->Index.count = VB->Count;
+ if (inputs & VERT_TEX_ANY) {
+ for (i = 0; i < ctx->Const.MaxTextureUnits ; i++) {
+ if (inputs & VERT_TEX(i)) {
+ _tnl_import_texcoord( ctx, i, 0, 0 );
+ tmp->TexCoord[i].count = VB->Count;
+ VB->TexCoordPtr[i] = &tmp->TexCoord[i];
+ }
}
- VB->IndexPtr[0] = &tmp->Index;
- VB->IndexPtr[1] = 0;
}
+ if (inputs & (VERT_INDEX|VERT_FOG_COORD|VERT_EDGE|VERT_SPEC_RGB)) {
+ if (inputs & VERT_INDEX) {
+ _tnl_import_index( ctx, 0, 0 );
+ tmp->Index.count = VB->Count;
+ VB->IndexPtr[0] = &tmp->Index;
+ VB->IndexPtr[1] = 0;
+ }
- if (inputs & VERT_FOG_COORD) {
- if (imports & VERT_FOG_COORD) {
+ if (inputs & VERT_FOG_COORD) {
_tnl_import_fogcoord( ctx, 0, 0 );
tmp->FogCoord.count = VB->Count;
+ VB->FogCoordPtr = &tmp->FogCoord;
}
- VB->FogCoordPtr = &tmp->FogCoord;
- }
- if (inputs & VERT_EDGE) {
- _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
- VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data;
- }
+ if (inputs & VERT_EDGE) {
+ _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
+ VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data;
+ }
- if (inputs & VERT_SPEC_RGB) {
- if (imports & VERT_SPEC_RGB) {
+ if (inputs & VERT_SPEC_RGB) {
_tnl_import_secondarycolor( ctx, 0, 0, 0 );
+ VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
+ VB->SecondaryColorPtr[1] = 0;
}
-
- VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
- VB->SecondaryColorPtr[1] = 0;
}
-
- if (inputs & VERT_TEX_ANY) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxTextureUnits ; i++)
- if (inputs & VERT_TEX(i)) {
- if (imports & VERT_TEX(i)) {
- _tnl_import_texcoord( ctx, i, 0, 0 );
- tmp->TexCoord[i].count = VB->Count;
- }
- VB->TexCoordPtr[i] = &tmp->TexCoord[i];
- }
- }
-
- VB->Primitive = tnl->tmp_primitive;
- VB->PrimitiveLength = tnl->tmp_primitive_length;
- VB->import_data = _tnl_upgrade_client_data;
- VB->importable_data = inputs & VERT_FIXUP;
-
-/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: importable", */
-/* VB->importable_data); */
}
/* Function to fill an immediate struct with the effects of
- * consecutive calls to ArrayElement with consecutive indices.
+ * consecutive calls to ArrayElement with consecutive indices. Used
+ * for display lists and very large fan-like primitives only.
*/
void _tnl_fill_immediate_drawarrays( GLcontext *ctx, struct immediate *IM,
GLuint start, GLuint count )
-/* $Id: t_context.c,v 1.17 2001/05/09 13:53:36 keithw Exp $ */
+/* $Id: t_context.c,v 1.18 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
if (new_state & _NEW_ARRAY) {
struct immediate *IM = TNL_CURRENT_IM(ctx);
IM->ArrayEltFlags = ~ctx->Array._Enabled;
- IM->ArrayEltFlush = !ctx->Array.LockCount;
+ IM->ArrayEltFlush = (ctx->Array.LockCount
+ ? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER);
IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
tnl->pipeline.run_input_changes |= ctx->Array.NewState; /* overkill */
}
-/* $Id: t_context.h,v 1.23 2001/05/10 12:18:38 keithw Exp $ */
+/* $Id: t_context.h,v 1.24 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
GLuint ArrayEltFlags; /* precalc'ed for glArrayElt */
GLuint ArrayEltIncr;
GLuint ArrayEltFlush;
+
+#define FLUSH_ELT_EAGER 0x1
+#define FLUSH_ELT_LAZY 0x2
GLuint FlushElt;
GLuint MaxTextureUnits; /* precalc'ed for glMultiTexCoordARB */
-/* $Id: t_imm_api.c,v 1.12 2001/04/30 21:08:52 keithw Exp $ */
+/* $Id: t_imm_api.c,v 1.13 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
{
GLcontext *ctx = IM->backref;
+ if (IM->FlushElt == FLUSH_ELT_EAGER) {
+ _tnl_translate_array_elts( ctx, IM, IM->LastPrimitive, IM->Count );
+ }
+
/* Mark the last primitive:
*/
IM->PrimitiveLength[IM->LastPrimitive] = IM->Count - IM->LastPrimitive;
* when not known to be inside begin/end and arrays are
* unlocked.
*/
- if (IM->FlushElt) {
+ if (IM->FlushElt == FLUSH_ELT_EAGER) {
_tnl_translate_array_elts( ctx, IM, last, count );
- IM->FlushElt = 0;
}
}
IM->PrimitiveLength[last] = count - last;
IM->LastPrimitive = count;
- ASSERT (!IM->FlushElt);
+ ASSERT (IM->FlushElt != FLUSH_ELT_EAGER);
/* This is necessary as this immediate will not be flushed in
* _tnl_end() -- we leave it active, hoping to pick up more
IM->Primitive[count] = PRIM_OUTSIDE_BEGIN_END;
IM->LastPrimitive = count;
- if (IM->FlushElt) {
+ if (IM->FlushElt == FLUSH_ELT_EAGER) {
_tnl_translate_array_elts( ctx, IM, last, count );
- IM->FlushElt = 0;
}
}
IM->Elt[count] = i; \
IM->Flag[count] &= IM->ArrayEltFlags; \
IM->Flag[count] |= VERT_ELT; \
- IM->FlushElt |= IM->ArrayEltFlush; \
+ IM->FlushElt = IM->ArrayEltFlush; \
IM->Count += IM->ArrayEltIncr; \
if (IM->Count == IMM_MAXDATA) \
_tnl_flush_immediate( IM ); \
-/* $Id: t_imm_dlist.c,v 1.16 2001/05/03 16:49:27 keithw Exp $ */
+/* $Id: t_imm_dlist.c,v 1.17 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
TNLvertexcassette *node;
GLuint new_beginstate;
- _tnl_compute_orflag( IM );
-
- IM->CopyStart = IM->Start;
-
- if (IM->OrFlag & VERT_ELT) {
- GLuint andflag = ~0;
- GLuint i;
- GLuint start = IM->FlushElt ? IM->LastPrimitive : IM->CopyStart;
- _tnl_translate_array_elts( ctx, IM, start, IM->Count );
-
- /* Need to recompute andflag.
- */
- if (IM->AndFlag & VERT_ELT)
- IM->CopyAndFlag = IM->AndFlag |= ctx->Array._Enabled;
- else {
- for (i = IM->CopyStart ; i < IM->Count ; i++)
- andflag &= IM->Flag[i];
- IM->CopyAndFlag = IM->AndFlag = andflag;
- }
- IM->CopyOrFlag |= ctx->Array._Enabled;
+ if (IM->FlushElt) {
+ ASSERT (IM->FlushElt == FLUSH_ELT_LAZY);
+ _tnl_translate_array_elts( ctx, IM, IM->Start, IM->Count );
}
+ _tnl_compute_orflag( IM, IM->Start );
_tnl_fixup_input( ctx, IM );
-
-
/* _tnl_print_cassette( IM ); */
-
node = (TNLvertexcassette *)
_mesa_alloc_instruction(ctx,
tnl->opcode_vertex_cassette,
execute_compiled_cassette( ctx, (void *)node );
}
-
/* Discard any errors raised in the last cassette.
*/
new_beginstate = node->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1);
-/* $Id: t_imm_elt.c,v 1.10 2001/05/09 14:12:34 keithw Exp $ */
+/* $Id: t_imm_elt.c,v 1.11 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
for (i = start ; i < count ; i++)
if (flags[i] & VERT_ELT) flags[i] |= translate;
+
+ IM->FlushElt = 0;
}
-/* $Id: t_imm_exec.c,v 1.23 2001/05/10 12:18:38 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.24 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
-
-
-
-
void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
GLuint flag )
{
-void _tnl_compute_orflag( struct immediate *IM )
+void _tnl_compute_orflag( struct immediate *IM, GLuint start )
{
GLuint count = IM->Count;
GLuint orflag = 0;
/* Compute the flags for the whole buffer.
*/
- for (i = IM->CopyStart ; i < count ; i++) {
+ for (i = start ; i < count ; i++) {
andflag &= IM->Flag[i];
orflag |= IM->Flag[i];
}
-/* Called by exec_cassette execute_compiled_cassette, but not
+/* Called by exec_vert_cassette, execute_compiled_cassette, but not
* exec_elt_cassette.
*/
void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM )
_tnl_copy_to_current( ctx, IM, IM->OrFlag );
}
+
/* Called for regular vertex cassettes.
*/
static void exec_vert_cassette( GLcontext *ctx, struct immediate *IM )
{
- if (IM->OrFlag & VERT_ELT) {
- GLuint andflag = ~0;
- GLuint i;
- GLuint start = IM->FlushElt ? IM->LastPrimitive : IM->CopyStart;
- _tnl_translate_array_elts( ctx, IM, start, IM->Count );
-
- /* Need to recompute andflag and orflag for fixup.
+ if (IM->FlushElt) {
+ /* Orflag is computed twice, but only reach this code if app is
+ * using a mixture of glArrayElement() and glVertex() while
+ * arrays are locked.
*/
- if (IM->CopyAndFlag & VERT_ELT)
- IM->CopyAndFlag |= ctx->Array._Enabled;
- else {
- for (i = IM->CopyStart ; i < IM->Count ; i++)
- andflag &= IM->Flag[i];
- IM->CopyAndFlag = andflag;
- }
- IM->CopyOrFlag |= ctx->Array._Enabled;
+ ASSERT(ctx->Array.LockCount);
+ ASSERT(IM->FlushElt == FLUSH_ELT_LAZY);
+ _tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->Count );
+ _tnl_compute_orflag( IM, IM->CopyStart );
}
_tnl_fixup_input( ctx, IM );
*/
tnl->Driver.RunPipeline( ctx );
- /* Still need to update current values: (TODO - copy from VB)
- * TODO: delay this until FlushVertices
+ /* Still need to update current values:
*/
if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) {
_tnl_translate_array_elts( ctx, IM, IM->LastData, IM->LastData );
static void
exec_empty_cassette( GLcontext *ctx, struct immediate *IM )
{
- if (IM->OrFlag & VERT_ELT)
+ if (IM->FlushElt)
_tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->CopyStart );
_tnl_copy_to_current( ctx, IM, IM->OrFlag );
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- _tnl_compute_orflag( IM );
+ _tnl_compute_orflag( IM, IM->Start );
_tnl_copy_immediate_vertices( ctx, IM ); /* ?? flags, orflag above */
_tnl_get_exec_copy_verts( ctx, IM );
-/* $Id: t_imm_exec.h,v 1.5 2001/05/03 16:49:27 keithw Exp $ */
+/* $Id: t_imm_exec.h,v 1.6 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
GLuint beginstate,
GLuint savedbeginstate );
-extern void _tnl_compute_orflag( struct immediate *IM );
+extern void _tnl_compute_orflag( struct immediate *IM, GLuint start );
extern void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM );
-/* $Id: t_imm_fixup.c,v 1.14 2001/05/03 16:11:16 brianp Exp $ */
+/* $Id: t_imm_fixup.c,v 1.15 2001/05/11 08:11:31 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
next->CopyStart = next->Start - count;
-/* fprintf(stderr, "%s prim %s count %d source %p\n", */
-/* __FUNCTION__, */
-/* _mesa_lookup_enum_by_nr(ctx->Driver.CurrentExecPrimitive), */
-/* count, prev); */
if ((prev->CopyOrFlag & VERT_DATA) == VERT_ELT &&
ctx->Array.LockCount &&
{
GLuint src = elts[i+offset];
GLuint dst = next->CopyStart+i;
-
next->Elt[dst] = prev->Elt[src];
next->Flag[dst] = VERT_ELT;
- next->CopyOrFlag |= VERT_ELT;
- next->CopyAndFlag &= VERT_ELT;
}
+ next->CopyOrFlag |= VERT_ELT;
+ next->CopyAndFlag &= VERT_ELT;
}
else {
/* prev->CopyOrFlag is hacked to include values generated by eval:
*/
GLuint copy = tnl->pipeline.inputs & prev->CopyOrFlag;
-
-/* _tnl_print_vert_flags(__FUNCTION__, copy); */
-
next->TexSize |= tnl->ExecCopyTexSize;
GLuint isrc = src - prev->CopyStart;
GLuint dst = next->CopyStart+i;
-/* fprintf(stderr, "src %d isrc %d dst %d\n", src, isrc, dst); */
-
/* Values subject to eval must be copied out of the 'inputs'
* struct. (Copied rows should not be evaluated twice).
*
GLuint count = IM->Count;
GLuint start = IM->Start;
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-
if (count == start)
return;
VB->importable_data &= ~VERT_RGBA;
}
}
+