From 89cd55e11dd030eeb7704e80d589da6570cba704 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 21 Oct 2022 14:09:39 -0700 Subject: [PATCH] egl/dri2: Implement the new flush method Reviewed-by: Adam Jackson Acked-by: Karol Herbst Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 15 +++++++++++++++ src/egl/egl-symbols.txt | 1 + src/egl/main/egl.def.in | 1 + src/egl/main/eglapi.c | 22 ++++++++++++++++++++++ src/egl/main/egldriver.h | 4 ++++ 5 files changed, 43 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index cba764b..0157665 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -3824,6 +3824,20 @@ dri2_interop_export_object(_EGLDisplay *disp, _EGLContext *ctx, return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out); } +static int +dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx, + unsigned count, struct mesa_glinterop_export_in *objects, + GLsync *sync) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + + if (!dri2_dpy->interop || dri2_dpy->interop->base.version < 2) + return MESA_GLINTEROP_UNSUPPORTED; + + return dri2_dpy->interop->flush_objects(dri2_ctx->dri_context, count, objects, sync); +} + const _EGLDriver _eglDriver = { .Initialize = dri2_initialize, .Terminate = dri2_terminate, @@ -3875,6 +3889,7 @@ const _EGLDriver _eglDriver = { .DestroySyncKHR = dri2_destroy_sync, .GLInteropQueryDeviceInfo = dri2_interop_query_device_info, .GLInteropExportObject = dri2_interop_export_object, + .GLInteropFlushObjects = dri2_interop_flush_objects, .DupNativeFenceFDANDROID = dri2_dup_native_fence_fd, .SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs, }; diff --git a/src/egl/egl-symbols.txt b/src/egl/egl-symbols.txt index 0b1929a..cf2c453 100644 --- a/src/egl/egl-symbols.txt +++ b/src/egl/egl-symbols.txt @@ -44,3 +44,4 @@ eglWaitNative eglWaitSync MesaGLInteropEGLQueryDeviceInfo MesaGLInteropEGLExportObject +MesaGLInteropEGLFlushObjects diff --git a/src/egl/main/egl.def.in b/src/egl/main/egl.def.in index b2439d9..1e6cf18 100644 --- a/src/egl/main/egl.def.in +++ b/src/egl/main/egl.def.in @@ -47,3 +47,4 @@ eglWaitSync@12 ; __cdecl calling convention have no @number suffix MesaGLInteropEGLQueryDeviceInfo MesaGLInteropEGLExportObject +MesaGLInteropEGLFlushObjects diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 93eca3d..15f6e2e 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -2968,3 +2968,25 @@ MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context, _eglUnlockDisplay(disp); return ret; } + +PUBLIC int +MesaGLInteropEGLFlushObjects(EGLDisplay dpy, EGLContext context, + unsigned count, struct mesa_glinterop_export_in *objects, + GLsync *sync) +{ + _EGLDisplay *disp; + _EGLContext *ctx; + int ret; + + ret = _eglLockDisplayInterop(dpy, context, &disp, &ctx); + if (ret != MESA_GLINTEROP_SUCCESS) + return ret; + + if (disp->Driver->GLInteropFlushObjects) + ret = disp->Driver->GLInteropFlushObjects(disp, ctx, count, objects, sync); + else + ret = MESA_GLINTEROP_UNSUPPORTED; + + _eglUnlockDisplay(disp); + return ret; +} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 242c0f8..da2281e 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -75,6 +75,7 @@ struct wl_display; struct mesa_glinterop_device_info; struct mesa_glinterop_export_in; struct mesa_glinterop_export_out; +typedef struct __GLsync *GLsync; /** * The API dispatcher jumps through these functions @@ -202,6 +203,9 @@ struct _egl_driver int (*GLInteropExportObject)(_EGLDisplay *disp, _EGLContext *ctx, struct mesa_glinterop_export_in *in, struct mesa_glinterop_export_out *out); + int (*GLInteropFlushObjects)(_EGLDisplay *disp, _EGLContext *ctx, + unsigned count, struct mesa_glinterop_export_in *in, + GLsync *sync); /* for EGL_EXT_image_dma_buf_import_modifiers */ EGLBoolean (*QueryDmaBufFormatsEXT)(_EGLDisplay *disp, -- 2.7.4