* Shared-context state
*/
-#include "imports.h"
+
#include "mtypes.h"
#include "hash.h"
#include "atifragshader.h"
#include "util/hash_table.h"
#include "util/set.h"
+#include "util/u_memory.h"
static void
free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
if (!shared)
return NULL;
- mtx_init(&shared->Mutex, mtx_plain);
+ simple_mtx_init(&shared->Mutex, mtx_plain);
shared->DisplayList = _mesa_NewHashTable();
shared->BitmapAtlas = _mesa_NewHashTable();
/* GL_ARB_bindless_texture */
_mesa_init_shared_handles(shared);
- /* Allocate the default buffer object */
- shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
- if (!shared->NullBufferObj)
- goto fail;
+ /* ARB_shading_language_include */
+ _mesa_init_shader_includes(shared);
+ mtx_init(&shared->ShaderIncludeMutex, mtx_plain);
/* Create default texture objects */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
_mesa_key_pointer_equal);
shared->MemoryObjects = _mesa_NewHashTable();
- return shared;
+ shared->SemaphoreObjects = _mesa_NewHashTable();
-fail:
- free_shared_state(ctx, shared);
- return NULL;
+ return shared;
}
ctx->Driver.DeleteMemoryObject(ctx, memObj);
}
+/**
+ * Callback for deleting a memory object. Called by _mesa_HashDeleteAll().
+ */
+static void
+delete_semaphore_object_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_semaphore_object *semObj = (struct gl_semaphore_object *) data;
+ struct gl_context *ctx = (struct gl_context *) userData;
+ ctx->Driver.DeleteSemaphoreObject(ctx, semObj);
+}
/**
* Deallocate a shared state object and all children structures.
*
* \param ctx GL context.
* \param shared shared state pointer.
- *
+ *
* Frees the display lists, the texture objects (calling the driver texture
* deletion callback to free its private data) and the vertex programs, as well
* as their hash tables.
_mesa_DeleteHashTable(shared->RenderBuffers);
}
- if (shared->NullBufferObj)
- _mesa_reference_buffer_object(ctx, &shared->NullBufferObj, NULL);
-
if (shared->SyncObjects) {
- struct set_entry *entry;
set_foreach(shared->SyncObjects, entry) {
_mesa_unref_sync_object(ctx, (struct gl_sync_object *) entry->key, 1);
}
_mesa_free_shared_handles(shared);
+ /* ARB_shading_language_include */
+ _mesa_destroy_shader_includes(shared);
+ mtx_destroy(&shared->ShaderIncludeMutex);
+
if (shared->MemoryObjects) {
_mesa_HashDeleteAll(shared->MemoryObjects, delete_memory_object_cb, ctx);
_mesa_DeleteHashTable(shared->MemoryObjects);
}
- mtx_destroy(&shared->Mutex);
+ if (shared->SemaphoreObjects) {
+ _mesa_HashDeleteAll(shared->SemaphoreObjects, delete_semaphore_object_cb, ctx);
+ _mesa_DeleteHashTable(shared->SemaphoreObjects);
+ }
+
+ simple_mtx_destroy(&shared->Mutex);
mtx_destroy(&shared->TexMutex);
free(shared);
struct gl_shared_state *old = *ptr;
GLboolean delete;
- mtx_lock(&old->Mutex);
+ simple_mtx_lock(&old->Mutex);
assert(old->RefCount >= 1);
old->RefCount--;
delete = (old->RefCount == 0);
- mtx_unlock(&old->Mutex);
+ simple_mtx_unlock(&old->Mutex);
if (delete) {
free_shared_state(ctx, old);
if (state) {
/* reference new state */
- mtx_lock(&state->Mutex);
+ simple_mtx_lock(&state->Mutex);
state->RefCount++;
*ptr = state;
- mtx_unlock(&state->Mutex);
+ simple_mtx_unlock(&state->Mutex);
}
}