summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2003-04-08 02:27:16 +0000
committerBrian Paul <[email protected]>2003-04-08 02:27:16 +0000
commit36a0a3252e1e20df69b53f70ba93bc74c4a4bf0e (patch)
tree6c680de320af7a288fe70e5a95696bcf0f5faa56 /src/mesa/tnl
parent0cebd5822a39ad3b3d7621f8e59efab329bfb5b9 (diff)
Added ctx->Texture._EnabledCoordUnits bitfield.
Fixed some vertex array / vertex program glitches with glDrawElements. Fixed some fragment program runtime bugs. Non-trivial Cg programs are running now.
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_array_import.c28
-rw-r--r--src/mesa/tnl/t_context.c6
-rw-r--r--src/mesa/tnl/t_imm_elt.c118
-rw-r--r--src/mesa/tnl/t_imm_exec.c10
-rw-r--r--src/mesa/tnl/t_imm_fixup.c3
-rw-r--r--src/mesa/tnl/t_vb_render.c6
6 files changed, 114 insertions, 57 deletions
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c
index 2a8506aa424..fbcb9b33100 100644
--- a/src/mesa/tnl/t_array_import.c
+++ b/src/mesa/tnl/t_array_import.c
@@ -1,4 +1,4 @@
-/* $Id: t_array_import.c,v 1.28 2003/03/01 01:50:26 brianp Exp $ */
+/* $Id: t_array_import.c,v 1.29 2003/04/08 02:27:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -363,6 +363,22 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count )
_ac_import_range( ctx, start, count );
+ /* When vertex program mode is enabled, the generic vertex program
+ * attribute arrays have priority over the conventional attributes.
+ * Try to use them now.
+ */
+ if (ctx->VertexProgram.Enabled) {
+ GLuint index;
+ for (index = 0; index < VERT_ATTRIB_MAX; index++) {
+ /* XXX check program->InputsRead to reduce work here */
+ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
+ VB->AttribPtr[index] = &tmp->Attribs[index];
+ }
+ }
+
+ /*
+ * Conventional attributes
+ */
if (inputs & VERT_BIT_POS) {
_tnl_import_vertex( ctx, 0, 0 );
tmp->Obj.count = VB->Count;
@@ -418,14 +434,4 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count )
VB->SecondaryColorPtr[1] = 0;
}
}
-
- /* XXX not 100% sure this is finished. Keith should probably inspect. */
- if (ctx->VertexProgram.Enabled) {
- GLuint index;
- for (index = 0; index < VERT_ATTRIB_MAX; index++) {
- /* XXX check program->InputsRead to reduce work here */
- _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
- VB->AttribPtr[index] = &tmp->Attribs[index];
- }
- }
}
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 6e8f48aaecd..0b5e575ceaf 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,4 +1,4 @@
-/* $Id: t_context.c,v 1.31 2003/02/04 14:40:56 brianp Exp $ */
+/* $Id: t_context.c,v 1.32 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -162,7 +162,9 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
IM->ArrayEltFlags = ~ctx->Array._Enabled;
IM->ArrayEltFlush = (ctx->Array.LockCount
? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER);
- IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
+ IM->ArrayEltIncr = (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled)) ? 1 : 0;
tnl->pipeline.run_input_changes |= ctx->Array.NewState; /* overkill */
}
diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c
index 6ae30ea45b4..74958649c5a 100644
--- a/src/mesa/tnl/t_imm_elt.c
+++ b/src/mesa/tnl/t_imm_elt.c
@@ -753,7 +753,8 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
GLuint *flags = IM->Flag;
const GLuint *elts = IM->Elt;
GLuint translate = ctx->Array._Enabled;
- GLuint i, attr;
+ GLuint translateConventional;
+ GLuint attr;
if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
_mesa_debug(ctx, "exec_array_elements %d .. %d\n", start, count);
@@ -774,57 +775,97 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
}
}
+ translateConventional = translate;
- if (translate & VERT_BIT_POS) {
+ /*
+ * When vertex program mode is enabled, the generic vertex attribute arrays
+ * have priority over the conventional arrays. Process those arrays now.
+ * When we're done here, translateConventional will indicate which
+ * conventional arrays still have to be translated when we're done.
+ */
+ if (ctx->VertexProgram.Enabled) {
+ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ const GLuint attrBit = 1 << attr;
+ if ((translate & attrBit) && ctx->Array.VertexAttrib[attr].Enabled) {
+ _tnl_trans_elt_4f( IM->Attrib[attr],
+ &ctx->Array.VertexAttrib[attr],
+ flags, elts, (VERT_BIT_ELT | attrBit),
+ start, count);
+ /* special case stuff */
+ if (attr == VERT_ATTRIB_POS) {
+ if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 4)
+ translate |= VERT_BITS_OBJ_234;
+ else if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 3)
+ translate |= VERT_BITS_OBJ_23;
+ }
+ else if (attr >= VERT_ATTRIB_TEX0 && attr <= VERT_ATTRIB_TEX7) {
+ if (ctx->Array.VertexAttrib[attr].Size == 4)
+ IM->TexSize |= TEX_SIZE_4(attr - VERT_ATTRIB_TEX0);
+ else if (ctx->Array.VertexAttrib[attr].Size == 3)
+ IM->TexSize |= TEX_SIZE_3(attr - VERT_ATTRIB_TEX0);
+ }
+ /* override the conventional array */
+ translateConventional &= ~attrBit;
+ }
+ }
+ }
+
+ /*
+ * Check which conventional arrays are needed.
+ */
+ if (translateConventional & VERT_BIT_POS) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_POS],
- &ctx->Array.Vertex,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
- start, count);
+ &ctx->Array.Vertex,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
+ start, count);
if (ctx->Array.Vertex.Size == 4)
- translate |= VERT_BITS_OBJ_234;
+ translate |= VERT_BITS_OBJ_234;
else if (ctx->Array.Vertex.Size == 3)
- translate |= VERT_BITS_OBJ_23;
+ translate |= VERT_BITS_OBJ_23;
}
- if (translate & VERT_BIT_NORMAL)
+ if (translateConventional & VERT_BIT_NORMAL) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_NORMAL],
- &ctx->Array.Normal,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
- start, count);
+ &ctx->Array.Normal,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
+ start, count);
+ }
- if (translate & VERT_BIT_COLOR0) {
+ if (translateConventional & VERT_BIT_COLOR0) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR0],
- &ctx->Array.Color,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
- start, count);
+ &ctx->Array.Color,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
+ start, count);
}
- if (translate & VERT_BIT_COLOR1) {
+ if (translateConventional & VERT_BIT_COLOR1) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR1],
- &ctx->Array.SecondaryColor,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
- start, count);
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
+ start, count);
}
- if (translate & VERT_BIT_FOG)
+ if (translateConventional & VERT_BIT_FOG) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_FOG],
- &ctx->Array.FogCoord,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
- start, count);
+ &ctx->Array.FogCoord,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
+ start, count);
+ }
- if (translate & VERT_BITS_TEX_ANY) {
+ if (translateConventional & VERT_BITS_TEX_ANY) {
+ GLuint i;
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
- if (translate & VERT_BIT_TEX(i)) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
- &ctx->Array.TexCoord[i],
- flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
- start, count);
-
- if (ctx->Array.TexCoord[i].Size == 4)
- IM->TexSize |= TEX_SIZE_4(i);
- else if (ctx->Array.TexCoord[i].Size == 3)
- IM->TexSize |= TEX_SIZE_3(i);
+ if (translateConventional & VERT_BIT_TEX(i)) {
+ _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
+ &ctx->Array.TexCoord[i],
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
+ start, count);
+
+ if (ctx->Array.TexCoord[i].Size == 4)
+ IM->TexSize |= TEX_SIZE_4(i);
+ else if (ctx->Array.TexCoord[i].Size == 3)
+ IM->TexSize |= TEX_SIZE_3(i);
}
}
@@ -840,9 +881,12 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG),
start, count);
- for (i = start ; i < count ; i++)
- if (flags[i] & VERT_BIT_ELT)
- flags[i] |= translate;
+ {
+ GLuint i;
+ for (i = start ; i < count ; i++)
+ if (flags[i] & VERT_BIT_ELT)
+ flags[i] |= translate;
+ }
IM->FlushElt = 0;
}
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index 3c56e2ede28..a50922330f0 100644
--- a/src/mesa/tnl/t_imm_exec.c
+++ b/src/mesa/tnl/t_imm_exec.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_exec.c,v 1.45 2003/04/07 14:53:28 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.46 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -85,7 +85,9 @@ static void reset_input( GLcontext *ctx,
IM->MaterialMask[IM->Start] = 0;
IM->ArrayEltFlags = ~ctx->Array._Enabled;
- IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
+ IM->ArrayEltIncr = (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled)) ? 1 : 0;
IM->ArrayEltFlush = ctx->Array.LockCount ? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER;
}
@@ -486,7 +488,9 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM )
}
else if ((IM->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT &&
ctx->Array.LockCount &&
- ctx->Array.Vertex.Enabled) {
+ (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled))) {
exec_elt_cassette( ctx, IM );
}
else {
diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c
index 7fb4d4753ea..cf3aa2ed963 100644
--- a/src/mesa/tnl/t_imm_fixup.c
+++ b/src/mesa/tnl/t_imm_fixup.c
@@ -367,7 +367,8 @@ _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
if ((prev->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT &&
ctx->Array.LockCount &&
- ctx->Array.Vertex.Enabled)
+ (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled)))
{
/* Copy Elt values only
*/
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index c0e2bf26b09..bbfa1ae704f 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.34 2003/03/01 01:50:27 brianp Exp $ */
+/* $Id: t_vb_render.c,v 1.35 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -352,9 +352,9 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
inputs |= VERT_BIT_COLOR1;
- if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledCoordUnits) {
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
- if (ctx->Texture.Unit[i]._ReallyEnabled)
+ if (ctx->Texture._EnabledCoordUnits & (1 << i))
inputs |= VERT_BIT_TEX(i);
}
}