mesa/st: move external objects to direct calls

This moves the memory and semaphore objects to direct calls

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14073>
This commit is contained in:
Dave Airlie 2021-12-06 17:15:25 +10:00 committed by Marge Bot
parent 830e2038fc
commit da24bb17a8
8 changed files with 71 additions and 146 deletions

View File

@ -59,6 +59,7 @@ struct gl_shader_program;
struct gl_texture_image;
struct gl_texture_object;
struct gl_memory_info;
struct gl_memory_object;
struct gl_query_object;
struct gl_sampler_object;
struct gl_transform_feedback_object;
@ -1018,23 +1019,6 @@ struct dd_function_table {
/*@}*/
/**
* \name GL_EXT_external_objects interface
*/
/*@{*/
/**
* Called to allocate a new memory object. Drivers will usually
* allocate/return a subclass of gl_memory_object.
*/
struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
GLuint name);
/**
* Called to delete/free a memory object. Drivers should free the
* object and any image data it contains.
*/
void (*DeleteMemoryObject)(struct gl_context *ctx,
struct gl_memory_object *memObj);
/**
* Set the given memory object as the texture's storage.
*/
@ -1073,23 +1057,6 @@ struct dd_function_table {
/*@}*/
/**
* \name GL_EXT_external_objects_fd interface
*/
/*@{*/
/**
* Called to import a memory object. The caller relinquishes ownership
* of fd after the call returns.
*
* Accessing fd after ImportMemoryObjectFd returns results in undefined
* behaviour. This is consistent with EXT_external_object_fd.
*/
void (*ImportMemoryObjectFd)(struct gl_context *ctx,
struct gl_memory_object *memObj,
GLuint64 size,
int fd);
/*@}*/
/**
* \name GL_ARB_get_program_binary
*/
@ -1108,64 +1075,6 @@ struct dd_function_table {
struct gl_program *prog);
/*@}*/
/**
* \name GL_EXT_semaphore interface
*/
/*@{*/
/**
* Called to allocate a new semaphore object. Drivers will usually
* allocate/return a subclass of gl_semaphore_object.
*/
struct gl_semaphore_object * (*NewSemaphoreObject)(struct gl_context *ctx,
GLuint name);
/**
* Called to delete/free a semaphore object. Drivers should free the
* object and any associated resources.
*/
void (*DeleteSemaphoreObject)(struct gl_context *ctx,
struct gl_semaphore_object *semObj);
/**
* Introduce an operation to wait for the semaphore object in the GL
* server's command stream
*/
void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
struct gl_buffer_object **bufObjs,
GLuint numTextureBarriers,
struct gl_texture_object **texObjs,
const GLenum *srcLayouts);
/**
* Introduce an operation to signal the semaphore object in the GL
* server's command stream
*/
void (*ServerSignalSemaphoreObject)(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
struct gl_buffer_object **bufObjs,
GLuint numTextureBarriers,
struct gl_texture_object **texObjs,
const GLenum *dstLayouts);
/*@}*/
/**
* \name GL_EXT_semaphore_fd interface
*/
/*@{*/
/**
* Called to import a semaphore object. The caller relinquishes ownership
* of fd after the call returns.
*
* Accessing fd after ImportSemaphoreFd returns results in undefined
* behaviour. This is consistent with EXT_semaphore_fd.
*/
void (*ImportSemaphoreFd)(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
int fd);
/*@}*/
/**
* \name Disk shader cache functions
*/

View File

@ -33,8 +33,10 @@
#include "texstorage.h"
#include "util/u_memory.h"
#include "state_tracker/st_cb_memoryobjects.h"
#include "state_tracker/st_cb_semaphoreobjects.h"
/**
* Delete a memory object. Called via ctx->Driver.DeleteMemory().
* Delete a memory object.
* Not removed from hash table here.
*/
void
@ -91,7 +93,7 @@ _mesa_DeleteMemoryObjectsEXT(GLsizei n, const GLuint *memoryObjects)
if (delObj) {
_mesa_HashRemoveLocked(ctx->Shared->MemoryObjects,
memoryObjects[i]);
ctx->Driver.DeleteMemoryObject(ctx, delObj);
st_memoryobj_free(ctx, delObj);
}
}
}
@ -144,7 +146,7 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects)
struct gl_memory_object *memObj;
/* allocate memory object */
memObj = ctx->Driver.NewMemoryObject(ctx, memoryObjects[i]);
memObj = st_memoryobj_alloc(ctx, memoryObjects[i]);
if (!memObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", func);
_mesa_HashUnlockMutex(ctx->Shared->MemoryObjects);
@ -557,7 +559,7 @@ _mesa_TextureStorageMem1DEXT(GLuint texture,
static struct gl_semaphore_object DummySemaphoreObject;
/**
* Delete a semaphore object. Called via ctx->Driver.DeleteSemaphore().
* Delete a semaphore object.
* Not removed from hash table here.
*/
void
@ -647,7 +649,7 @@ _mesa_DeleteSemaphoresEXT(GLsizei n, const GLuint *semaphores)
if (delObj) {
_mesa_HashRemoveLocked(ctx->Shared->SemaphoreObjects,
semaphores[i]);
ctx->Driver.DeleteSemaphoreObject(ctx, delObj);
st_semaphoreobj_free(ctx, delObj);
}
}
}
@ -758,10 +760,10 @@ _mesa_WaitSemaphoreEXT(GLuint semaphore,
texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
}
ctx->Driver.ServerWaitSemaphoreObject(ctx, semObj,
numBufferBarriers, bufObjs,
numTextureBarriers, texObjs,
srcLayouts);
st_server_wait_semaphore(ctx, semObj,
numBufferBarriers, bufObjs,
numTextureBarriers, texObjs,
srcLayouts);
end:
free(bufObjs);
@ -818,10 +820,10 @@ _mesa_SignalSemaphoreEXT(GLuint semaphore,
texObjs[i] = _mesa_lookup_texture(ctx, textures[i]);
}
ctx->Driver.ServerSignalSemaphoreObject(ctx, semObj,
numBufferBarriers, bufObjs,
numTextureBarriers, texObjs,
dstLayouts);
st_server_signal_semaphore(ctx, semObj,
numBufferBarriers, bufObjs,
numTextureBarriers, texObjs,
dstLayouts);
end:
free(bufObjs);
@ -852,7 +854,7 @@ _mesa_ImportMemoryFdEXT(GLuint memory,
if (!memObj)
return;
ctx->Driver.ImportMemoryObjectFd(ctx, memObj, size, fd);
st_import_memoryobj_fd(ctx, memObj, size, fd);
memObj->Immutable = GL_TRUE;
}
@ -881,7 +883,7 @@ _mesa_ImportSemaphoreFdEXT(GLuint semaphore,
return;
if (semObj == &DummySemaphoreObject) {
semObj = ctx->Driver.NewSemaphoreObject(ctx, semaphore);
semObj = st_semaphoreobj_alloc(ctx, semaphore);
if (!semObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
return;
@ -889,5 +891,5 @@ _mesa_ImportSemaphoreFdEXT(GLuint semaphore,
_mesa_HashInsert(ctx->Shared->SemaphoreObjects, semaphore, semObj, true);
}
ctx->Driver.ImportSemaphoreFd(ctx, semObj, fd);
st_import_semaphoreobj_fd(ctx, semObj, fd);
}

View File

@ -45,6 +45,9 @@
#include "util/set.h"
#include "util/u_memory.h"
#include "state_tracker/st_cb_memoryobjects.h"
#include "state_tracker/st_cb_semaphoreobjects.h"
static void
free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
@ -313,7 +316,7 @@ delete_memory_object_cb(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);
st_memoryobj_free(ctx, memObj);
}
/**
@ -324,7 +327,7 @@ delete_semaphore_object_cb(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);
st_semaphoreobj_free(ctx, semObj);
}
/**

View File

@ -39,7 +39,7 @@
#include "drm-uapi/drm_fourcc.h"
#endif
static struct gl_memory_object *
struct gl_memory_object *
st_memoryobj_alloc(struct gl_context *ctx, GLuint name)
{
struct st_memory_object *st_obj = ST_CALLOC_STRUCT(st_memory_object);
@ -50,7 +50,7 @@ st_memoryobj_alloc(struct gl_context *ctx, GLuint name)
return &st_obj->Base;
}
static void
void
st_memoryobj_free(struct gl_context *ctx,
struct gl_memory_object *obj)
{
@ -64,7 +64,7 @@ st_memoryobj_free(struct gl_context *ctx,
}
static void
void
st_import_memoryobj_fd(struct gl_context *ctx,
struct gl_memory_object *obj,
GLuint64 size,
@ -90,11 +90,3 @@ st_import_memoryobj_fd(struct gl_context *ctx,
close(fd);
#endif
}
void
st_init_memoryobject_functions(struct dd_function_table *functions)
{
functions->NewMemoryObject = st_memoryobj_alloc;
functions->DeleteMemoryObject = st_memoryobj_free;
functions->ImportMemoryObjectFd = st_import_memoryobj_fd;
}

View File

@ -27,7 +27,6 @@
#include "main/mtypes.h"
struct dd_function_table;
struct pipe_screen;
struct st_memory_object
@ -45,7 +44,15 @@ st_memory_object(struct gl_memory_object *obj)
return (struct st_memory_object *)obj;
}
extern void
st_init_memoryobject_functions(struct dd_function_table *functions);
struct gl_memory_object *
st_memoryobj_alloc(struct gl_context *ctx, GLuint name);
void
st_memoryobj_free(struct gl_context *ctx,
struct gl_memory_object *obj);
void
st_import_memoryobj_fd(struct gl_context *ctx,
struct gl_memory_object *obj,
GLuint64 size,
int fd);
#endif

View File

@ -38,7 +38,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
static struct gl_semaphore_object *
struct gl_semaphore_object *
st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
{
struct st_semaphore_object *st_obj = ST_CALLOC_STRUCT(st_semaphore_object);
@ -49,7 +49,7 @@ st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name)
return &st_obj->Base;
}
static void
void
st_semaphoreobj_free(struct gl_context *ctx,
struct gl_semaphore_object *semObj)
{
@ -57,10 +57,10 @@ st_semaphoreobj_free(struct gl_context *ctx,
}
static void
void
st_import_semaphoreobj_fd(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
int fd)
struct gl_semaphore_object *semObj,
int fd)
{
struct st_semaphore_object *st_obj = st_semaphore_object(semObj);
struct st_context *st = st_context(ctx);
@ -74,7 +74,7 @@ st_import_semaphoreobj_fd(struct gl_context *ctx,
#endif
}
static void
void
st_server_wait_semaphore(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
@ -123,7 +123,7 @@ st_server_wait_semaphore(struct gl_context *ctx,
}
}
static void
void
st_server_signal_semaphore(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
@ -161,12 +161,3 @@ st_server_signal_semaphore(struct gl_context *ctx,
pipe->fence_server_signal(pipe, st_obj->fence);
}
void
st_init_semaphoreobject_functions(struct dd_function_table *functions)
{
functions->NewSemaphoreObject = st_semaphoreobj_alloc;
functions->DeleteSemaphoreObject = st_semaphoreobj_free;
functions->ImportSemaphoreFd = st_import_semaphoreobj_fd;
functions->ServerWaitSemaphoreObject = st_server_wait_semaphore;
functions->ServerSignalSemaphoreObject = st_server_signal_semaphore;
}

View File

@ -42,7 +42,32 @@ st_semaphore_object(struct gl_semaphore_object *obj)
return (struct st_semaphore_object *)obj;
}
extern void
st_init_semaphoreobject_functions(struct dd_function_table *functions);
struct gl_semaphore_object *
st_semaphoreobj_alloc(struct gl_context *ctx, GLuint name);
void
st_semaphoreobj_free(struct gl_context *ctx,
struct gl_semaphore_object *semObj);
void
st_import_semaphoreobj_fd(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
int fd);
void
st_server_wait_semaphore(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
struct gl_buffer_object **bufObjs,
GLuint numTextureBarriers,
struct gl_texture_object **texObjs,
const GLenum *srcLayouts);
void
st_server_signal_semaphore(struct gl_context *ctx,
struct gl_semaphore_object *semObj,
GLuint numBufferBarriers,
struct gl_buffer_object **bufObjs,
GLuint numTextureBarriers,
struct gl_texture_object **texObjs,
const GLenum *dstLayouts);
#endif

View File

@ -55,14 +55,12 @@
#include "st_cb_eglimage.h"
#include "st_cb_fbo.h"
#include "st_cb_feedback.h"
#include "st_cb_memoryobjects.h"
#include "st_cb_msaa.h"
#include "st_cb_perfmon.h"
#include "st_cb_perfquery.h"
#include "st_cb_program.h"
#include "st_cb_queryobj.h"
#include "st_cb_readpixels.h"
#include "st_cb_semaphoreobjects.h"
#include "st_cb_texture.h"
#include "st_cb_flush.h"
#include "st_cb_viewport.h"
@ -953,13 +951,11 @@ st_init_driver_functions(struct pipe_screen *screen,
st_init_fbo_functions(functions);
st_init_feedback_functions(functions);
st_init_memoryobject_functions(functions);
st_init_msaa_functions(functions);
st_init_perfmon_functions(functions);
st_init_perfquery_functions(functions);
st_init_program_functions(functions);
st_init_readpixels_functions(functions);
st_init_semaphoreobject_functions(functions);
st_init_texture_functions(functions);
st_init_flush_functions(screen, functions);
st_init_viewport_functions(functions);