From 0ee70e92a51c910cd90be3db36c4858b5c7deaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Fri, 9 Jul 2021 01:17:22 -0400 Subject: [PATCH] virgl: Add VIRGL_RENDERER_ASYNC_FENCE_CB flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flag allows fence callback to be executed directly from the fence polling thread. It requires the `write_fence` callback provided by the user to be thread-safe. The `virgl_renderer_poll()` method no longer needs to be called by the user if that flag is used. v2: set VKR_RENDERER_ASYNC_FENCE_CB as well (by olv) Signed-off-by: Louis-Francis Ratté-Boulianne Reviewed-by: Chia-I Wu Reviewed-by: Ryan Neph (v1) --- src/virglrenderer.c | 4 ++++ src/virglrenderer.h | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index f05eb30..7250c1d 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -667,6 +667,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks if (flags & VIRGL_RENDERER_THREAD_SYNC) renderer_flags |= VREND_USE_THREAD_SYNC; + if (flags & VIRGL_RENDERER_ASYNC_FENCE_CB) + renderer_flags |= VREND_USE_ASYNC_FENCE_CB; if (flags & VIRGL_RENDERER_USE_EXTERNAL_BLOB) renderer_flags |= VREND_USE_EXTERNAL_BLOB; @@ -680,6 +682,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks uint32_t vkr_flags = 0; if (flags & VIRGL_RENDERER_THREAD_SYNC) vkr_flags |= VKR_RENDERER_THREAD_SYNC; + if (flags & VIRGL_RENDERER_ASYNC_FENCE_CB) + vkr_flags |= VKR_RENDERER_ASYNC_FENCE_CB; ret = vkr_renderer_init(vkr_flags); if (ret) diff --git a/src/virglrenderer.h b/src/virglrenderer.h index 2fe43aa..a1c06ff 100644 --- a/src/virglrenderer.h +++ b/src/virglrenderer.h @@ -98,6 +98,13 @@ struct virgl_renderer_callbacks { */ #define VIRGL_RENDERER_NO_VIRGL (1 << 7) +/* + * Used in conjonction with VIRGL_RENDERER_THREAD_SYNC; + * write_fence callback is executed directly from the polling thread. When enabled, + * virgl_renderer_get_poll_fd should not be used to watch for retired fences. + */ +#define VIRGL_RENDERER_ASYNC_FENCE_CB (1 << 8) + #endif /* VIRGL_RENDERER_UNSTABLE_APIS */ VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);