1
0
Fork 0

egl: Add helpers to manage and wait for EGLSync objects

This adds meta_egl_create_sync and meta_egl_destroy_sync to be able to
create and dispose EGLSync objects, respectively, as well as
meta_egl_wait_sync to be able to wait for an EGLSync on the GPU.

(cherry picked from commit d2e70c15ec1cf6b6f7cd8c8825a5d92a1f89b35b)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4015>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
This commit is contained in:
Gert-dev 2024-10-02 17:39:32 +02:00 committed by Mingi Sung
parent 74cf8ac0f0
commit 69cc9a7c0e
Signed by: sungmg
GPG key ID: 41BAFD6FFD8036C5
2 changed files with 89 additions and 0 deletions

View file

@ -44,6 +44,10 @@ struct _MetaEgl
PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
PFNEGLCREATESYNCPROC eglCreateSync;
PFNEGLDESTROYSYNCPROC eglDestroySync;
PFNEGLWAITSYNCPROC eglWaitSync;
PFNEGLBINDWAYLANDDISPLAYWL eglBindWaylandDisplayWL;
PFNEGLQUERYWAYLANDBUFFERWL eglQueryWaylandBufferWL;
@ -1162,6 +1166,69 @@ meta_egl_query_display_attrib (MetaEgl *egl,
return TRUE;
}
gboolean
meta_egl_create_sync (MetaEgl *egl,
EGLDisplay display,
EGLenum type,
const EGLAttrib *attrib_list,
EGLSync *egl_sync,
GError **error)
{
EGLSync sync;
if (!is_egl_proc_valid (egl->eglCreateSync, error))
return FALSE;
sync = egl->eglCreateSync (display, type, attrib_list);
if (sync == EGL_NO_SYNC)
{
set_egl_error (error);
return FALSE;
}
*egl_sync = sync;
return TRUE;
}
gboolean
meta_egl_destroy_sync (MetaEgl *egl,
EGLDisplay display,
EGLSync sync,
GError **error)
{
if (!is_egl_proc_valid (egl->eglDestroySync, error))
return FALSE;
if (!egl->eglDestroySync (display, sync))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
gboolean
meta_egl_wait_sync (MetaEgl *egl,
EGLDisplay display,
EGLSync sync,
EGLint flags,
GError **error)
{
if (!is_egl_proc_valid (egl->eglWaitSync, error))
return FALSE;
if (!egl->eglWaitSync (display, sync, flags))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
#define GET_EGL_PROC_ADDR(proc) \
egl->proc = (void *) eglGetProcAddress (#proc);
@ -1175,6 +1242,10 @@ meta_egl_constructed (GObject *object)
GET_EGL_PROC_ADDR (eglCreateImageKHR);
GET_EGL_PROC_ADDR (eglDestroyImageKHR);
GET_EGL_PROC_ADDR (eglCreateSync);
GET_EGL_PROC_ADDR (eglDestroySync);
GET_EGL_PROC_ADDR (eglWaitSync);
GET_EGL_PROC_ADDR (eglBindWaylandDisplayWL);
GET_EGL_PROC_ADDR (eglQueryWaylandBufferWL);

View file

@ -276,3 +276,21 @@ gboolean meta_egl_query_display_attrib (MetaEgl *egl,
EGLint attribute,
EGLAttrib *value,
GError **error);
gboolean meta_egl_create_sync (MetaEgl *egl,
EGLDisplay display,
EGLenum type,
const EGLAttrib *attrib_list,
EGLSync *egl_sync,
GError **error);
gboolean meta_egl_destroy_sync (MetaEgl *egl,
EGLDisplay display,
EGLSync sync,
GError **error);
gboolean meta_egl_wait_sync (MetaEgl *egl,
EGLDisplay display,
EGLSync sync,
EGLint flags,
GError **error);