Skip to content

Commit 121abaf

Browse files
vivekkreddykraxel
authored andcommitted
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 <[email protected]> Reviewed-by: Gerd Hoffmann <[email protected]> Signed-off-by: Vivek Kasireddy <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent 89faed6 commit 121abaf

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

include/ui/console.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ typedef struct QemuDmaBuf {
168168
uint64_t modifier;
169169
uint32_t texture;
170170
bool y0_top;
171+
void *sync;
172+
int fence_fd;
171173
} QemuDmaBuf;
172174

173175
typedef struct DisplayState DisplayState;

include/ui/egl-helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
4545

4646
void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
4747
void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
48+
void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf);
49+
void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
4850

4951
#endif
5052

ui/egl-helpers.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,32 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf)
287287
dmabuf->texture = 0;
288288
}
289289

290+
void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf)
291+
{
292+
EGLSyncKHR sync;
293+
294+
if (epoxy_has_egl_extension(qemu_egl_display,
295+
"EGL_KHR_fence_sync") &&
296+
epoxy_has_egl_extension(qemu_egl_display,
297+
"EGL_ANDROID_native_fence_sync")) {
298+
sync = eglCreateSyncKHR(qemu_egl_display,
299+
EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
300+
if (sync != EGL_NO_SYNC_KHR) {
301+
dmabuf->sync = sync;
302+
}
303+
}
304+
}
305+
306+
void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf)
307+
{
308+
if (dmabuf->sync) {
309+
dmabuf->fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display,
310+
dmabuf->sync);
311+
eglDestroySyncKHR(qemu_egl_display, dmabuf->sync);
312+
dmabuf->sync = NULL;
313+
}
314+
}
315+
290316
#endif /* CONFIG_GBM */
291317

292318
/* ---------------------------------------------------------------------- */

0 commit comments

Comments
 (0)