mesa/st: direct call sync object functions

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 16:58:22 +10:00 committed by Marge Bot
parent bd9adf3919
commit 8fe4ff2fda
5 changed files with 33 additions and 51 deletions

View file

@ -889,21 +889,6 @@ struct dd_function_table {
/**@}*/
/**
* \name GL_ARB_sync interfaces
*/
/*@{*/
struct gl_sync_object * (*NewSyncObject)(struct gl_context *);
void (*FenceSync)(struct gl_context *, struct gl_sync_object *,
GLenum, GLbitfield);
void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *);
void (*CheckSync)(struct gl_context *, struct gl_sync_object *);
void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *,
GLbitfield, GLuint64);
void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *,
GLbitfield, GLuint64);
/*@}*/
/**
* \name GL_OES_draw_texture interface
*/

View file

@ -68,6 +68,8 @@
#include "syncobj.h"
#include "state_tracker/st_cb_syncobj.h"
/**
* Allocate/init the context state related to sync objects.
*/
@ -134,7 +136,7 @@ _mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj,
_mesa_set_remove(ctx->Shared->SyncObjects, entry);
simple_mtx_unlock(&ctx->Shared->Mutex);
ctx->Driver.DeleteSyncObject(ctx, syncObj);
st_delete_sync_object(ctx, syncObj);
} else {
simple_mtx_unlock(&ctx->Shared->Mutex);
}
@ -204,7 +206,7 @@ fence_sync(struct gl_context *ctx, GLenum condition, GLbitfield flags)
{
struct gl_sync_object *syncObj;
syncObj = ctx->Driver.NewSyncObject(ctx);
syncObj = st_new_sync_object(ctx);
if (syncObj != NULL) {
/* The name is not currently used, and it is never visible to
* applications. If sync support is extended to provide support for
@ -218,7 +220,7 @@ fence_sync(struct gl_context *ctx, GLenum condition, GLbitfield flags)
syncObj->Flags = flags;
syncObj->StatusFlag = 0;
ctx->Driver.FenceSync(ctx, syncObj, condition, flags);
st_fence_sync(ctx, syncObj, condition, flags);
simple_mtx_lock(&ctx->Shared->Mutex);
_mesa_set_add(ctx->Shared->SyncObjects, syncObj);
@ -273,14 +275,14 @@ client_wait_sync(struct gl_context *ctx, struct gl_sync_object *syncObj,
* ClientWaitSync was called. ALREADY_SIGNALED will always be returned
* if <sync> was signaled, even if the value of <timeout> is zero.
*/
ctx->Driver.CheckSync(ctx, syncObj);
st_check_sync(ctx, syncObj);
if (syncObj->StatusFlag) {
ret = GL_ALREADY_SIGNALED;
} else {
if (timeout == 0) {
ret = GL_TIMEOUT_EXPIRED;
} else {
ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout);
st_client_wait_sync(ctx, syncObj, flags, timeout);
ret = syncObj->StatusFlag
? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED;
@ -330,7 +332,7 @@ static void
wait_sync(struct gl_context *ctx, struct gl_sync_object *syncObj,
GLbitfield flags, GLuint64 timeout)
{
ctx->Driver.ServerWaitSync(ctx, syncObj, flags, timeout);
st_server_wait_sync(ctx, syncObj, flags, timeout);
_mesa_unref_sync_object(ctx, syncObj, 1);
}
@ -405,7 +407,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length,
* this call won't block. It just updates state in the common object
* data from the current driver state.
*/
ctx->Driver.CheckSync(ctx, syncObj);
st_check_sync(ctx, syncObj);
v[0] = (syncObj->StatusFlag) ? GL_SIGNALED : GL_UNSIGNALED;
size = 1;

View file

@ -46,7 +46,7 @@ struct st_sync_object {
};
static struct gl_sync_object *st_new_sync_object(struct gl_context *ctx)
struct gl_sync_object *st_new_sync_object(struct gl_context *ctx)
{
struct st_sync_object *so = CALLOC_STRUCT(st_sync_object);
@ -54,8 +54,8 @@ static struct gl_sync_object *st_new_sync_object(struct gl_context *ctx)
return &so->b;
}
static void st_delete_sync_object(struct gl_context *ctx,
struct gl_sync_object *obj)
void st_delete_sync_object(struct gl_context *ctx,
struct gl_sync_object *obj)
{
struct pipe_screen *screen = st_context(ctx)->screen;
struct st_sync_object *so = (struct st_sync_object*)obj;
@ -66,8 +66,8 @@ static void st_delete_sync_object(struct gl_context *ctx,
free(so);
}
static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
GLenum condition, GLbitfield flags)
void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
GLenum condition, GLbitfield flags)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_sync_object *so = (struct st_sync_object*)obj;
@ -79,9 +79,9 @@ static void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
pipe->flush(pipe, &so->fence, ctx->Shared->RefCount == 1 ? PIPE_FLUSH_DEFERRED : 0);
}
static void st_client_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout)
void st_client_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct pipe_screen *screen = st_context(ctx)->screen;
@ -123,14 +123,14 @@ static void st_client_wait_sync(struct gl_context *ctx,
screen->fence_reference(screen, &fence, NULL);
}
static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj)
void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj)
{
st_client_wait_sync(ctx, obj, 0, 0);
}
static void st_server_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout)
void st_server_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct pipe_screen *screen = st_context(ctx)->screen;
@ -158,12 +158,3 @@ static void st_server_wait_sync(struct gl_context *ctx,
screen->fence_reference(screen, &fence, NULL);
}
void st_init_syncobj_functions(struct dd_function_table *functions)
{
functions->NewSyncObject = st_new_sync_object;
functions->FenceSync = st_fence_sync;
functions->DeleteSyncObject = st_delete_sync_object;
functions->CheckSync = st_check_sync;
functions->ClientWaitSync = st_client_wait_sync;
functions->ServerWaitSync = st_server_wait_sync;
}

View file

@ -28,11 +28,17 @@
#ifndef ST_CB_SYNCOBJ_H
#define ST_CB_SYNCOBJ_H
struct gl_sync_object *st_new_sync_object(struct gl_context *ctx);
void st_delete_sync_object(struct gl_context *ctx,
struct gl_sync_object *obj);
void st_fence_sync(struct gl_context *ctx, struct gl_sync_object *obj,
GLenum condition, GLbitfield flags);
void st_client_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout);
struct dd_function_table;
extern void
st_init_syncobj_functions(struct dd_function_table *functions);
void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj);
void st_server_wait_sync(struct gl_context *ctx,
struct gl_sync_object *obj,
GLbitfield flags, GLuint64 timeout);
#endif /* ST_CB_SYNCOBJ_H */

View file

@ -66,7 +66,6 @@
#include "st_cb_texture.h"
#include "st_cb_xformfb.h"
#include "st_cb_flush.h"
#include "st_cb_syncobj.h"
#include "st_cb_texturebarrier.h"
#include "st_cb_viewport.h"
#include "st_atom.h"
@ -970,7 +969,6 @@ st_init_driver_functions(struct pipe_screen *screen,
st_init_compute_functions(functions);
st_init_xformfb_functions(functions);
st_init_syncobj_functions(functions);
st_init_vdpau_functions(functions);