Clean up translation of array elements, copying of elts in pure-elt

cassettes.  Fixes problem with isosurf/compiled-array-elt/strips.
This commit is contained in:
Keith Whitwell 2001-05-11 08:11:31 +00:00
parent 1a3e034b12
commit 6d1055c967
10 changed files with 104 additions and 161 deletions

View File

@ -1,4 +1,4 @@
/* $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
@ -104,7 +104,7 @@ static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count,
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++;

View File

@ -1,4 +1,4 @@
/* $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
@ -40,6 +40,7 @@
#include "t_array_import.h"
#include "t_context.h"
#include "t_imm_debug.h"
static void _tnl_import_vertex( GLcontext *ctx,
@ -100,8 +101,6 @@ static void _tnl_import_color( 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,
@ -306,118 +305,96 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count )
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 (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);
}
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);
}
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;
/* _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); */
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;
}
VB->IndexPtr[0] = &tmp->Index;
VB->IndexPtr[1] = 0;
}
if (inputs & VERT_FOG_COORD) {
if (imports & VERT_FOG_COORD) {
_tnl_import_fogcoord( ctx, 0, 0 );
tmp->FogCoord.count = VB->Count;
}
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_SPEC_RGB) {
if (imports & VERT_SPEC_RGB) {
_tnl_import_secondarycolor( ctx, 0, 0, 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++)
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;
}
_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;
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;
}
/* _tnl_print_vert_flags("_tnl_vb_bind_arrays: importable", */
/* VB->importable_data); */
if (inputs & VERT_FOG_COORD) {
_tnl_import_fogcoord( ctx, 0, 0 );
tmp->FogCoord.count = VB->Count;
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_SPEC_RGB) {
_tnl_import_secondarycolor( ctx, 0, 0, 0 );
VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
VB->SecondaryColorPtr[1] = 0;
}
}
}
/* 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 )

View File

@ -1,4 +1,4 @@
/* $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
@ -149,7 +149,8 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
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 */
}

View File

@ -1,4 +1,4 @@
/* $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
@ -176,6 +176,9 @@ struct immediate
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 */

View File

@ -1,4 +1,4 @@
/* $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
@ -52,6 +52,10 @@ void _tnl_flush_immediate( struct immediate *IM )
{
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;
@ -122,9 +126,8 @@ _tnl_begin( GLcontext *ctx, GLenum p )
* 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;
}
}
@ -229,7 +232,7 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p )
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
@ -305,9 +308,8 @@ _tnl_end( GLcontext *ctx )
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;
}
}
@ -1053,7 +1055,7 @@ _tnl_EvalPoint2( GLint i, GLint j )
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 ); \

View File

@ -1,4 +1,4 @@
/* $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
@ -76,34 +76,15 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM )
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,
@ -129,7 +110,6 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM )
execute_compiled_cassette( ctx, (void *)node );
}
/* Discard any errors raised in the last cassette.
*/
new_beginstate = node->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1);

View File

@ -1,4 +1,4 @@
/* $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
@ -825,4 +825,6 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
for (i = start ; i < count ; i++)
if (flags[i] & VERT_ELT) flags[i] |= translate;
IM->FlushElt = 0;
}

View File

@ -1,4 +1,4 @@
/* $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
@ -117,10 +117,6 @@ void _tnl_reset_compile_input( GLcontext *ctx,
}
void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
GLuint flag )
{
@ -172,7 +168,7 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
void _tnl_compute_orflag( struct immediate *IM )
void _tnl_compute_orflag( struct immediate *IM, GLuint start )
{
GLuint count = IM->Count;
GLuint orflag = 0;
@ -184,7 +180,7 @@ void _tnl_compute_orflag( struct immediate *IM )
/* 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];
}
@ -352,7 +348,7 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM )
/* 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 )
@ -373,26 +369,20 @@ 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 );
@ -422,8 +412,7 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *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 );
@ -435,7 +424,7 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM )
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 );
@ -450,7 +439,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM )
{
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 );

View File

@ -1,4 +1,4 @@
/* $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
@ -62,7 +62,7 @@ extern void _tnl_reset_compile_input( GLcontext *ctx,
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 );

View File

@ -1,4 +1,4 @@
/* $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
@ -391,10 +391,6 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
}
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 &&
@ -406,20 +402,16 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
{
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;
@ -431,8 +423,6 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
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).
*
@ -500,8 +490,6 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
GLuint count = IM->Count;
GLuint start = IM->Start;
/* fprintf(stderr, "%s\n", __FUNCTION__); */
if (count == start)
return;
@ -837,3 +825,4 @@ void _tnl_upgrade_current_data( GLcontext *ctx,
VB->importable_data &= ~VERT_RGBA;
}
}