summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2006-10-30 16:44:13 +0000
committerKeith Whitwell <[email protected]>2006-10-30 16:44:13 +0000
commit99efde461d3b8615863bdb7308e05289e0db0422 (patch)
tree95b9e3f4f612957a93547892f3559cfaa44dccb7 /src/mesa
parentefef291dc71eb57f90785a26957f4b3e01733156 (diff)
better handling of current attributes. Trivial dlist and varray tests work
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/Makefile2
-rw-r--r--src/mesa/main/arrayobj.c9
-rw-r--r--src/mesa/main/enable.c2
-rw-r--r--src/mesa/main/mtypes.h10
-rw-r--r--src/mesa/sources30
-rw-r--r--src/mesa/tnl/t_context.c2
-rw-r--r--src/mesa/vbo/vbo_context.c144
-rw-r--r--src/mesa/vbo/vbo_context.h7
-rw-r--r--src/mesa/vbo/vbo_exec.c117
-rw-r--r--src/mesa/vbo/vbo_exec.h4
-rw-r--r--src/mesa/vbo/vbo_exec_array.c15
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c38
-rw-r--r--src/mesa/vbo/vbo_save_draw.c28
13 files changed, 235 insertions, 173 deletions
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 3f65ecf5cc9..e06607b0f83 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -142,7 +142,7 @@ depend: $(ALL_SOURCES)
@ echo "running $(MKDEP)"
@ touch depend
@$(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
- > /dev/null
+ > /dev/null 2>/dev/null
subdirs:
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 852b9aaee98..d601ee461e6 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -114,40 +114,34 @@ _mesa_initialize_array_object( GLcontext *ctx,
obj->Vertex.StrideB = 0;
obj->Vertex.Ptr = NULL;
obj->Vertex.Enabled = GL_FALSE;
- obj->Vertex.Flags = CA_CLIENT_DATA;
obj->Normal.Type = GL_FLOAT;
obj->Normal.Stride = 0;
obj->Normal.StrideB = 0;
obj->Normal.Ptr = NULL;
obj->Normal.Enabled = GL_FALSE;
- obj->Normal.Flags = CA_CLIENT_DATA;
obj->Color.Size = 4;
obj->Color.Type = GL_FLOAT;
obj->Color.Stride = 0;
obj->Color.StrideB = 0;
obj->Color.Ptr = NULL;
obj->Color.Enabled = GL_FALSE;
- obj->Color.Flags = CA_CLIENT_DATA;
obj->SecondaryColor.Size = 4;
obj->SecondaryColor.Type = GL_FLOAT;
obj->SecondaryColor.Stride = 0;
obj->SecondaryColor.StrideB = 0;
obj->SecondaryColor.Ptr = NULL;
obj->SecondaryColor.Enabled = GL_FALSE;
- obj->SecondaryColor.Flags = CA_CLIENT_DATA;
obj->FogCoord.Size = 1;
obj->FogCoord.Type = GL_FLOAT;
obj->FogCoord.Stride = 0;
obj->FogCoord.StrideB = 0;
obj->FogCoord.Ptr = NULL;
obj->FogCoord.Enabled = GL_FALSE;
- obj->FogCoord.Flags = CA_CLIENT_DATA;
obj->Index.Type = GL_FLOAT;
obj->Index.Stride = 0;
obj->Index.StrideB = 0;
obj->Index.Ptr = NULL;
obj->Index.Enabled = GL_FALSE;
- obj->Index.Flags = CA_CLIENT_DATA;
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
obj->TexCoord[i].Size = 4;
obj->TexCoord[i].Type = GL_FLOAT;
@@ -155,13 +149,11 @@ _mesa_initialize_array_object( GLcontext *ctx,
obj->TexCoord[i].StrideB = 0;
obj->TexCoord[i].Ptr = NULL;
obj->TexCoord[i].Enabled = GL_FALSE;
- obj->TexCoord[i].Flags = CA_CLIENT_DATA;
}
obj->EdgeFlag.Stride = 0;
obj->EdgeFlag.StrideB = 0;
obj->EdgeFlag.Ptr = NULL;
obj->EdgeFlag.Enabled = GL_FALSE;
- obj->EdgeFlag.Flags = CA_CLIENT_DATA;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
obj->VertexAttrib[i].Size = 4;
obj->VertexAttrib[i].Type = GL_FLOAT;
@@ -170,7 +162,6 @@ _mesa_initialize_array_object( GLcontext *ctx,
obj->VertexAttrib[i].Ptr = NULL;
obj->VertexAttrib[i].Enabled = GL_FALSE;
obj->VertexAttrib[i].Normalized = GL_FALSE;
- obj->VertexAttrib[i].Flags = CA_CLIENT_DATA;
}
#if FEATURE_ARB_vertex_buffer_object
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 91268b596d2..bf86e6db7d2 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -53,7 +53,7 @@ static void
client_state( GLcontext *ctx, GLenum cap, GLboolean state )
{
GLuint flag;
- GLuint *var;
+ GLboolean *var;
switch (cap) {
case GL_VERTEX_ARRAY:
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5a326ff0dc9..903779edae5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1640,8 +1640,6 @@ struct gl_pixelstore_attrib
};
-#define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
-
/**
* Client vertex array attributes
@@ -1653,14 +1651,12 @@ struct gl_client_array
GLsizei Stride; /**< user-specified stride */
GLsizei StrideB; /**< actual stride in bytes */
const GLubyte *Ptr; /**< Points to array data */
- GLbitfield Enabled; /**< one of the _NEW_ARRAY_ bits */
+ GLboolean Enabled; /**< Enabled flag is a boolean */
GLboolean Normalized; /**< GL_ARB_vertex_program */
/**< GL_ARB_vertex_buffer_object */
struct gl_buffer_object *BufferObj;
GLuint _MaxElement;
-
- GLbitfield Flags;
};
@@ -1681,8 +1677,8 @@ struct gl_array_object
struct gl_client_array SecondaryColor;
struct gl_client_array FogCoord;
struct gl_client_array Index;
- struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
struct gl_client_array EdgeFlag;
+ struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
/*@}*/
/** Generic arrays for vertex programs/shaders */
@@ -2617,7 +2613,7 @@ struct matrix_stack
#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
-#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
+#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */
#define _NEW_ARRAY_ALL 0xffffffff
diff --git a/src/mesa/sources b/src/mesa/sources
index 09692c6f155..b589111a19b 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -78,10 +78,6 @@ MATH_SOURCES = \
math/m_vector.c \
math/m_xform.c
-ARRAY_CACHE_SOURCES = \
- array_cache/ac_context.c \
- array_cache/ac_import.c
-
SWRAST_SOURCES = \
swrast/s_aaline.c \
swrast/s_aatriangle.c \
@@ -119,13 +115,9 @@ SWRAST_SETUP_SOURCES = \
swrast_setup/ss_triangle.c
TNL_SOURCES = \
- tnl/t_array_api.c \
- tnl/t_array_import.c \
tnl/t_context.c \
tnl/t_pipeline.c \
- tnl/t_save_api.c \
- tnl/t_save_loopback.c \
- tnl/t_save_playback.c \
+ tnl/t_draw.c \
tnl/t_vb_arbprogram.c \
tnl/t_vb_arbprogram_sse.c \
tnl/t_vb_arbshader.c\
@@ -142,13 +134,19 @@ TNL_SOURCES = \
tnl/t_vp_build.c \
tnl/t_vertex.c \
tnl/t_vertex_sse.c \
- tnl/t_vertex_generic.c \
- tnl/t_vtx_api.c \
- tnl/t_vtx_generic.c \
- tnl/t_vtx_x86.c \
- tnl/t_vtx_eval.c \
- tnl/t_vtx_exec.c
+ tnl/t_vertex_generic.c
+VBO_SOURCES = \
+ vbo/vbo_context.c \
+ vbo/vbo_exec.c \
+ vbo/vbo_exec_api.c \
+ vbo/vbo_exec_array.c \
+ vbo/vbo_exec_draw.c \
+ vbo/vbo_exec_eval.c \
+ vbo/vbo_save.c \
+ vbo/vbo_save_api.c \
+ vbo/vbo_save_draw.c \
+ vbo/vbo_save_loopback.c
SHADER_SOURCES = \
@@ -317,7 +315,7 @@ ALL_SOURCES = \
SOLO_SOURCES = \
$(MAIN_SOURCES) \
$(MATH_SOURCES) \
- $(ARRAY_CACHE_SOURCES) \
+ $(VBO_SOURCES) \
$(TNL_SOURCES) \
$(SHADER_SOURCES) \
$(SWRAST_SOURCES) \
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index ff05ac03181..851a0672d42 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -77,6 +77,8 @@ _tnl_CreateContext( GLcontext *ctx )
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables;
+ tnl->nr_blocks = 0;
+
return GL_TRUE;
}
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 5f28e6b0e07..29dfe09d997 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -40,6 +40,123 @@ extern void _tnl_draw_prims( GLcontext *ctx,
GLuint min_index,
GLuint max_index );
+
+
+#define NR_LEGACY_ATTRIBS 16
+#define NR_GENERIC_ATTRIBS 16
+#define NR_MAT_ATTRIBS 12
+
+static void init_legacy_currval(GLcontext *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->legacy_currval;
+ GLuint i;
+
+ memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
+
+ /* Set up a constant (StrideB == 0) array for each current
+ * attribute:
+ */
+ for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ switch (i) {
+ case VBO_ATTRIB_EDGEFLAG:
+ cl->Type = GL_UNSIGNED_BYTE;
+ cl->Ptr = (const void *)&ctx->Current.EdgeFlag;
+ break;
+ case VBO_ATTRIB_INDEX:
+ cl->Type = GL_FLOAT;
+ cl->Ptr = (const void *)&ctx->Current.Index;
+ break;
+ default:
+ cl->Type = GL_FLOAT;
+ cl->Ptr = (const void *)ctx->Current.Attrib[i];
+ break;
+ }
+
+ /* This will have to be determined at runtime:
+ */
+ cl->Size = 1;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->BufferObj = ctx->Array.NullBufferObj;
+ }
+}
+
+
+static void init_generic_currval(GLcontext *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->generic_currval;
+ GLuint i;
+
+ memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+
+ for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ /* This will have to be determined at runtime:
+ */
+ cl->Size = 1;
+
+ cl->Type = GL_FLOAT;
+ cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->BufferObj = ctx->Array.NullBufferObj;
+ }
+}
+
+
+static void init_mat_currval(GLcontext *ctx)
+{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct gl_client_array *arrays = vbo->mat_currval;
+ GLuint i;
+
+ memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+
+ /* Set up a constant (StrideB == 0) array for each current
+ * attribute:
+ */
+ for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+ struct gl_client_array *cl = &arrays[i];
+
+ /* Size is fixed for the material attributes, for others will
+ * be determined at runtime:
+ */
+ switch (i - VERT_ATTRIB_GENERIC0) {
+ case MAT_ATTRIB_FRONT_SHININESS:
+ case MAT_ATTRIB_BACK_SHININESS:
+ cl->Size = 1;
+ break;
+ case MAT_ATTRIB_FRONT_INDEXES:
+ case MAT_ATTRIB_BACK_INDEXES:
+ cl->Size = 3;
+ break;
+ default:
+ cl->Size = 4;
+ break;
+ }
+
+ if (i < MAT_ATTRIB_MAX)
+ cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
+ else
+ cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
+
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Enabled = 1;
+ cl->BufferObj = ctx->Array.NullBufferObj;
+ }
+}
+
+
+
GLboolean _vbo_CreateContext( GLcontext *ctx )
{
struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);
@@ -60,6 +177,32 @@ GLboolean _vbo_CreateContext( GLcontext *ctx )
vbo_exec_init( ctx );
vbo_save_init( ctx );
+
+ init_legacy_currval( ctx );
+ init_generic_currval( ctx );
+ init_mat_currval( ctx );
+
+ /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
+ * of vertex program active.
+ */
+ {
+ GLuint i;
+
+ /* When no vertex program, pull in the material attributes in
+ * the 16..32 generic range.
+ */
+ for (i = 0; i < 16; i++)
+ vbo->map_vp_none[i] = i;
+ for (i = 0; i < 12; i++)
+ vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
+ for (i = 0; i < 4; i++)
+ vbo->map_vp_none[28+i] = i;
+
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ vbo->map_vp_arb[i] = i;
+ }
+
+
/* By default:
*/
vbo->draw_prims = _tnl_draw_prims;
@@ -82,5 +225,4 @@ void _vbo_DestroyContext( GLcontext *ctx )
FREE(vbo_context(ctx));
ctx->swtnl_im = NULL;
-
}
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index 6b0f14d70ea..a20bfbd518b 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -60,6 +60,13 @@ void _vbo_DestroyContext( GLcontext *ctx );
struct vbo_context {
+ struct gl_client_array legacy_currval[16];
+ struct gl_client_array generic_currval[16];
+ struct gl_client_array mat_currval[16];
+
+ GLuint map_vp_none[32];
+ GLuint map_vp_arb[32];
+
struct vbo_exec_context exec;
struct vbo_save_context save;
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index 4499803b8c7..270e5201d35 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -38,119 +38,6 @@
#include "vbo_context.h"
-#define NR_LEGACY_ATTRIBS 16
-#define NR_GENERIC_ATTRIBS 16
-#define NR_MAT_ATTRIBS 12
-
-static void init_legacy_currval(GLcontext *ctx)
-{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- struct gl_client_array *arrays = exec->legacy_currval;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
-
- /* Set up a constant (StrideB == 0) array for each current
- * attribute:
- */
- for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- switch (i) {
- case VBO_ATTRIB_EDGEFLAG:
- cl->Type = GL_UNSIGNED_BYTE;
- cl->Ptr = (const void *)&ctx->Current.EdgeFlag;
- break;
- case VBO_ATTRIB_INDEX:
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)&ctx->Current.Index;
- break;
- default:
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)ctx->Current.Attrib[i];
- break;
- }
-
- /* This will have to be determined at runtime:
- */
- cl->Size = 1;
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->BufferObj = ctx->Array.NullBufferObj;
- }
-}
-
-
-static void init_generic_currval(GLcontext *ctx)
-{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- struct gl_client_array *arrays = exec->generic_currval;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
-
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- /* This will have to be determined at runtime:
- */
- cl->Size = 1;
-
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->BufferObj = ctx->Array.NullBufferObj;
- }
-}
-
-
-static void init_mat_currval(GLcontext *ctx)
-{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- struct gl_client_array *arrays = exec->mat_currval;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
-
- /* Set up a constant (StrideB == 0) array for each current
- * attribute:
- */
- for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- /* Size is fixed for the material attributes, for others will
- * be determined at runtime:
- */
- switch (i - VERT_ATTRIB_GENERIC0) {
- case MAT_ATTRIB_FRONT_SHININESS:
- case MAT_ATTRIB_BACK_SHININESS:
- cl->Size = 1;
- break;
- case MAT_ATTRIB_FRONT_INDEXES:
- case MAT_ATTRIB_BACK_INDEXES:
- cl->Size = 3;
- break;
- default:
- cl->Size = 4;
- break;
- }
-
- if (i < MAT_ATTRIB_MAX)
- cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
- else
- cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
-
- cl->Type = GL_FLOAT;
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->BufferObj = ctx->Array.NullBufferObj;
- }
-}
-
void vbo_exec_init( GLcontext *ctx )
{
@@ -167,10 +54,6 @@ void vbo_exec_init( GLcontext *ctx )
vbo_exec_vtx_init( exec );
vbo_exec_array_init( exec );
- init_legacy_currval( ctx );
- init_generic_currval( ctx );
- init_mat_currval( ctx );
-
ctx->Driver.NeedFlush = 0;
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
ctx->Driver.FlushVertices = vbo_exec_FlushVertices;
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 4542d2807cd..72855d267ed 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -75,10 +75,6 @@ struct vbo_exec_context
GLcontext *ctx;
GLvertexformat vtxfmt;
- struct gl_client_array legacy_currval[16];
- struct gl_client_array generic_currval[16];
- struct gl_client_array mat_currval[16];
-
struct {
struct gl_buffer_object *bufferobj;
GLubyte *buffer_map;
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 5cfa7a01a96..b3650e26978 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -107,7 +107,8 @@ static void bind_array_obj( GLcontext *ctx )
static void recalculate_input_bindings( GLcontext *ctx )
{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_exec_context *exec = &vbo->exec;
const struct gl_client_array **inputs = &exec->array.inputs[0];
GLuint i;
@@ -126,11 +127,11 @@ static void recalculate_input_bindings( GLcontext *ctx )
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else
- inputs[i] = &exec->legacy_currval[i];
+ inputs[i] = &vbo->legacy_currval[i];
}
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
- inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->mat_currval[i];
+ inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->mat_currval[i];
}
break;
case VP_NV:
@@ -144,7 +145,7 @@ static void recalculate_input_bindings( GLcontext *ctx )
else if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else
- inputs[i] = &exec->legacy_currval[i];
+ inputs[i] = &vbo->legacy_currval[i];
}
break;
case VP_ARB:
@@ -160,21 +161,21 @@ static void recalculate_input_bindings( GLcontext *ctx )
else if (exec->array.legacy_array[0]->Enabled)
inputs[0] = exec->array.legacy_array[0];
else
- inputs[0] = &exec->legacy_currval[0];
+ inputs[0] = &vbo->legacy_currval[0];
for (i = 1; i <= VERT_ATTRIB_TEX7; i++) {
if (exec->array.legacy_array[i]->Enabled)
inputs[i] = exec->array.legacy_array[i];
else
- inputs[i] = &exec->legacy_currval[i];
+ inputs[i] = &vbo->legacy_currval[i];
}
for (i = 0; i < 16; i++) {
if (exec->array.generic_array[0]->Enabled)
inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
else
- inputs[VERT_ATTRIB_GENERIC0 + i] = &exec->generic_currval[i];
+ inputs[VERT_ATTRIB_GENERIC0 + i] = &vbo->generic_currval[i];
}
break;
}
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index f665c64c7ac..c1898aea497 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -132,25 +132,49 @@ static GLuint vbo_copy_vertices( struct vbo_exec_context *exec )
}
+
/* TODO: populate these as the vertex is defined:
*/
-static void vbo_exec_bind_arrays( struct vbo_exec_context *exec )
+static void vbo_exec_bind_arrays( GLcontext *ctx )
{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_exec_context *exec = &vbo->exec;
struct gl_client_array *arrays = exec->vtx.arrays;
GLuint count = exec->vtx.vert_count;
GLubyte *data = exec->vtx.buffer_map;
+ const GLuint *map;
GLuint attr;
- memcpy(arrays, exec->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, exec->mat_currval, 16 * sizeof(arrays[0]));
+ /* Install the default (ie Current) attributes first, then overlay
+ * all active ones.
+ */
+ switch (get_program_mode(exec->ctx)) {
+ case VP_NONE:
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0]));
+ map = vbo->map_vp_none;
+ break;
+ case VP_NV:
+ case VP_ARB:
+ /* The aliasing of attributes for NV vertex programs has already
+ * occurred. NV vertex programs cannot access material values,
+ * nor attributes greater than VERT_ATTRIB_TEX7.
+ */
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ map = vbo->map_vp_arb;
+ break;
+ }
/* Make all active attributes (including edgeflag) available as
* arrays of floats.
*/
- for (attr = 0; attr < VBO_ATTRIB_MAX ; attr++) {
- if (exec->vtx.attrsz[attr]) {
+ for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) {
+ GLuint src = map[attr];
+
+ if (exec->vtx.attrsz[src]) {
arrays[attr].Ptr = (void *)data;
- arrays[attr].Size = exec->vtx.attrsz[attr];
+ arrays[attr].Size = exec->vtx.attrsz[src];
arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
arrays[attr].Type = GL_FLOAT;
@@ -181,7 +205,7 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
if (exec->vtx.copied.nr != exec->vtx.vert_count) {
GLcontext *ctx = exec->ctx;
- vbo_exec_bind_arrays( exec );
+ vbo_exec_bind_arrays( ctx );
vbo_context(ctx)->draw_prims( ctx,
exec->vtx.inputs,
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 44e01712330..18c770a41cb 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -95,14 +95,36 @@ static void _playback_copy_to_current( GLcontext *ctx,
/* Treat the vertex storage as a VBO, define vertex arrays pointing
* into it:
*/
-static void vbo_bind_vertex_list( struct vbo_save_context *save,
+static void vbo_bind_vertex_list( GLcontext *ctx,
const struct vbo_save_vertex_list *node )
{
+ struct vbo_context *vbo = vbo_context(ctx);
+ struct vbo_save_context *save = &vbo->save;
struct gl_client_array *arrays = save->arrays;
GLuint data = node->buffer_offset;
+ const GLuint *map;
GLuint attr;
- memset(arrays, 0, VBO_ATTRIB_MAX * sizeof(arrays[0]));
+ /* Install the default (ie Current) attributes first, then overlay
+ * all active ones.
+ */
+ switch (get_program_mode(ctx)) {
+ case VP_NONE:
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->mat_currval, 16 * sizeof(arrays[0]));
+ map = vbo->map_vp_none;
+ break;
+ case VP_NV:
+ case VP_ARB:
+ /* The aliasing of attributes for NV vertex programs has already
+ * occurred. NV vertex programs cannot access material values,
+ * nor attributes greater than VERT_ATTRIB_TEX7.
+ */
+ memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
+ memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ map = vbo->map_vp_arb;
+ break;
+ }
for (attr = 0; attr <= VBO_ATTRIB_INDEX; attr++) {
if (node->attrsz[attr]) {
@@ -185,7 +207,7 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data )
return;
}
- vbo_bind_vertex_list( save, node );
+ vbo_bind_vertex_list( ctx, node );
vbo_context(ctx)->draw_prims( ctx,
save->inputs,