From 69740fb82b4a4a23578703b691bc1f260a935316 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Wed, 3 May 2023 20:32:23 +0900 Subject: [PATCH] asahi: Implement create_fence_fd and fence_server_sync Apparently we were still missing some fence stuff, and it started crashing Firefox in apitrace? I'm not sure why we never noticed this before, but it's trivial enough. Cargo culted from Panfrost. Signed-off-by: Asahi Lina Part-of: --- src/gallium/drivers/asahi/agx_fence.c | 23 +++++++++++++++++++++++ src/gallium/drivers/asahi/agx_fence.h | 7 +++++++ src/gallium/drivers/asahi/agx_pipe.c | 3 +++ 3 files changed, 33 insertions(+) diff --git a/src/gallium/drivers/asahi/agx_fence.c b/src/gallium/drivers/asahi/agx_fence.c index 6cb16f6b8e7..d0ba3d93f9e 100644 --- a/src/gallium/drivers/asahi/agx_fence.c +++ b/src/gallium/drivers/asahi/agx_fence.c @@ -15,6 +15,7 @@ #include "agx_fence.h" #include "agx_state.h" +#include "util/libsync.h" #include "util/os_time.h" #include "util/u_inlines.h" @@ -136,3 +137,25 @@ agx_fence_create(struct agx_context *ctx) return f; } + +void +agx_create_fence_fd(struct pipe_context *pctx, + struct pipe_fence_handle **pfence, int fd, + enum pipe_fd_type type) +{ + *pfence = agx_fence_from_fd(agx_context(pctx), fd, type); +} + +void +agx_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *f) +{ + struct agx_device *dev = agx_device(pctx->screen); + struct agx_context *ctx = agx_context(pctx); + int fd = -1, ret; + + ret = drmSyncobjExportSyncFile(dev->fd, f->syncobj, &fd); + assert(!ret); + + sync_accumulate("asahi", &ctx->in_sync_fd, fd); + close(fd); +} diff --git a/src/gallium/drivers/asahi/agx_fence.h b/src/gallium/drivers/asahi/agx_fence.h index 4c94ccdc498..518b2b609a6 100644 --- a/src/gallium/drivers/asahi/agx_fence.h +++ b/src/gallium/drivers/asahi/agx_fence.h @@ -32,4 +32,11 @@ struct pipe_fence_handle *agx_fence_from_fd(struct agx_context *ctx, int fd, struct pipe_fence_handle *agx_fence_create(struct agx_context *ctx); +void agx_create_fence_fd(struct pipe_context *pctx, + struct pipe_fence_handle **pfence, int fd, + enum pipe_fd_type type); + +void agx_fence_server_sync(struct pipe_context *pctx, + struct pipe_fence_handle *f); + #endif diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 16f53ef8bac..eba84a477a2 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -1403,6 +1403,9 @@ agx_create_context(struct pipe_screen *screen, void *priv, unsigned flags) pctx->invalidate_resource = agx_invalidate_resource; pctx->memory_barrier = agx_memory_barrier; + pctx->create_fence_fd = agx_create_fence_fd; + pctx->fence_server_sync = agx_fence_server_sync; + agx_init_state_functions(pctx); agx_init_query_functions(pctx); agx_init_streamout_functions(pctx);