[Mesa-dev] egl: Fix eglMakeCurrent behaviour when used with EGL_NO_SURFACE and EGL_NO_CONTEXT.

Submitted by Beren Minor on March 15, 2014, 9:20 p.m.

Details

Message ID 1394918412-847-1-git-send-email-beren.minor+git@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Beren Minor March 15, 2014, 9:20 p.m.
EGL 1.4 Specification says that
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) can be used to release the
current thread's ownership on the surfaces and context.

MESA's egl implementation was only accepting the parameters when the KHR_surfaceless_context
extension is supported.
---
 src/egl/main/eglapi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 950c447..a5def55 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -486,7 +486,12 @@  eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
 
    if (!context && ctx != EGL_NO_CONTEXT)
       RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
-   if (!draw_surf || !read_surf) {
+
+   /* surfaces may both be EGL_NO_SURFACE and context be EGL_NO_CONTEXT,
+      releasing the current thread's ownership on the resources
+      (EGL 1.4 Specification, Section 3.7.3) */
+   if ((draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || ctx != EGL_NO_CONTEXT) &&
+       (!draw_surf || !read_surf)) {
       /* surfaces may be NULL if surfaceless */
       if (!disp->Extensions.KHR_surfaceless_context)
          RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);

Comments

On Sun, Mar 16, 2014 at 5:20 AM, Beren Minor <beren.minor@gmail.com> wrote:
> EGL 1.4 Specification says that
> eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) can be used to release the
> current thread's ownership on the surfaces and context.
>
> MESA's egl implementation was only accepting the parameters when the KHR_surfaceless_context
> extension is supported.
> ---
>  src/egl/main/eglapi.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> index 950c447..a5def55 100644
> --- a/src/egl/main/eglapi.c
> +++ b/src/egl/main/eglapi.c
> @@ -486,7 +486,12 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
>
>     if (!context && ctx != EGL_NO_CONTEXT)
>        RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
> -   if (!draw_surf || !read_surf) {
> +
> +   /* surfaces may both be EGL_NO_SURFACE and context be EGL_NO_CONTEXT,
> +      releasing the current thread's ownership on the resources
> +      (EGL 1.4 Specification, Section 3.7.3) */
> +   if ((draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || ctx != EGL_NO_CONTEXT) &&
> +       (!draw_surf || !read_surf)) {
Intead of changing this if condition, ...
>        /* surfaces may be NULL if surfaceless */
>        if (!disp->Extensions.KHR_surfaceless_context)
isn't it enough to change this one to

  if (ctx && !disp->Extensions.KHR_surfaceless_context)

?
>           RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
> --
> 1.9.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
It's probably enough, indeed. (With "ctx != EGL_NO_CONTEXT &&" instead of
"ctx &&")

--
Beren Minor


On Mon, Mar 17, 2014 at 3:30 AM, Chia-I Wu <olvaffe@gmail.com> wrote:

> On Sun, Mar 16, 2014 at 5:20 AM, Beren Minor <beren.minor@gmail.com>
> wrote:
> > EGL 1.4 Specification says that
> > eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)
> can be used to release the
> > current thread's ownership on the surfaces and context.
> >
> > MESA's egl implementation was only accepting the parameters when the
> KHR_surfaceless_context
> > extension is supported.
> > ---
> >  src/egl/main/eglapi.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
> > index 950c447..a5def55 100644
> > --- a/src/egl/main/eglapi.c
> > +++ b/src/egl/main/eglapi.c
> > @@ -486,7 +486,12 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
> EGLSurface read,
> >
> >     if (!context && ctx != EGL_NO_CONTEXT)
> >        RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE);
> > -   if (!draw_surf || !read_surf) {
> > +
> > +   /* surfaces may both be EGL_NO_SURFACE and context be EGL_NO_CONTEXT,
> > +      releasing the current thread's ownership on the resources
> > +      (EGL 1.4 Specification, Section 3.7.3) */
> > +   if ((draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || ctx !=
> EGL_NO_CONTEXT) &&
> > +       (!draw_surf || !read_surf)) {
> Intead of changing this if condition, ...
> >        /* surfaces may be NULL if surfaceless */
> >        if (!disp->Extensions.KHR_surfaceless_context)
> isn't it enough to change this one to
>
>   if (ctx && !disp->Extensions.KHR_surfaceless_context)
>
> ?
> >           RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
> > --
> > 1.9.0
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
>
> --
> olv@LunarG.com
>