vrend: Use server side fence wait.

Change to use eglWaitSyncKHR which is a server side fence and it
could be sightly better.

Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
macos/master
Lepton Wu 5 years ago
parent e54bfe8961
commit 7fb8f44578
  1. 3
      src/virgl_egl.h
  2. 22
      src/virgl_egl_context.c
  3. 4
      src/vrend_renderer.c

@ -58,5 +58,6 @@ void *virgl_egl_aux_plane_image_from_dmabuf(struct virgl_egl *egl, struct gbm_bo
void virgl_egl_image_destroy(struct virgl_egl *egl, void *image);
bool virgl_egl_need_fence_and_wait_external(struct virgl_egl *egl);
void virgl_egl_fence_and_wait_external(struct virgl_egl *egl);
void *virgl_egl_fence(struct virgl_egl *egl);
void virgl_egl_wait_fence(struct virgl_egl *egl, void* fence);
#endif

@ -518,21 +518,25 @@ bool virgl_egl_need_fence_and_wait_external(struct virgl_egl *egl)
return (egl && egl->need_fence_and_wait_external);
}
void virgl_egl_fence_and_wait_external(struct virgl_egl *egl)
void *virgl_egl_fence(struct virgl_egl *egl)
{
const EGLint attrib_list[] = {EGL_SYNC_CONDITION_KHR,
EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR,
EGL_NONE};
EGLSyncKHR fence;
EGLSyncKHR fence = EGL_NO_SYNC_KHR;
if (!egl || !has_bit(egl->extension_bits, EGL_KHR_FENCE_SYNC)) {
return;
return (void *)fence;
}
fence = eglCreateSyncKHR(egl->egl_display, EGL_SYNC_FENCE_KHR, attrib_list);
if (fence != EGL_NO_SYNC_KHR) {
eglClientWaitSyncKHR(egl->egl_display, fence,
EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR);
eglDestroySyncKHR(egl->egl_display, fence);
}
return (void *)eglCreateSyncKHR(egl->egl_display, EGL_SYNC_FENCE_KHR, attrib_list);
}
void virgl_egl_wait_fence(struct virgl_egl *egl, void* sync)
{
EGLSyncKHR fence = (EGLSyncKHR) sync;
if (fence == EGL_NO_SYNC_KHR)
return;
eglWaitSyncKHR(egl->egl_display, fence, 0);
eglDestroySyncKHR(egl->egl_display, fence);
}

@ -7633,12 +7633,13 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
return EINVAL;
}
void* fence = NULL;
#ifdef HAVE_EPOXY_EGL_H
// Some platforms require extra synchronization before transferring.
if (transfer_mode == VIRGL_TRANSFER_FROM_HOST) {
if (virgl_egl_need_fence_and_wait_external(egl)) {
vrend_hw_switch_context(ctx, true);
virgl_egl_fence_and_wait_external(egl);
fence = virgl_egl_fence(egl);
}
}
#endif
@ -7675,6 +7676,7 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
if (info->context0) {
vrend_renderer_force_ctx_0();
virgl_egl_wait_fence(egl, fence);
ctx = NULL;
}

Loading…
Cancel
Save