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 <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22971>
This commit is contained in:
Asahi Lina 2023-05-03 20:32:23 +09:00 committed by Marge Bot
parent 86d41cb7bd
commit 69740fb82b
3 changed files with 33 additions and 0 deletions

View file

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

View file

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

View file

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