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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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 */
|
||||
};
|
||||
|
||||
|
@@ -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 */
|
||||
@@ -206,18 +204,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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user