virgl: Add VIRGL_RENDERER_ASYNC_FENCE_CB flag

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 <lfrb@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com> (v1)
macos/master
Louis-Francis Ratté-Boulianne 3 years ago committed by Chia-I Wu
parent 23c4ef5aa3
commit 0ee70e92a5
  1. 4
      src/virglrenderer.c
  2. 7
      src/virglrenderer.h

@ -667,6 +667,8 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
if (flags & VIRGL_RENDERER_THREAD_SYNC) if (flags & VIRGL_RENDERER_THREAD_SYNC)
renderer_flags |= VREND_USE_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) if (flags & VIRGL_RENDERER_USE_EXTERNAL_BLOB)
renderer_flags |= VREND_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; uint32_t vkr_flags = 0;
if (flags & VIRGL_RENDERER_THREAD_SYNC) if (flags & VIRGL_RENDERER_THREAD_SYNC)
vkr_flags |= VKR_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); ret = vkr_renderer_init(vkr_flags);
if (ret) if (ret)

@ -98,6 +98,13 @@ struct virgl_renderer_callbacks {
*/ */
#define VIRGL_RENDERER_NO_VIRGL (1 << 7) #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 */ #endif /* VIRGL_RENDERER_UNSTABLE_APIS */
VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb); VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb);

Loading…
Cancel
Save