summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-08-02 22:39:51 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-08-02 22:39:51 +0000
commit76ca0f5232682665a899841026c47f171c7ec05c (patch)
tree0457ec7393a5c798b2f2f5542377ffb4fa48feba /src/mesa/tnl
parent554ceab8ecc9805afb89cfa5975852fd57cad1e6 (diff)
Fix SGL testLights.exe bugs (interaction of copying and fixup in display lists)
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_imm_dlist.c8
-rw-r--r--src/mesa/tnl/t_imm_exec.c23
-rw-r--r--src/mesa/tnl/t_imm_exec.h4
-rw-r--r--src/mesa/tnl/t_imm_fixup.c102
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h17
5 files changed, 103 insertions, 51 deletions
diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c
index b2b7f90c495..6d6830a50d9 100644
--- a/src/mesa/tnl/t_imm_dlist.c
+++ b/src/mesa/tnl/t_imm_dlist.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_dlist.c,v 1.27 2001/07/28 21:04:21 keithw Exp $ */
+/* $Id: t_imm_dlist.c,v 1.28 2001/08/02 22:39:51 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -368,9 +368,11 @@ execute_compiled_cassette( GLcontext *ctx, void *data )
fixup_normal_lengths( IM );
if (IM->Count == IM->Start)
- _tnl_copy_to_current( ctx, IM, IM->OrFlag );
- else
+ _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData );
+ else {
+/* _tnl_print_cassette( IM ); */
_tnl_run_cassette( ctx, IM );
+ }
restore_compiled_primitives( ctx, IM );
}
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index b99260bfbc5..8b55fec9681 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.28 2001/08/01 05:10:42 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.29 2001/08/02 22:39:51 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -118,10 +118,8 @@ void _tnl_reset_compile_input( GLcontext *ctx,
void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
- GLuint flag )
+ GLuint flag, GLuint count )
{
- GLuint count = IM->LastData;
-
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
_tnl_print_vert_flags("copy to current", flag);
@@ -198,7 +196,8 @@ void _tnl_compute_orflag( struct immediate *IM, GLuint start )
IM->Flag[IM->LastData+1] |= VERT_END_VB;
IM->CopyAndFlag = IM->AndFlag = andflag;
- IM->CopyOrFlag = IM->OrFlag = orflag;
+ IM->OrFlag = orflag;
+ IM->CopyOrFlag = orflag;
IM->Evaluated = 0;
}
@@ -360,9 +359,11 @@ void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
_tnl_vb_bind_immediate( ctx, IM );
- if (IM->CopyOrFlag & VERT_EVAL_ANY)
+ if (IM->OrFlag & VERT_EVAL_ANY)
_tnl_eval_immediate( ctx, IM );
/* Invalidate all stored data before and after run:
@@ -371,7 +372,7 @@ void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM )
tnl->Driver.RunPipeline( ctx );
tnl->pipeline.run_input_changes |= tnl->pipeline.inputs;
- _tnl_copy_to_current( ctx, IM, IM->OrFlag );
+ _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData );
}
@@ -379,6 +380,8 @@ void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM )
*/
static void exec_vert_cassette( GLcontext *ctx, struct immediate *IM )
{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
if (IM->FlushElt) {
/* Orflag is computed twice, but only reach this code if app is
* using a mixture of glArrayElement() and glVertex() while
@@ -404,6 +407,8 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM )
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
_tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount );
/* Take only elements and primitive information from the immediate:
@@ -421,7 +426,7 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM )
*/
if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) {
_tnl_translate_array_elts( ctx, IM, IM->LastData, IM->LastData );
- _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled );
+ _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled, IM->LastData );
}
}
@@ -432,7 +437,7 @@ exec_empty_cassette( GLcontext *ctx, struct immediate *IM )
if (IM->FlushElt)
_tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->CopyStart );
- _tnl_copy_to_current( ctx, IM, IM->OrFlag );
+ _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData );
}
diff --git a/src/mesa/tnl/t_imm_exec.h b/src/mesa/tnl/t_imm_exec.h
index 226aa143ffd..5e586449e8a 100644
--- a/src/mesa/tnl/t_imm_exec.h
+++ b/src/mesa/tnl/t_imm_exec.h
@@ -1,4 +1,4 @@
-/* $Id: t_imm_exec.h,v 1.6 2001/05/11 08:11:31 keithw Exp $ */
+/* $Id: t_imm_exec.h,v 1.7 2001/08/02 22:39:51 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,7 +44,7 @@ extern void _tnl_flush_immediate( struct immediate *IM );
*/
extern void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM );
extern void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
- GLuint flag );
+ GLuint flag, GLuint row );
/* Initialize some stuff:
*/
diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c
index b5f191e3a38..4cc4704b6b2 100644
--- a/src/mesa/tnl/t_imm_fixup.c
+++ b/src/mesa/tnl/t_imm_fixup.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_fixup.c,v 1.24 2001/08/01 05:10:42 keithw Exp $ */
+/* $Id: t_imm_fixup.c,v 1.25 2001/08/02 22:39:51 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,6 +50,7 @@
#include "t_imm_debug.h"
#include "t_imm_elt.h"
#include "t_imm_fixup.h"
+#include "t_imm_exec.h"
#include "t_pipeline.h"
@@ -151,7 +152,8 @@ fixup_first_3f( GLfloat data[][3], GLuint flag[], GLuint match,
GLuint i = start-1;
match |= VERT_END_VB;
-/* fprintf(stderr, "fixup_first_3f\n"); */
+/* fprintf(stderr, "fixup_first_3f default: %f %f %f start: %d\n", */
+/* dflt[0], dflt[1], dflt[2], start); */
while ((flag[++i]&match) == 0)
COPY_3FV(data[i], dflt);
@@ -192,6 +194,41 @@ fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match,
data[i] = dflt;
}
+static void copy_from_current( GLcontext *ctx, struct immediate *IM,
+ GLuint start, GLuint copy )
+{
+ if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
+ _tnl_print_vert_flags("copy from current", copy);
+
+ if (copy & VERT_NORM) {
+ COPY_3V( IM->Normal[start], ctx->Current.Normal );
+ }
+
+ if (copy & VERT_RGBA) {
+ COPY_4FV( IM->Color[start], ctx->Current.Color);
+ }
+
+ if (copy & VERT_SPEC_RGB)
+ COPY_4FV( IM->SecondaryColor[start], ctx->Current.SecondaryColor);
+
+ if (copy & VERT_FOG_COORD)
+ IM->FogCoord[start] = ctx->Current.FogCoord;
+
+ if (copy & VERT_INDEX)
+ IM->Index[start] = ctx->Current.Index;
+
+ if (copy & VERT_EDGE)
+ IM->EdgeFlag[start] = ctx->Current.EdgeFlag;
+
+ if (copy & VERT_TEX_ANY) {
+ GLuint i;
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
+ if (copy & VERT_TEX(i))
+ COPY_4FV( IM->TexCoord[i][start], ctx->Current.Texcoord[i] );
+ }
+ }
+}
+
void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
{
@@ -227,39 +264,8 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
/* Equivalent to a lazy copy-from-current when setting up the
* immediate.
*/
- if (ctx->ExecuteFlag && copy) {
-
- if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
- _tnl_print_vert_flags("copy from current", copy);
-
- if (copy & VERT_NORM) {
- COPY_3V( IM->Normal[start], ctx->Current.Normal );
- }
-
- if (copy & VERT_RGBA) {
- COPY_4FV( IM->Color[start], ctx->Current.Color);
- }
-
- if (copy & VERT_SPEC_RGB)
- COPY_4FV( IM->SecondaryColor[start], ctx->Current.SecondaryColor);
-
- if (copy & VERT_FOG_COORD)
- IM->FogCoord[start] = ctx->Current.FogCoord;
-
- if (copy & VERT_INDEX)
- IM->Index[start] = ctx->Current.Index;
-
- if (copy & VERT_EDGE)
- IM->EdgeFlag[start] = ctx->Current.EdgeFlag;
-
- if (copy & VERT_TEX_ANY) {
- GLuint i;
- for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
- if (copy & VERT_TEX(i))
- COPY_4FV( IM->TexCoord[i][start], ctx->Current.Texcoord[i] );
- }
- }
- }
+ if (ctx->ExecuteFlag && copy)
+ copy_from_current( ctx, IM, start, copy );
if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
_tnl_print_vert_flags("fixup", fixup);
@@ -425,6 +431,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
next->Elt[dst] = prev->Elt[src];
next->Flag[dst] = VERT_ELT;
}
+/* fprintf(stderr, "ADDING VERT_ELT!\n"); */
next->CopyOrFlag |= VERT_ELT;
next->CopyAndFlag &= VERT_ELT;
}
@@ -446,6 +453,10 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
next->CopyAndFlag &= flag;
+/* _tnl_print_vert_flags("copy vertex components", copy); */
+/* _tnl_print_vert_flags("prev copyorflag", prev->CopyOrFlag); */
+/* _tnl_print_vert_flags("flag", flag); */
+
/* Copy whole vertices
*/
for (i = 0 ; i < count ; i++)
@@ -503,7 +514,9 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
}
next->Flag[dst] = flag;
- next->CopyOrFlag |= prev->Flag[src];
+ next->CopyOrFlag |= prev->Flag[src] & (VERT_FIXUP|
+ VERT_MATERIAL|
+ VERT_OBJ);
}
}
@@ -515,6 +528,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next )
}
+
/* Revive a compiled immediate struct - propogate new 'Current'
* values. Often this is redundant because the current values were
* known and fixed up at compile time (or in the first execution of
@@ -526,6 +540,8 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
GLuint fixup;
GLuint start = IM->Start;
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
IM->Evaluated = 0;
IM->CopyOrFlag = IM->OrFlag;
IM->CopyAndFlag = IM->AndFlag;
@@ -541,12 +557,23 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
* display list. Need to translate them away:
*/
if (IM->CopyOrFlag & VERT_ELT) {
+ GLuint copy = tnl->pipeline.inputs & ~ctx->Array._Enabled;
+ GLuint i;
+
ASSERT(IM->CopyStart < IM->Start);
+
_tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->Start );
+
+ for (i = IM->CopyStart ; i < IM->Start ; i++)
+ copy_from_current( ctx, IM, i, copy );
+
+ _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled, IM->Start );
}
fixup = tnl->pipeline.inputs & ~IM->Flag[start] & VERT_FIXUP;
+/* _tnl_print_vert_flags("fixup compiled", fixup); */
+
if (fixup) {
if (fixup & VERT_TEX_ANY) {
GLuint i;
@@ -582,7 +609,10 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
fixup_first_3f(IM->Normal, IM->Flag, VERT_NORM, start,
ctx->Current.Normal );
}
+
+ IM->CopyOrFlag |= fixup;
}
+
/* Materials:
*/
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index f26f1df68b6..22601db55fb 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -1,4 +1,4 @@
-/* $Id: t_vb_lighttmp.h,v 1.15 2001/08/01 05:10:42 keithw Exp $ */
+/* $Id: t_vb_lighttmp.h,v 1.16 2001/08/02 22:39:51 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -588,6 +588,13 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
do {
GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm);
+/* if (j < 5) */
+/* fprintf(stderr, "light normal %d: %f %f %f\n", */
+/* j, */
+/* normal[0], */
+/* normal[1], */
+/* normal[2]); */
+
if (n_dot_VP < 0.0F) {
if (IDX & LIGHT_TWOSIDE) {
GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
@@ -628,6 +635,14 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
COPY_CHAN4(Fcolor[j], Fcolor[j-1]);
if (IDX & LIGHT_TWOSIDE)
COPY_CHAN4(Bcolor[j], Bcolor[j-1]);
+
+/* if (j < 5) */
+/* fprintf(stderr, "skip normal %d: %f %f %f\n", */
+/* j, */
+/* normal[0], */
+/* normal[1], */
+/* normal[2]); */
+
}
} while (!CHECK_END_VB(j));