ui/egl: Add egl helpers to help with synchronization
These egl helpers would be used for creating and waiting on a sync object. Cc: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Message-Id: <20210914211837.3229977-3-vivek.kasireddy@intel.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
89faed62af
commit
121abaf3e6
|
@ -168,6 +168,8 @@ typedef struct QemuDmaBuf {
|
||||||
uint64_t modifier;
|
uint64_t modifier;
|
||||||
uint32_t texture;
|
uint32_t texture;
|
||||||
bool y0_top;
|
bool y0_top;
|
||||||
|
void *sync;
|
||||||
|
int fence_fd;
|
||||||
} QemuDmaBuf;
|
} QemuDmaBuf;
|
||||||
|
|
||||||
typedef struct DisplayState DisplayState;
|
typedef struct DisplayState DisplayState;
|
||||||
|
|
|
@ -45,6 +45,8 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
|
||||||
|
|
||||||
void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
|
void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
|
||||||
void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
|
void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
|
||||||
|
void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf);
|
||||||
|
void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,32 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf)
|
||||||
dmabuf->texture = 0;
|
dmabuf->texture = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf)
|
||||||
|
{
|
||||||
|
EGLSyncKHR sync;
|
||||||
|
|
||||||
|
if (epoxy_has_egl_extension(qemu_egl_display,
|
||||||
|
"EGL_KHR_fence_sync") &&
|
||||||
|
epoxy_has_egl_extension(qemu_egl_display,
|
||||||
|
"EGL_ANDROID_native_fence_sync")) {
|
||||||
|
sync = eglCreateSyncKHR(qemu_egl_display,
|
||||||
|
EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
|
||||||
|
if (sync != EGL_NO_SYNC_KHR) {
|
||||||
|
dmabuf->sync = sync;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf)
|
||||||
|
{
|
||||||
|
if (dmabuf->sync) {
|
||||||
|
dmabuf->fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display,
|
||||||
|
dmabuf->sync);
|
||||||
|
eglDestroySyncKHR(qemu_egl_display, dmabuf->sync);
|
||||||
|
dmabuf->sync = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_GBM */
|
#endif /* CONFIG_GBM */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue