Re: [Mesa-dev] [PATCH 3/5] egl: implement EGL part of interop interface (v2)
On Wed, Apr 20, 2016 at 4:56 PM, Aaron Watry wrote: > Hi Marek, > > This patch ended up breaking make check for me (src/egl/egl-symbols-check). > > Also, while bisecting, it occurred to me that you pushed v2 of the series, > while you had previously sent a v3 to the mesa-dev list. Was pushing v2 > intentional? Yes, I had to go back, because some the changes in v3 had not been well received by certain individuals. :) Yeah, there are some new exported functions in libGL and libEGL. Marek ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/5] egl: implement EGL part of interop interface (v2)
Hi Marek, This patch ended up breaking make check for me (src/egl/egl-symbols-check). Also, while bisecting, it occurred to me that you pushed v2 of the series, while you had previously sent a v3 to the mesa-dev list. Was pushing v2 intentional? --Aaron On Tue, Mar 8, 2016 at 4:52 PM, Marek Olšák wrote: > From: Marek Olšák > > v2: - use const > --- > src/egl/drivers/dri2/egl_dri2.c | 32 ++ > src/egl/drivers/dri2/egl_dri2.h | 1 + > src/egl/main/eglapi.c | 72 > + > src/egl/main/eglapi.h | 9 ++ > 4 files changed, 114 insertions(+) > > diff --git a/src/egl/drivers/dri2/egl_dri2.c > b/src/egl/drivers/dri2/egl_dri2.c > index 8f50f0c..6e23b71 100644 > --- a/src/egl/drivers/dri2/egl_dri2.c > +++ b/src/egl/drivers/dri2/egl_dri2.c > @@ -44,6 +44,7 @@ > #endif > #include > #include > +#include "GL/mesa_glinterop.h" > #include > #include > > @@ -736,6 +737,8 @@ dri2_create_screen(_EGLDisplay *disp) >if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) { > dri2_dpy->rendererQuery = (__DRI2rendererQueryExtension *) > extensions[i]; >} > + if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0) > + dri2_dpy->interop = (__DRI2interopExtension *) extensions[i]; > } > > dri2_setup_screen(disp); > @@ -2512,6 +2515,33 @@ dri2_server_wait_sync(_EGLDriver *drv, _EGLDisplay > *dpy, _EGLSync *sync) > return EGL_TRUE; > } > > +static int > +dri2_interop_query_device_info(_EGLDisplay *dpy, _EGLContext *ctx, > + mesa_glinterop_device_info *out) > +{ > + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); > + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); > + > + if (!dri2_dpy->interop) > + return MESA_GLINTEROP_UNSUPPORTED; > + > + return dri2_dpy->interop->query_device_info(dri2_ctx->dri_context, > out); > +} > + > +static int > +dri2_interop_export_object(_EGLDisplay *dpy, _EGLContext *ctx, > + const mesa_glinterop_export_in *in, > + mesa_glinterop_export_out *out) > +{ > + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); > + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); > + > + if (!dri2_dpy->interop) > + return MESA_GLINTEROP_UNSUPPORTED; > + > + return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, > out); > +} > + > static void > dri2_unload(_EGLDriver *drv) > { > @@ -2622,6 +2652,8 @@ _eglBuiltInDriverDRI2(const char *args) > dri2_drv->base.API.ClientWaitSyncKHR = dri2_client_wait_sync; > dri2_drv->base.API.WaitSyncKHR = dri2_server_wait_sync; > dri2_drv->base.API.DestroySyncKHR = dri2_destroy_sync; > + dri2_drv->base.API.GLInteropQueryDeviceInfo = > dri2_interop_query_device_info; > + dri2_drv->base.API.GLInteropExportObject = dri2_interop_export_object; > > dri2_drv->base.Name = "DRI2"; > dri2_drv->base.Unload = dri2_unload; > diff --git a/src/egl/drivers/dri2/egl_dri2.h > b/src/egl/drivers/dri2/egl_dri2.h > index 52ad92b..d83bc1e 100644 > --- a/src/egl/drivers/dri2/egl_dri2.h > +++ b/src/egl/drivers/dri2/egl_dri2.h > @@ -174,6 +174,7 @@ struct dri2_egl_display > const __DRI2configQueryExtension *config; > const __DRI2fenceExtension *fence; > const __DRI2rendererQueryExtension *rendererQuery; > + const __DRI2interopExtension *interop; > int fd; > > int own_device; > diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c > index 32f6823..e229334 100644 > --- a/src/egl/main/eglapi.c > +++ b/src/egl/main/eglapi.c > @@ -88,6 +88,7 @@ > #include > #include "c99_compat.h" > #include "c11/threads.h" > +#include "GL/mesa_glinterop.h" > #include "eglcompiler.h" > > #include "eglglobals.h" > @@ -1905,3 +1906,74 @@ eglGetProcAddress(const char *procname) > > RETURN_EGL_SUCCESS(NULL, ret); > } > + > +static int > +_eglLockDisplayInterop(EGLDisplay dpy, EGLContext context, > + _EGLDisplay **disp, _EGLDriver **drv, > + _EGLContext **ctx) > +{ > + > + *disp = _eglLockDisplay(dpy); > + if (!*disp || !(*disp)->Initialized || !(*disp)->Driver) { > + if (*disp) > + _eglUnlockDisplay(*disp); > + return MESA_GLINTEROP_INVALID_DISPLAY; > + } > + > + *drv = (*disp)->Driver; > + > + *ctx = _eglLookupContext(context, *disp); > + if (!*ctx || > + ((*ctx)->ClientAPI != EGL_OPENGL_API && > +(*ctx)->ClientAPI != EGL_OPENGL_ES_API)) { > + _eglUnlockDisplay(*disp); > + return MESA_GLINTEROP_INVALID_CONTEXT; > + } > + > + return MESA_GLINTEROP_SUCCESS; > +} > + > +GLAPI int GLAPIENTRY > +MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context, > +mesa_glinterop_device_info *out) > +{ > + _EGLDisplay *disp; > + _EGLDriver *drv; > + _EGLContext *ctx; > + int ret; > + > + ret = _egl
[Mesa-dev] [PATCH 3/5] egl: implement EGL part of interop interface (v2)
From: Marek Olšák v2: - use const --- src/egl/drivers/dri2/egl_dri2.c | 32 ++ src/egl/drivers/dri2/egl_dri2.h | 1 + src/egl/main/eglapi.c | 72 + src/egl/main/eglapi.h | 9 ++ 4 files changed, 114 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 8f50f0c..6e23b71 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -44,6 +44,7 @@ #endif #include #include +#include "GL/mesa_glinterop.h" #include #include @@ -736,6 +737,8 @@ dri2_create_screen(_EGLDisplay *disp) if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) { dri2_dpy->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i]; } + if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0) + dri2_dpy->interop = (__DRI2interopExtension *) extensions[i]; } dri2_setup_screen(disp); @@ -2512,6 +2515,33 @@ dri2_server_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync) return EGL_TRUE; } +static int +dri2_interop_query_device_info(_EGLDisplay *dpy, _EGLContext *ctx, + mesa_glinterop_device_info *out) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + + if (!dri2_dpy->interop) + return MESA_GLINTEROP_UNSUPPORTED; + + return dri2_dpy->interop->query_device_info(dri2_ctx->dri_context, out); +} + +static int +dri2_interop_export_object(_EGLDisplay *dpy, _EGLContext *ctx, + const mesa_glinterop_export_in *in, + mesa_glinterop_export_out *out) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + + if (!dri2_dpy->interop) + return MESA_GLINTEROP_UNSUPPORTED; + + return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out); +} + static void dri2_unload(_EGLDriver *drv) { @@ -2622,6 +2652,8 @@ _eglBuiltInDriverDRI2(const char *args) dri2_drv->base.API.ClientWaitSyncKHR = dri2_client_wait_sync; dri2_drv->base.API.WaitSyncKHR = dri2_server_wait_sync; dri2_drv->base.API.DestroySyncKHR = dri2_destroy_sync; + dri2_drv->base.API.GLInteropQueryDeviceInfo = dri2_interop_query_device_info; + dri2_drv->base.API.GLInteropExportObject = dri2_interop_export_object; dri2_drv->base.Name = "DRI2"; dri2_drv->base.Unload = dri2_unload; diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index 52ad92b..d83bc1e 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -174,6 +174,7 @@ struct dri2_egl_display const __DRI2configQueryExtension *config; const __DRI2fenceExtension *fence; const __DRI2rendererQueryExtension *rendererQuery; + const __DRI2interopExtension *interop; int fd; int own_device; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 32f6823..e229334 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -88,6 +88,7 @@ #include #include "c99_compat.h" #include "c11/threads.h" +#include "GL/mesa_glinterop.h" #include "eglcompiler.h" #include "eglglobals.h" @@ -1905,3 +1906,74 @@ eglGetProcAddress(const char *procname) RETURN_EGL_SUCCESS(NULL, ret); } + +static int +_eglLockDisplayInterop(EGLDisplay dpy, EGLContext context, + _EGLDisplay **disp, _EGLDriver **drv, + _EGLContext **ctx) +{ + + *disp = _eglLockDisplay(dpy); + if (!*disp || !(*disp)->Initialized || !(*disp)->Driver) { + if (*disp) + _eglUnlockDisplay(*disp); + return MESA_GLINTEROP_INVALID_DISPLAY; + } + + *drv = (*disp)->Driver; + + *ctx = _eglLookupContext(context, *disp); + if (!*ctx || + ((*ctx)->ClientAPI != EGL_OPENGL_API && +(*ctx)->ClientAPI != EGL_OPENGL_ES_API)) { + _eglUnlockDisplay(*disp); + return MESA_GLINTEROP_INVALID_CONTEXT; + } + + return MESA_GLINTEROP_SUCCESS; +} + +GLAPI int GLAPIENTRY +MesaGLInteropEGLQueryDeviceInfo(EGLDisplay dpy, EGLContext context, +mesa_glinterop_device_info *out) +{ + _EGLDisplay *disp; + _EGLDriver *drv; + _EGLContext *ctx; + int ret; + + ret = _eglLockDisplayInterop(dpy, context, &disp, &drv, &ctx); + if (ret != MESA_GLINTEROP_SUCCESS) + return ret; + + if (drv->API.GLInteropQueryDeviceInfo) + ret = drv->API.GLInteropQueryDeviceInfo(disp, ctx, out); + else + ret = MESA_GLINTEROP_UNSUPPORTED; + + _eglUnlockDisplay(disp); + return ret; +} + +GLAPI int GLAPIENTRY +MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context, + const mesa_glinterop_export_in *in, + mesa_glinterop_export_out *out) +{ + _EGLDisplay *disp; + _EGLDriver *drv; +