summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-06-19 17:58:47 -0600
committerBrian Paul <[email protected]>2009-06-19 18:11:52 -0600
commit12cf98f5fc5eaa4743134387ce3f8e584aa20bc4 (patch)
treee5cda3e5920ae3102319844fd594c2e60495dff4 /src/mesa
parentbda551898a09e4a07491dcf394bb2981dced0012 (diff)
mesa: move vertex array objects from shared state to per-context
The ARB version requires VAOs to be per-context while the Apple extension was ambiguous.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/arrayobj.c29
-rw-r--r--src/mesa/main/context.c1
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/shared.c17
-rw-r--r--src/mesa/main/varray.c26
-rw-r--r--src/mesa/main/varray.h4
6 files changed, 42 insertions, 41 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index c03353b78f5..e078f69ff95 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);
}
}
@@ -425,8 +426,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,8 +449,6 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
_mesa_reference_array_object(ctx, &obj, NULL);
}
}
-
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
}
@@ -478,12 +475,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 +484,12 @@ _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;
}
save_array_object(ctx, obj);
arrays[i] = first + i;
}
-
- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
}
@@ -521,9 +510,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/context.c b/src/mesa/main/context.c
index eafe292a1f2..7a9c69ac90b 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/mtypes.h b/src/mesa/main/mtypes.h
index 0c071ee19a0..69a23fe98ac 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1608,6 +1608,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 */
@@ -2119,9 +2122,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 */
};
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..3fbc730dc2a 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"
@@ -1120,4 +1121,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