summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shared.c
diff options
context:
space:
mode:
authorAndres Rodriguez <[email protected]>2017-07-12 18:45:07 -0400
committerTimothy Arceri <[email protected]>2017-08-06 12:42:06 +1000
commit8b7c5744791fe403375dd1d61c4a99b882044415 (patch)
treeec5728914a1f98d8d55c9919d304f479e225481e /src/mesa/main/shared.c
parent322ee1b3636a38c22bc65009f13667a9d5f438cf (diff)
mesa: add support for memory object creation/import/delete
Used by EXT_external_objects and EXT_external_objects_fd V2 (Timothy Arceri): - Throw GL_OUT_OF_MEMORY error if CreateMemoryObjectsEXT() fails. - C99 tidy ups - remove void cast (Constantine Kharlamov) V3 (Timothy Arceri): - rename mo -> memObj - check that the object is not NULL before initializing - add missing "EXT" in function error message V4 (Timothy Arceri): - remove checks for (memory objecy id == 0) and catch in _mesa_lookup_memory_object() instead. Signed-off-by: Andres Rodriguez <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/mesa/main/shared.c')
-rw-r--r--src/mesa/main/shared.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 6926d40570b..2cce47e2268 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -130,6 +130,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->SyncObjects = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ shared->MemoryObjects = _mesa_NewHashTable();
return shared;
}
@@ -295,6 +296,17 @@ delete_sampler_object_cb(GLuint id, void *data, void *userData)
_mesa_reference_sampler_object(ctx, &sampObj, NULL);
}
+/**
+ * Callback for deleting a memory object. Called by _mesa_HashDeleteAll().
+ */
+static void
+delete_memory_object_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_memory_object *memObj = (struct gl_memory_object *) data;
+ struct gl_context *ctx = (struct gl_context *) userData;
+ ctx->Driver.DeleteMemoryObject(ctx, memObj);
+}
+
/**
* Deallocate a shared state object and all children structures.
@@ -379,6 +391,11 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
_mesa_free_shared_handles(shared);
+ if (shared->MemoryObjects) {
+ _mesa_HashDeleteAll(shared->MemoryObjects, delete_memory_object_cb, ctx);
+ _mesa_DeleteHashTable(shared->MemoryObjects);
+ }
+
mtx_destroy(&shared->Mutex);
mtx_destroy(&shared->TexMutex);