From 67d5d08682c4975a025182a7bf58a4768753e677 Mon Sep 17 00:00:00 2001 From: Andres Rodriguez Date: Fri, 6 Oct 2017 17:17:54 -0400 Subject: mesa: add support for semaphore object creation/import/delete v3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Used by EXT_semmaphore and EXT_semaphore_fd v2: Removed unnecessary dummy callback initialization v3: Fixed attempting to free the DummySemaphoreObject Signed-off-by: Andres Rodriguez Reviewed-by: Marek Olšák --- src/mesa/main/shared.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/mesa/main/shared.c') diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index e3417a4df30..b0338d78b05 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -136,6 +136,8 @@ _mesa_alloc_shared_state(struct gl_context *ctx) _mesa_key_pointer_equal); shared->MemoryObjects = _mesa_NewHashTable(); + shared->SemaphoreObjects = _mesa_NewHashTable(); + return shared; fail: @@ -316,6 +318,16 @@ delete_memory_object_cb(GLuint id, void *data, void *userData) 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. @@ -435,6 +447,11 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) _mesa_DeleteHashTable(shared->MemoryObjects); } + 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); -- cgit v1.2.3