summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-07-19 15:28:29 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-07-19 15:28:29 +0000
commit0749e2723b32ba430539791b94acd95dcf939a1d (patch)
tree066fe341ee47a9dbdfde90a84db9a5fecba86d61 /src/mesa
parent69ddf6cc41a18c6947e7deeb0b4240946f5ddb34 (diff)
Several loops over the map1/2 evaluator arrays were incorrect.
There's only 16 evaluator maps. Define new _TNL_NUM_EVAL constant for those loops. Also, fix priority of GL_NV_vertex_program generic maps - they override the conventional maps. See bug 7564.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/tnl/t_context.h7
-rw-r--r--src/mesa/tnl/t_vtx_api.c4
-rw-r--r--src/mesa/tnl/t_vtx_eval.c41
3 files changed, 33 insertions, 19 deletions
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 5cf262c580..97ad79c58f 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -172,6 +172,9 @@ enum {
/* Number of available generic attributes */
#define _TNL_NUM_GENERIC 16
+/* Number of attributes used for evaluators */
+#define _TNL_NUM_EVAL 16
+
#define PRIM_BEGIN 0x10
#define PRIM_END 0x20
#define PRIM_WEAK 0x40
@@ -199,8 +202,8 @@ struct tnl_eval2_map {
struct tnl_eval {
GLuint new_state;
- struct tnl_eval1_map map1[_TNL_ATTRIB_EDGEFLAG + 1];
- struct tnl_eval2_map map2[_TNL_ATTRIB_EDGEFLAG + 1];
+ struct tnl_eval1_map map1[_TNL_NUM_EVAL];
+ struct tnl_eval2_map map2[_TNL_NUM_EVAL];
};
diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c
index 4765228269..214af5b63c 100644
--- a/src/mesa/tnl/t_vtx_api.c
+++ b/src/mesa/tnl/t_vtx_api.c
@@ -649,7 +649,7 @@ static void GLAPIENTRY _tnl_EvalCoord1f( GLfloat u )
if (tnl->vtx.eval.new_state)
_tnl_update_eval( ctx );
- for (i = 0 ; i <= _TNL_ATTRIB_EDGEFLAG ; i++) {
+ 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)
_tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map1[i].sz );
@@ -677,7 +677,7 @@ static void GLAPIENTRY _tnl_EvalCoord2f( GLfloat u, GLfloat v )
if (tnl->vtx.eval.new_state)
_tnl_update_eval( ctx );
- for (i = 0 ; i <= _TNL_ATTRIB_EDGEFLAG ; i++) {
+ 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)
_tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map2[i].sz );
diff --git a/src/mesa/tnl/t_vtx_eval.c b/src/mesa/tnl/t_vtx_eval.c
index e21cc7f00a..71564076e3 100644
--- a/src/mesa/tnl/t_vtx_eval.c
+++ b/src/mesa/tnl/t_vtx_eval.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.5.1
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -36,17 +36,20 @@
static void clear_active_eval1( TNLcontext *tnl, GLuint attr )
{
+ ASSERT(attr < _TNL_NUM_EVAL);
tnl->vtx.eval.map1[attr].map = NULL;
}
static void clear_active_eval2( TNLcontext *tnl, GLuint attr )
{
+ ASSERT(attr < _TNL_NUM_EVAL);
tnl->vtx.eval.map2[attr].map = NULL;
}
static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim,
struct gl_1d_map *map )
{
+ ASSERT(attr < _TNL_NUM_EVAL);
if (!tnl->vtx.eval.map1[attr].map) {
tnl->vtx.eval.map1[attr].map = map;
tnl->vtx.eval.map1[attr].sz = dim;
@@ -56,6 +59,7 @@ static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim,
static void set_active_eval2( TNLcontext *tnl, GLuint attr, GLuint dim,
struct gl_2d_map *map )
{
+ ASSERT(attr < _TNL_NUM_EVAL);
if (!tnl->vtx.eval.map2[attr].map) {
tnl->vtx.eval.map2[attr].map = map;
tnl->vtx.eval.map2[attr].sz = dim;
@@ -69,21 +73,11 @@ void _tnl_update_eval( GLcontext *ctx )
/* Vertex program maps have priority over conventional attribs */
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ for (attr = 0; attr < _TNL_NUM_EVAL; attr++) {
clear_active_eval1( tnl, attr );
clear_active_eval2( tnl, attr );
}
- if (ctx->VertexProgram._Enabled) {
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (ctx->Eval.Map1Attrib[attr])
- set_active_eval1( tnl, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
-
- if (ctx->Eval.Map2Attrib[attr])
- set_active_eval2( tnl, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
- }
- }
-
if (ctx->Eval.Map1Color4)
set_active_eval1( tnl, VERT_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
@@ -124,6 +118,23 @@ void _tnl_update_eval( GLcontext *ctx )
else if (ctx->Eval.Map2Vertex3)
set_active_eval2( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
+ /* Evaluators with generic attributes is only supported for NV vertex
+ * programs, not ARB vertex programs. 16 evaluator maps are supported.
+ * We do this after the conventional attributes since the spec says that
+ * these generic maps have higher priority.
+ */
+ if (ctx->VertexProgram._Enabled &&
+ ctx->VertexProgram._Current &&
+ ctx->VertexProgram._Current->IsNVProgram) {
+ for (attr = 0; attr < 16; attr++) {
+ if (ctx->Eval.Map1Attrib[attr])
+ set_active_eval1( tnl, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
+
+ if (ctx->Eval.Map2Attrib[attr])
+ set_active_eval2( tnl, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
+ }
+ }
+
tnl->vtx.eval.new_state = 0;
}
@@ -134,7 +145,7 @@ void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u)
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint attr;
- for (attr = 1; attr <= _TNL_ATTRIB_EDGEFLAG; attr++) {
+ for (attr = 1; attr < _TNL_NUM_EVAL; attr++) {
struct gl_1d_map *map = tnl->vtx.eval.map1[attr].map;
if (map) {
GLfloat uu = (u - map->u1) * map->du;
@@ -179,7 +190,7 @@ void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v )
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint attr;
- for (attr = 1; attr <= _TNL_ATTRIB_EDGEFLAG; attr++) {
+ for (attr = 1; attr < _TNL_NUM_EVAL; attr++) {
struct gl_2d_map *map = tnl->vtx.eval.map2[attr].map;
if (map) {
GLfloat uu = (u - map->u1) * map->du;