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 <andresx7@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
Andres Rodriguez
2017-07-12 18:45:07 -04:00
committed by Timothy Arceri
parent 322ee1b363
commit 8b7c574479
6 changed files with 232 additions and 1 deletions

View File

@@ -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);