summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_exec.c4
-rw-r--r--src/mesa/main/arrayobj.c115
-rw-r--r--src/mesa/main/arrayobj.h5
-rw-r--r--src/mesa/main/context.c1
-rw-r--r--src/mesa/main/enums.c244
-rw-r--r--src/mesa/main/extensions.c2
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/shared.c17
-rw-r--r--src/mesa/main/varray.c103
-rw-r--r--src/mesa/main/varray.h4
10 files changed, 301 insertions, 202 deletions
diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index 534fef00df3..e49cd041a6a 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -904,4 +904,8 @@ _mesa_init_exec_table(struct _glapi_table *exec)
/* GL_ARB_copy_buffer */
SET_CopyBufferSubData(exec, _mesa_CopyBufferSubData);
+
+ /* GL_ARB_vertex_array_object */
+ SET_BindVertexArray(exec, _mesa_BindVertexArray);
+ SET_GenVertexArrays(exec, _mesa_GenVertexArrays);
}
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index c03353b78f5..fd35d4e38c9 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -63,10 +63,11 @@
static INLINE struct gl_array_object *
lookup_arrayobj(GLcontext *ctx, GLuint id)
{
- return (id == 0)
- ? NULL
- : (struct gl_array_object *) _mesa_HashLookup(ctx->Shared->ArrayObjects,
- id);
+ if (id == 0)
+ return NULL;
+ else
+ return (struct gl_array_object *)
+ _mesa_HashLookup(ctx->Array.Objects, id);
}
@@ -252,7 +253,7 @@ save_array_object( GLcontext *ctx, struct gl_array_object *obj )
{
if (obj->Name > 0) {
/* insert into hash table */
- _mesa_HashInsert(ctx->Shared->ArrayObjects, obj->Name, obj);
+ _mesa_HashInsert(ctx->Array.Objects, obj->Name, obj);
}
}
@@ -266,7 +267,7 @@ remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
{
if (obj->Name > 0) {
/* remove from hash table */
- _mesa_HashRemove(ctx->Shared->ArrayObjects, obj->Name);
+ _mesa_HashRemove(ctx->Array.Objects, obj->Name);
}
}
@@ -352,18 +353,15 @@ _mesa_update_array_object_max_element(GLcontext *ctx,
/* API Functions */
/**********************************************************************/
+
/**
- * Bind a new array.
- *
- * \todo
- * The binding could be done more efficiently by comparing the non-NULL
- * pointers in the old and new objects. The only arrays that are "dirty" are
- * the ones that are non-NULL in either object.
+ * Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE().
+ * \param genRequired specifies behavour when id was not generated with
+ * glGenVertexArrays().
*/
-void GLAPIENTRY
-_mesa_BindVertexArrayAPPLE( GLuint id )
+static void
+bind_vertex_array(GLcontext *ctx, GLuint id, GLboolean genRequired)
{
- GET_CURRENT_CONTEXT(ctx);
struct gl_array_object * const oldObj = ctx->Array.ArrayObj;
struct gl_array_object *newObj = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -386,8 +384,12 @@ _mesa_BindVertexArrayAPPLE( GLuint id )
/* non-default array object */
newObj = lookup_arrayobj(ctx, id);
if (!newObj) {
- /* If this is a new array object id, allocate an array object now.
- */
+ if (genRequired) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBindVertexArray(id)");
+ return;
+ }
+
+ /* For APPLE version, generate a new array object now */
newObj = (*ctx->Driver.NewArrayObject)(ctx, id);
if (!newObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE");
@@ -403,7 +405,37 @@ _mesa_BindVertexArrayAPPLE( GLuint id )
/* Pass BindVertexArray call to device driver */
if (ctx->Driver.BindArrayObject && newObj)
- (*ctx->Driver.BindArrayObject)( ctx, newObj );
+ ctx->Driver.BindArrayObject(ctx, newObj);
+}
+
+
+/**
+ * ARB version of glBindVertexArray()
+ * This function behaves differently from glBindVertexArrayAPPLE() in
+ * that this function requires all ids to have been previously generated
+ * by glGenVertexArrays[APPLE]().
+ */
+void GLAPIENTRY
+_mesa_BindVertexArray( GLuint id )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ bind_vertex_array(ctx, id, GL_TRUE);
+}
+
+
+/**
+ * Bind a new array.
+ *
+ * \todo
+ * The binding could be done more efficiently by comparing the non-NULL
+ * pointers in the old and new objects. The only arrays that are "dirty" are
+ * the ones that are non-NULL in either object.
+ */
+void GLAPIENTRY
+_mesa_BindVertexArrayAPPLE( GLuint id )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ bind_vertex_array(ctx, id, GL_FALSE);
}
@@ -425,8 +457,6 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
return;
}
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
-
for (i = 0; i < n; i++) {
struct gl_array_object *obj = lookup_arrayobj(ctx, ids[i]);
@@ -450,21 +480,19 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
_mesa_reference_array_object(ctx, &obj, NULL);
}
}
-
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
}
/**
* Generate a set of unique array object IDs and store them in \c arrays.
- *
+ * Helper for _mesa_GenVertexArrays[APPLE]() functions below.
* \param n Number of IDs to generate.
* \param arrays Array of \c n locations to store the IDs.
+ * \param vboOnly Will arrays have to reside in VBOs?
*/
-void GLAPIENTRY
-_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
+static void
+gen_vertex_arrays(GLcontext *ctx, GLsizei n, GLuint *arrays, GLboolean vboOnly)
{
- GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -478,12 +506,7 @@ _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
return;
}
- /*
- * This must be atomic (generation and allocation of array object IDs)
- */
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
-
- first = _mesa_HashFindFreeKeyBlock(ctx->Shared->ArrayObjects, n);
+ first = _mesa_HashFindFreeKeyBlock(ctx->Array.Objects, n);
/* Allocate new, empty array objects and return identifiers */
for (i = 0; i < n; i++) {
@@ -492,15 +515,37 @@ _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
obj = (*ctx->Driver.NewArrayObject)( ctx, name );
if (!obj) {
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE");
return;
}
+ obj->VBOonly = vboOnly;
save_array_object(ctx, obj);
arrays[i] = first + i;
}
+}
+
+
+/**
+ * ARB version of glGenVertexArrays()
+ * All arrays will be required to live in VBOs.
+ */
+void GLAPIENTRY
+_mesa_GenVertexArrays(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gen_vertex_arrays(ctx, n, arrays, GL_TRUE);
+}
+
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+/**
+ * APPLE version of glGenVertexArraysAPPLE()
+ * Arrays may live in VBOs or ordinary memory.
+ */
+void GLAPIENTRY
+_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gen_vertex_arrays(ctx, n, arrays, GL_FALSE);
}
@@ -521,9 +566,7 @@ _mesa_IsVertexArrayAPPLE( GLuint id )
if (id == 0)
return GL_FALSE;
- _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
obj = lookup_arrayobj(ctx, id);
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
return (obj != NULL) ? GL_TRUE : GL_FALSE;
}
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index abca5ab9b4c..8999edc724f 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -67,10 +67,15 @@ _mesa_update_array_object_max_element(GLcontext *ctx,
* API functions
*/
+
+void GLAPIENTRY _mesa_BindVertexArray( GLuint id );
+
void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id );
void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids);
+void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays);
+
void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer);
GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id );
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a0681c84149..415e339cb80 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1011,6 +1011,7 @@ _mesa_free_context_data( GLcontext *ctx )
#if FEATURE_ARB_occlusion_query
_mesa_free_query_data(ctx);
#endif
+ _mesa_free_varray_data(ctx);
_mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 87ff67dd112..7c62328fa95 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -1799,6 +1799,7 @@ LONGSTRING static const char enum_string_table[] =
"GL_VENDOR\0"
"GL_VERSION\0"
"GL_VERTEX_ARRAY\0"
+ "GL_VERTEX_ARRAY_BINDING\0"
"GL_VERTEX_ARRAY_BINDING_APPLE\0"
"GL_VERTEX_ARRAY_BUFFER_BINDING\0"
"GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0"
@@ -1870,7 +1871,7 @@ LONGSTRING static const char enum_string_table[] =
"GL_ZOOM_Y\0"
;
-static const enum_elt all_enums[1832] =
+static const enum_elt all_enums[1833] =
{
{ 0, 0x00000600 }, /* GL_2D */
{ 6, 0x00001407 }, /* GL_2_BYTES */
@@ -3635,75 +3636,76 @@ static const enum_elt all_enums[1832] =
{ 37885, 0x00001F00 }, /* GL_VENDOR */
{ 37895, 0x00001F02 }, /* GL_VERSION */
{ 37906, 0x00008074 }, /* GL_VERTEX_ARRAY */
- { 37922, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
- { 37952, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
- { 37983, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
- { 38018, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
- { 38042, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
- { 38063, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
- { 38086, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
- { 38107, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
- { 38134, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
- { 38162, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
- { 38190, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
- { 38218, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
- { 38246, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
- { 38274, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
- { 38302, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
- { 38329, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
- { 38356, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
- { 38383, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
- { 38410, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
- { 38437, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
- { 38464, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
- { 38491, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
- { 38518, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
- { 38545, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
- { 38583, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
- { 38625, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
- { 38656, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
- { 38691, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
- { 38725, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
- { 38763, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
- { 38794, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
- { 38829, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
- { 38857, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
- { 38889, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
- { 38919, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
- { 38953, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
- { 38981, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
- { 39013, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
- { 39033, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
- { 39055, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
- { 39084, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
- { 39105, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
- { 39134, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
- { 39167, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
- { 39199, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
- { 39226, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
- { 39257, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
- { 39287, 0x00008B31 }, /* GL_VERTEX_SHADER */
- { 39304, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
- { 39325, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
- { 39352, 0x00000BA2 }, /* GL_VIEWPORT */
- { 39364, 0x00000800 }, /* GL_VIEWPORT_BIT */
- { 39380, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
- { 39400, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
- { 39431, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
- { 39466, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
- { 39494, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
- { 39519, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
- { 39546, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
- { 39571, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
- { 39595, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
- { 39614, 0x000088B9 }, /* GL_WRITE_ONLY */
- { 39628, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
- { 39646, 0x00001506 }, /* GL_XOR */
- { 39653, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
- { 39672, 0x00008757 }, /* GL_YCBCR_MESA */
- { 39686, 0x00000000 }, /* GL_ZERO */
- { 39694, 0x00000D16 }, /* GL_ZOOM_X */
- { 39704, 0x00000D17 }, /* GL_ZOOM_Y */
+ { 37922, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */
+ { 37946, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+ { 37976, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+ { 38007, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
+ { 38042, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
+ { 38066, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
+ { 38087, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
+ { 38110, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
+ { 38131, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+ { 38158, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+ { 38186, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+ { 38214, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+ { 38242, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+ { 38270, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+ { 38298, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+ { 38326, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+ { 38353, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+ { 38380, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+ { 38407, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+ { 38434, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+ { 38461, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+ { 38488, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+ { 38515, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+ { 38542, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+ { 38569, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+ { 38607, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
+ { 38649, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+ { 38680, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+ { 38715, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+ { 38749, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+ { 38787, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+ { 38818, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+ { 38853, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+ { 38881, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+ { 38913, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+ { 38943, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+ { 38977, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+ { 39005, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+ { 39037, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
+ { 39057, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
+ { 39079, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
+ { 39108, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
+ { 39129, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+ { 39158, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+ { 39191, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+ { 39223, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+ { 39250, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+ { 39281, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+ { 39311, 0x00008B31 }, /* GL_VERTEX_SHADER */
+ { 39328, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
+ { 39349, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
+ { 39376, 0x00000BA2 }, /* GL_VIEWPORT */
+ { 39388, 0x00000800 }, /* GL_VIEWPORT_BIT */
+ { 39404, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
+ { 39424, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+ { 39455, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
+ { 39490, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+ { 39518, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+ { 39543, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+ { 39570, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+ { 39595, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
+ { 39619, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
+ { 39638, 0x000088B9 }, /* GL_WRITE_ONLY */
+ { 39652, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
+ { 39670, 0x00001506 }, /* GL_XOR */
+ { 39677, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
+ { 39696, 0x00008757 }, /* GL_YCBCR_MESA */
+ { 39710, 0x00000000 }, /* GL_ZERO */
+ { 39718, 0x00000D16 }, /* GL_ZOOM_X */
+ { 39728, 0x00000D17 }, /* GL_ZOOM_Y */
};
static const unsigned reduced_enums[1325] =
@@ -3848,7 +3850,7 @@ static const unsigned reduced_enums[1325] =
1504, /* GL_STENCIL_WRITEMASK */
839, /* GL_MATRIX_MODE */
1007, /* GL_NORMALIZE */
- 1813, /* GL_VIEWPORT */
+ 1814, /* GL_VIEWPORT */
981, /* GL_MODELVIEW_STACK_DEPTH */
1244, /* GL_PROJECTION_STACK_DEPTH */
1699, /* GL_TEXTURE_STACK_DEPTH */
@@ -3928,8 +3930,8 @@ static const unsigned reduced_enums[1325] =
628, /* GL_INDEX_OFFSET */
1291, /* GL_RED_SCALE */
1289, /* GL_RED_BIAS */
- 1830, /* GL_ZOOM_X */
- 1831, /* GL_ZOOM_Y */
+ 1831, /* GL_ZOOM_X */
+ 1832, /* GL_ZOOM_Y */
590, /* GL_GREEN_SCALE */
588, /* GL_GREEN_BIAS */
92, /* GL_BLUE_SCALE */
@@ -4030,7 +4032,7 @@ static const unsigned reduced_enums[1325] =
295, /* GL_COPY */
50, /* GL_AND_INVERTED */
1005, /* GL_NOOP */
- 1826, /* GL_XOR */
+ 1827, /* GL_XOR */
1067, /* GL_OR */
1006, /* GL_NOR */
462, /* GL_EQUIV */
@@ -4255,9 +4257,9 @@ static const unsigned reduced_enums[1325] =
618, /* GL_INDEX_ARRAY */
1634, /* GL_TEXTURE_COORD_ARRAY */
451, /* GL_EDGE_FLAG_ARRAY */
- 1767, /* GL_VERTEX_ARRAY_SIZE */
- 1769, /* GL_VERTEX_ARRAY_TYPE */
- 1768, /* GL_VERTEX_ARRAY_STRIDE */
+ 1768, /* GL_VERTEX_ARRAY_SIZE */
+ 1770, /* GL_VERTEX_ARRAY_TYPE */
+ 1769, /* GL_VERTEX_ARRAY_STRIDE */
1013, /* GL_NORMAL_ARRAY_TYPE */
1012, /* GL_NORMAL_ARRAY_STRIDE */
149, /* GL_COLOR_ARRAY_SIZE */
@@ -4269,7 +4271,7 @@ static const unsigned reduced_enums[1325] =
1640, /* GL_TEXTURE_COORD_ARRAY_TYPE */
1639, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
455, /* GL_EDGE_FLAG_ARRAY_STRIDE */
- 1766, /* GL_VERTEX_ARRAY_POINTER */
+ 1767, /* GL_VERTEX_ARRAY_POINTER */
1011, /* GL_NORMAL_ARRAY_POINTER */
148, /* GL_COLOR_ARRAY_POINTER */
621, /* GL_INDEX_ARRAY_POINTER */
@@ -4369,7 +4371,7 @@ static const unsigned reduced_enums[1325] =
302, /* GL_CULL_VERTEX_EXT */
304, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
303, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
- 1823, /* GL_WRAP_BORDER_SUN */
+ 1824, /* GL_WRAP_BORDER_SUN */
1618, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
676, /* GL_LIGHT_MODEL_COLOR_CONTROL */
1415, /* GL_SINGLE_COLOR */
@@ -4535,19 +4537,19 @@ static const unsigned reduced_enums[1325] =
1053, /* GL_OPERAND1_ALPHA */
1059, /* GL_OPERAND2_ALPHA */
1065, /* GL_OPERAND3_ALPHA_NV */
- 1763, /* GL_VERTEX_ARRAY_BINDING_APPLE */
- 1827, /* GL_YCBCR_422_APPLE */
+ 1763, /* GL_VERTEX_ARRAY_BINDING */
+ 1828, /* GL_YCBCR_422_APPLE */
1752, /* GL_UNSIGNED_SHORT_8_8_APPLE */
1754, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
1417, /* GL_SLICE_ACCUM_SUN */
1267, /* GL_QUAD_MESH_SUN */
1723, /* GL_TRIANGLE_MESH_SUN */
- 1801, /* GL_VERTEX_PROGRAM_ARB */
- 1812, /* GL_VERTEX_STATE_PROGRAM_NV */
- 1788, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
- 1794, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
- 1796, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
- 1798, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+ 1802, /* GL_VERTEX_PROGRAM_ARB */
+ 1813, /* GL_VERTEX_STATE_PROGRAM_NV */
+ 1789, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+ 1795, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+ 1797, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+ 1799, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
330, /* GL_CURRENT_VERTEX_ATTRIB */
1221, /* GL_PROGRAM_LENGTH_ARB */
1235, /* GL_PROGRAM_STRING_ARB */
@@ -4568,33 +4570,33 @@ static const unsigned reduced_enums[1325] =
831, /* GL_MATRIX7_NV */
314, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
311, /* GL_CURRENT_MATRIX_ARB */
- 1804, /* GL_VERTEX_PROGRAM_POINT_SIZE */
- 1807, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+ 1805, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+ 1808, /* GL_VERTEX_PROGRAM_TWO_SIDE */
1233, /* GL_PROGRAM_PARAMETER_NV */
- 1792, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+ 1793, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
1237, /* GL_PROGRAM_TARGET_NV */
1234, /* GL_PROGRAM_RESIDENT_NV */
1708, /* GL_TRACK_MATRIX_NV */
1709, /* GL_TRACK_MATRIX_TRANSFORM_NV */
- 1802, /* GL_VERTEX_PROGRAM_BINDING_NV */
+ 1803, /* GL_VERTEX_PROGRAM_BINDING_NV */
1215, /* GL_PROGRAM_ERROR_POSITION_ARB */
351, /* GL_DEPTH_CLAMP_NV */
- 1770, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
- 1777, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
- 1778, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
- 1779, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
- 1780, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
- 1781, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
- 1782, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
- 1783, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
- 1784, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
- 1785, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
- 1771, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
- 1772, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
- 1773, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
- 1774, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
- 1775, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
- 1776, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+ 1771, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+ 1778, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+ 1779, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+ 1780, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+ 1781, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+ 1782, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+ 1783, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+ 1784, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+ 1785, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+ 1786, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+ 1772, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+ 1773, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+ 1774, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+ 1775, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+ 1776, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+ 1777, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
743, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
750, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
751, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
@@ -4633,14 +4635,14 @@ static const unsigned reduced_enums[1325] =
266, /* GL_COMPRESSED_TEXTURE_FORMATS */
928, /* GL_MAX_VERTEX_UNITS_ARB */
22, /* GL_ACTIVE_VERTEX_UNITS_ARB */
- 1822, /* GL_WEIGHT_SUM_UNITY_ARB */
- 1800, /* GL_VERTEX_BLEND_ARB */
+ 1823, /* GL_WEIGHT_SUM_UNITY_ARB */
+ 1801, /* GL_VERTEX_BLEND_ARB */
332, /* GL_CURRENT_WEIGHT_ARB */
- 1821, /* GL_WEIGHT_ARRAY_TYPE_ARB */
- 1820, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
- 1819, /* GL_WEIGHT_ARRAY_SIZE_ARB */
- 1818, /* GL_WEIGHT_ARRAY_POINTER_ARB */
- 1815, /* GL_WEIGHT_ARRAY_ARB */
+ 1822, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+ 1821, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+ 1820, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+ 1819, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+ 1816, /* GL_WEIGHT_ARRAY_ARB */
379, /* GL_DOT3_RGB */
380, /* GL_DOT3_RGBA */
260, /* GL_COMPRESSED_RGB_FXT1_3DFX */
@@ -4685,7 +4687,7 @@ static const unsigned reduced_enums[1325] =
983, /* GL_MODULATE_ADD_ATI */
984, /* GL_MODULATE_SIGNED_ADD_ATI */
985, /* GL_MODULATE_SUBTRACT_ATI */
- 1828, /* GL_YCBCR_MESA */
+ 1829, /* GL_YCBCR_MESA */
1074, /* GL_PACK_INVERT_MESA */
335, /* GL_DEBUG_OBJECT_MESA */
336, /* GL_DEBUG_PRINT_MESA */
@@ -4758,7 +4760,7 @@ static const unsigned reduced_enums[1325] =
1271, /* GL_QUERY_RESULT */
1273, /* GL_QUERY_RESULT_AVAILABLE */
922, /* GL_MAX_VERTEX_ATTRIBS */
- 1790, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+ 1791, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
370, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
369, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
908, /* GL_MAX_TEXTURE_COORDS */
@@ -4773,7 +4775,7 @@ static const unsigned reduced_enums[1325] =
456, /* GL_ELEMENT_ARRAY_BUFFER */
53, /* GL_ARRAY_BUFFER_BINDING */
457, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
- 1764, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+ 1765, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
1009, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
146, /* GL_COLOR_ARRAY_BUFFER_BINDING */
619, /* GL_INDEX_ARRAY_BUFFER_BINDING */
@@ -4781,8 +4783,8 @@ static const unsigned reduced_enums[1325] =
452, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
1392, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
505, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
- 1816, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
- 1786, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+ 1817, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+ 1787, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
1220, /* GL_PROGRAM_INSTRUCTIONS_ARB */
883, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
1226, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
@@ -4808,7 +4810,7 @@ static const unsigned reduced_enums[1325] =
1241, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
1713, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
1282, /* GL_READ_ONLY */
- 1824, /* GL_WRITE_ONLY */
+ 1825, /* GL_WRITE_ONLY */
1284, /* GL_READ_WRITE */
101, /* GL_BUFFER_ACCESS */
103, /* GL_BUFFER_MAPPED */
@@ -4872,7 +4874,7 @@ static const unsigned reduced_enums[1325] =
943, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
1373, /* GL_SAMPLES_PASSED */
528, /* GL_FRAGMENT_SHADER */
- 1810, /* GL_VERTEX_SHADER */
+ 1811, /* GL_VERTEX_SHADER */
1231, /* GL_PROGRAM_OBJECT_ARB */
1405, /* GL_SHADER_OBJECT_ARB */
867, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 96552599a80..c60b58a4926 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -78,6 +78,7 @@ static const struct {
{ OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
{ OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
{ ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
+ { OFF, "GL_ARB_vertex_array_object", F(ARB_vertex_array_object) },
{ ON, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
{ OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
{ OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
@@ -227,6 +228,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
/*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
+ ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
#if FEATURE_ARB_vertex_program
ctx->Extensions.ARB_vertex_program = GL_TRUE;
#endif
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 408b65d308e..e52278a7b25 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1563,6 +1563,7 @@ struct gl_array_object
GLint RefCount;
_glthread_Mutex Mutex;
+ GLboolean VBOonly; /**< require all arrays to live in VBOs? */
/** Conventional vertex arrays */
/*@{*/
@@ -1608,6 +1609,9 @@ struct gl_array_attrib
/** The default vertex array object */
struct gl_array_object *DefaultArrayObj;
+ /** Array objects (GL_ARB/APPLE_vertex_array_object) */
+ struct _mesa_HashTable *Objects;
+
GLint ActiveTexture; /**< Client Active Texture */
GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
@@ -2120,9 +2124,6 @@ struct gl_shared_state
struct _mesa_HashTable *FrameBuffers;
#endif
- /** Objects associated with the GL_APPLE_vertex_array_object extension. */
- struct _mesa_HashTable *ArrayObjects;
-
void *DriverData; /**< Device driver shared state */
};
@@ -2468,6 +2469,7 @@ struct gl_extensions
GLboolean ARB_texture_mirrored_repeat;
GLboolean ARB_texture_non_power_of_two;
GLboolean ARB_transpose_matrix;
+ GLboolean ARB_vertex_array_object;
GLboolean ARB_vertex_buffer_object;
GLboolean ARB_vertex_program;
GLboolean ARB_vertex_shader;
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 104f18f545a..ad6e6ce7cd3 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -100,8 +100,6 @@ _mesa_alloc_shared_state(GLcontext *ctx)
shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0, 0);
shared->NullBufferObj->RefCount = 1000 * 1000 * 1000;
- shared->ArrayObjects = _mesa_NewHashTable();
-
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
/* NOTE: the order of these enums matches the TEXTURE_x_INDEX values */
@@ -207,18 +205,6 @@ delete_bufferobj_cb(GLuint id, void *data, void *userData)
/**
- * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
- */
-static void
-delete_arrayobj_cb(GLuint id, void *data, void *userData)
-{
- struct gl_array_object *arrayObj = (struct gl_array_object *) data;
- GLcontext *ctx = (GLcontext *) userData;
- _mesa_delete_array_object(ctx, arrayObj);
-}
-
-
-/**
* Callback for freeing shader program data. Call it before delete_shader_cb
* to avoid memory access error.
*/
@@ -320,9 +306,6 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
_mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx);
_mesa_DeleteHashTable(shared->Programs);
- _mesa_HashDeleteAll(shared->ArrayObjects, delete_arrayobj_cb, ctx);
- _mesa_DeleteHashTable(shared->ArrayObjects);
-
#if FEATURE_ARB_vertex_program
_mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL);
#endif
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index f04c137c6d3..3d5b8faecff 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -30,6 +30,7 @@
#include "context.h"
#include "enable.h"
#include "enums.h"
+#include "hash.h"
#include "mtypes.h"
#include "varray.h"
#include "arrayobj.h"
@@ -38,6 +39,8 @@
/**
* Set the fields of a vertex array.
+ * Also do an error check for GL_ARB_vertex_array_object: check that
+ * all arrays reside in VBOs when using a vertex array object.
*
* \param array the array to update
* \param dirtyBit which bit to set in ctx->Array.NewState for this array
@@ -48,14 +51,26 @@
* \param stride stride between elements, in elements
* \param normalized are integer types converted to floats in [-1, 1]?
* \param ptr the address (or offset inside VBO) of the array data
+ * \return GL_TRUE if no error, GL_FALSE if error
*/
-static void
+static GLboolean
update_array(GLcontext *ctx, struct gl_client_array *array,
GLbitfield dirtyBit, GLsizei elementSize,
GLint size, GLenum type, GLenum format,
GLsizei stride, GLboolean normalized, const GLvoid *ptr)
{
ASSERT(format == GL_RGBA || format == GL_BGRA);
+
+ if (ctx->Array.ArrayObj->VBOonly &&
+ ctx->Array.ArrayBufferObj->Name == 0) {
+ /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs.
+ * Generate GL_INVALID_OPERATION if that's not true.
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertex/Normal/EtcPointer(non-VBO array)");
+ return GL_FALSE;
+ }
+
array->Size = size;
array->Type = type;
array->Format = format;
@@ -70,6 +85,8 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= dirtyBit;
+
+ return GL_TRUE;
}
@@ -122,8 +139,9 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
- elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX,
+ elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
+ return;
if (ctx->Driver.VertexPointer)
ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
@@ -172,8 +190,9 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
- elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL,
+ elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr))
+ return;
if (ctx->Driver.NormalPointer)
ctx->Driver.NormalPointer( ctx, type, stride, ptr );
@@ -250,8 +269,9 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
- elementSize, size, type, format, stride, GL_TRUE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0,
+ elementSize, size, type, format, stride, GL_TRUE, ptr))
+ return;
if (ctx->Driver.ColorPointer)
ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
@@ -282,8 +302,9 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
- elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD,
+ elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
+ return;
if (ctx->Driver.FogCoordPointer)
ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
@@ -323,8 +344,9 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
- elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX,
+ elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr))
+ return;
if (ctx->Driver.IndexPointer)
ctx->Driver.IndexPointer( ctx, type, stride, ptr );
@@ -397,8 +419,10 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1,
- elementSize, size, type, format, stride, GL_TRUE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor,
+ _NEW_ARRAY_COLOR1, elementSize, size, type,
+ format, stride, GL_TRUE, ptr))
+ return;
if (ctx->Driver.SecondaryColorPointer)
ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
@@ -456,9 +480,10 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
- _NEW_ARRAY_TEXCOORD(unit),
- elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit],
+ _NEW_ARRAY_TEXCOORD(unit),
+ elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr))
+ return;
if (ctx->Driver.TexCoordPointer)
ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
@@ -476,9 +501,10 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
- sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
- stride, GL_FALSE, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+ sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA,
+ stride, GL_FALSE, ptr))
+ return;
if (ctx->Driver.EdgeFlagPointer)
ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
@@ -588,9 +614,10 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
- _NEW_ARRAY_ATTRIB(index),
- elementSize, size, type, format, stride, normalized, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+ _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, format, stride, normalized, ptr))
+ return;
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
@@ -687,9 +714,10 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
return;
}
- update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
- _NEW_ARRAY_ATTRIB(index),
- elementSize, size, type, format, stride, normalized, ptr);
+ if (!update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
+ _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, format, stride, normalized, ptr))
+ return;
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
@@ -1120,4 +1148,29 @@ _mesa_init_varray(GLcontext *ctx)
_mesa_reference_array_object(ctx, &ctx->Array.ArrayObj,
ctx->Array.DefaultArrayObj);
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
+
+ ctx->Array.Objects = _mesa_NewHashTable();
+}
+
+
+/**
+ * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
+ */
+static void
+delete_arrayobj_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_array_object *arrayObj = (struct gl_array_object *) data;
+ GLcontext *ctx = (GLcontext *) userData;
+ _mesa_delete_array_object(ctx, arrayObj);
+}
+
+
+/**
+ * Free vertex array state for given context.
+ */
+void
+_mesa_free_varray_data(GLcontext *ctx)
+{
+ _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx);
+ _mesa_DeleteHashTable(ctx->Array.Objects);
}
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 46cc3ee3425..d4d505ae049 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -166,10 +166,14 @@ _mesa_print_arrays(GLcontext *ctx);
extern void
_mesa_init_varray( GLcontext * ctx );
+extern void
+_mesa_free_varray_data(GLcontext *ctx);
+
#else
/** No-op */
#define _mesa_init_varray( c ) ((void)0)
+#define _mesa_free_varray_data( c ) ((void)0)
#endif