summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_array_api.c20
-rw-r--r--src/mesa/tnl/t_array_import.c5
-rw-r--r--src/mesa/tnl/t_context.c5
-rw-r--r--src/mesa/tnl/t_context.h1
-rw-r--r--src/mesa/tnl/t_vb_arbprogram.c3
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h17
-rw-r--r--src/mesa/tnl/t_vb_program.c14
-rw-r--r--src/mesa/tnl/t_vtx_api.c25
8 files changed, 65 insertions, 25 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c
index 36ea54296ce..6826cf7e24c 100644
--- a/src/mesa/tnl/t_array_api.c
+++ b/src/mesa/tnl/t_array_api.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.2
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
@@ -115,6 +115,12 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
{
GET_CURRENT_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
+ /* It's tempting to get rid of this threshold value because we take
+ * very different paths if 'count' is less than or greater than 'thresh'.
+ * I've found/fixed at least one bug which only occured for particular
+ * array sizes. Also, several conformance tests use very short arrays
+ * which means the long-array path doesn't get tested. -Brian
+ */
GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10;
if (MESA_VERBOSE & VERBOSE_API)
@@ -289,6 +295,18 @@ _tnl_DrawRangeElements(GLenum mode,
ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
count, type, indices );
+#ifdef DEBUG
+ /* check that array indices really fall inside [start, end] range */
+ {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (ui_indices[i] < start || ui_indices[i] > end) {
+ _mesa_warning(ctx, "Invalid array index in "
+ "glDrawRangeElements(index=%u)", ui_indices[i]);
+ }
+ }
+ }
+#endif
assert(!ctx->CompileFlag);
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c
index 0677a1fd3b2..13c5689ceb9 100644
--- a/src/mesa/tnl/t_array_import.c
+++ b/src/mesa/tnl/t_array_import.c
@@ -327,9 +327,10 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end)
}
else if (index >= VERT_ATTRIB_GENERIC1 &&
index <= VERT_ATTRIB_GENERIC15) {
- if (program && !program->IsNVProgram) {
+ const GLuint arrayIndex = index - VERT_ATTRIB_GENERIC0;
+ if (program && !program->IsNVProgram &&
+ ctx->Array.ArrayObj->VertexAttrib[arrayIndex].Enabled) {
/* GL_ARB_vertex_program: bind a generic attribute array */
- const GLuint arrayIndex = index - VERT_ATTRIB_GENERIC0;
_tnl_import_attrib(ctx, arrayIndex, GL_FALSE, GL_TRUE);
VB->AttribPtr[index] = &tmp->Attribs[arrayIndex];
}
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index b6f5152c741..55b40c0531f 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.2
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
@@ -184,7 +184,8 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
if (ctx->Fog.Enabled ||
(ctx->FragmentProgram._Active &&
- ctx->FragmentProgram._Current->FogOption != GL_NONE))
+ (ctx->FragmentProgram._Current->FogOption != GL_NONE ||
+ ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_FOGC)))
RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
if (ctx->Polygon.FrontMode != GL_FILL ||
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 97ad79c58fd..d5414bd730d 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -248,6 +248,7 @@ struct _tnl_dynfn_generators {
struct tnl_vtx {
GLfloat buffer[VERT_BUFFER_SIZE];
GLubyte attrsz[_TNL_ATTRIB_MAX];
+ GLubyte active_sz[_TNL_ATTRIB_MAX];
GLuint vertex_size;
struct tnl_prim prim[TNL_MAX_PRIM];
GLuint prim_count;
diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c
index 0ff26df713a..71fb45dd95c 100644
--- a/src/mesa/tnl/t_vb_arbprogram.c
+++ b/src/mesa/tnl/t_vb_arbprogram.c
@@ -1182,7 +1182,8 @@ do_ndc_cliptest(GLcontext *ctx, struct arb_vp_machine *m)
/* Test userclip planes. This contributes to VB->ClipMask.
*/
- if (ctx->Transform.ClipPlanesEnabled && !ctx->VertexProgram._Enabled) {
+ if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
+ ctx->VertexProgram.Current->IsPositionInvariant)) {
userclip( ctx,
VB->ClipPtr,
m->clipmask,
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
index f3776e7eeb6..788fe329ed8 100644
--- a/src/mesa/tnl/t_vb_cliptmp.h
+++ b/src/mesa/tnl/t_vb_cliptmp.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 6.5.2
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
@@ -125,6 +125,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
GLfloat t0 = 0;
GLfloat t1 = 0;
GLuint p;
+ const GLuint v0_orig = v0;
if (mask & 0x3f) {
LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
@@ -153,12 +154,17 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
v0 = newvert;
newvert++;
}
- else
+ else {
ASSERT(t0 == 0.0);
+ }
+ /* Note: we need to use vertex v0_orig when computing the new
+ * interpolated/clipped vertex position, not the current v0 which
+ * may have got set when we clipped the other end of the line!
+ */
if (VB->ClipMask[v1]) {
- INTERP_4F( t1, coord[newvert], coord[v1], coord[v0] );
- interp( ctx, t1, newvert, v1, v0, GL_FALSE );
+ INTERP_4F( t1, coord[newvert], coord[v1], coord[v0_orig] );
+ interp( ctx, t1, newvert, v1, v0_orig, GL_FALSE );
if (ctx->Light.ShadeModel == GL_FLAT)
tnl->Driver.Render.CopyPV( ctx, newvert, v1 );
@@ -167,8 +173,9 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
newvert++;
}
- else
+ else {
ASSERT(t1 == 0.0);
+ }
tnl->Driver.Render.ClippedLine( ctx, v0, v1 );
}
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 36ee4b2f46a..f11ac616f16 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -76,6 +76,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
struct vp_stage_data *store = VP_STAGE_DATA(stage);
struct vertex_buffer *VB = &tnl->vb;
struct gl_vertex_program *program = ctx->VertexProgram.Current;
+ struct vp_machine machine;
GLuint i;
if (ctx->ShaderObjects._VertexShaderPresent)
@@ -91,7 +92,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
for (i = 0; i < VB->Count; i++) {
GLuint attr;
- _mesa_init_vp_per_vertex_registers(ctx);
+ _mesa_init_vp_per_vertex_registers(ctx, &machine);
#if 0
printf("Input %d: %f, %f, %f, %f\n", i,
@@ -118,30 +119,29 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
const GLfloat *data = (GLfloat *) (ptr + stride * i);
- COPY_CLEAN_4V(ctx->VertexProgram.Inputs[attr], size, data);
+ COPY_CLEAN_4V(machine.Inputs[attr], size, data);
}
}
/* execute the program */
ASSERT(program);
- _mesa_exec_vertex_program(ctx, program);
+ _mesa_exec_vertex_program(ctx, &machine, program);
/* Fixup fog an point size results if needed */
if (ctx->Fog.Enabled &&
(program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0;
+ machine.Outputs[VERT_RESULT_FOGC][0] = 1.0;
}
if (ctx->VertexProgram.PointSizeEnabled &&
(program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
+ machine.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
}
/* copy the output registers into the VB->attribs arrays */
/* XXX (optimize) could use a conditional and smaller loop limit here */
for (attr = 0; attr < 15; attr++) {
- COPY_4V(store->attribs[attr].data[i],
- ctx->VertexProgram.Outputs[attr]);
+ COPY_4V(store->attribs[attr].data[i], machine.Outputs[attr]);
}
}
diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c
index 9379d91780c..b766ce2d2ce 100644
--- a/src/mesa/tnl/t_vtx_api.c
+++ b/src/mesa/tnl/t_vtx_api.c
@@ -174,6 +174,8 @@ static void _tnl_copy_to_current( GLcontext *ctx )
}
ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+
+ ctx->NewState |= _NEW_LIGHT;
}
@@ -321,13 +323,17 @@ static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
static const GLfloat id[4] = { 0, 0, 0, 1 };
int i;
+ if (0)
+ _mesa_printf("%s attr %d sz %d -> %d\n",
+ __FUNCTION__, attr, tnl->vtx.attrsz[attr], sz);
+
if (tnl->vtx.attrsz[attr] < sz) {
/* New size is larger. Need to flush existing vertices and get
* an enlarged vertex format.
*/
_tnl_wrap_upgrade_vertex( ctx, attr, sz );
}
- else if (tnl->vtx.attrsz[attr] > sz) {
+ else if (sz < tnl->vtx.active_sz[attr]) {
/* New size is smaller - just need to fill in some
* zeros. Don't need to flush or wrap.
*/
@@ -335,6 +341,8 @@ static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
tnl->vtx.attrptr[attr][i-1] = id[i-1];
}
+ tnl->vtx.active_sz[attr] = sz;
+
/* Does setting NeedFlush belong here? Necessitates resetting
* vtxfmt on each flush (otherwise flags won't get reset
* afterwards).
@@ -398,7 +406,7 @@ static tnl_attrfv_func do_choose( GLuint attr, GLuint sz )
{
GET_CURRENT_CONTEXT( ctx );
TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint oldsz = tnl->vtx.attrsz[attr];
+ GLuint oldsz = tnl->vtx.active_sz[attr];
assert(attr < _TNL_MAX_ATTR_CODEGEN);
@@ -519,6 +527,7 @@ reset_attrfv(TNLcontext *tnl)
if (tnl->vtx.attrsz[i]) {
GLint j = tnl->vtx.attrsz[i] - 1;
tnl->vtx.attrsz[i] = 0;
+ tnl->vtx.active_sz[i] = 0;
if (i < _TNL_MAX_ATTR_CODEGEN) {
while (j >= 0) {
@@ -550,7 +559,7 @@ reset_attrfv(TNLcontext *tnl)
*/
#define OTHER_ATTR( A, N, params ) \
do { \
- if (tnl->vtx.attrsz[A] != N) { \
+ if (tnl->vtx.active_sz[A] != N) { \
_tnl_fixup_vertex( ctx, A, N ); \
} \
\
@@ -650,7 +659,7 @@ static void GLAPIENTRY _tnl_EvalCoord1f( GLfloat u )
for (i = 0; i < _TNL_NUM_EVAL; i++) {
if (tnl->vtx.eval.map1[i].map)
- if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map1[i].sz)
+ if (tnl->vtx.active_sz[i] != tnl->vtx.eval.map1[i].sz)
_tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map1[i].sz );
}
}
@@ -678,12 +687,12 @@ static void GLAPIENTRY _tnl_EvalCoord2f( GLfloat u, GLfloat v )
for (i = 0; i < _TNL_NUM_EVAL; i++) {
if (tnl->vtx.eval.map2[i].map)
- if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map2[i].sz)
+ if (tnl->vtx.active_sz[i] != tnl->vtx.eval.map2[i].sz)
_tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map2[i].sz );
}
if (ctx->Eval.AutoNormal)
- if (tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL] != 3)
+ if (tnl->vtx.active_sz[_TNL_ATTRIB_NORMAL] != 3)
_tnl_fixup_vertex( ctx, _TNL_ATTRIB_NORMAL, 3 );
}
@@ -1005,8 +1014,10 @@ void _tnl_vtx_init( GLcontext *ctx )
_mesa_memcpy( tnl->vtx.tabfv, choose, sizeof(choose) );
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++) {
tnl->vtx.attrsz[i] = 0;
+ tnl->vtx.active_sz[i] = 0;
+ }
tnl->vtx.vertex_size = 0;
tnl->vtx.have_materials = 0;