[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/6] ui/egl: Add egl helpers to help with synchronization
From: |
Gerd Hoffmann |
Subject: |
[PULL 2/6] ui/egl: Add egl helpers to help with synchronization |
Date: |
Fri, 10 Sep 2021 15:17:05 +0200 |
From: Vivek Kasireddy <vivek.kasireddy@intel.com>
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: <20210901211014.2800391-3-vivek.kasireddy@intel.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/ui/console.h | 2 ++
include/ui/egl-helpers.h | 2 ++
ui/egl-helpers.c | 26 ++++++++++++++++++++++++++
3 files changed, 30 insertions(+)
diff --git a/include/ui/console.h b/include/ui/console.h
index 3be21497a2e8..45ec1291743b 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -168,6 +168,8 @@ typedef struct QemuDmaBuf {
uint64_t modifier;
uint32_t texture;
bool y0_top;
+ void *sync;
+ int fence_fd;
} QemuDmaBuf;
typedef struct DisplayState DisplayState;
diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h
index f1bf8f97fc33..2c3ba92b53e1 100644
--- a/include/ui/egl-helpers.h
+++ b/include/ui/egl-helpers.h
@@ -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_release_texture(QemuDmaBuf *dmabuf);
+void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf);
+void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
#endif
diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 6d0cb2b5cb93..d8986b0a7f9c 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -76,6 +76,32 @@ void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
GL_TEXTURE_2D, fb->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;
+ }
+}
+
void egl_fb_setup_new_tex(egl_fb *fb, int width, int height)
{
GLuint texture;
--
2.31.1
- [PULL 0/6] Vga 20210910 patches, Gerd Hoffmann, 2021/09/10
- [PULL 2/6] ui/egl: Add egl helpers to help with synchronization,
Gerd Hoffmann <=
- [PULL 1/6] ui/gtk: Create a common release_dmabuf helper, Gerd Hoffmann, 2021/09/10
- [PULL 4/6] ui/gtk-egl: Wait for the draw signal for dmabuf blobs, Gerd Hoffmann, 2021/09/10
- [PULL 3/6] ui: Create sync objects and fences only for blobs, Gerd Hoffmann, 2021/09/10
- [PULL 5/6] virtio-gpu: Add gl_flushed callback, Gerd Hoffmann, 2021/09/10
- [PULL 6/6] qxl: fix pre-save logic, Gerd Hoffmann, 2021/09/10
- Re: [PULL 0/6] Vga 20210910 patches, Peter Maydell, 2021/09/10