egl: drop unused _EGLDriver & _EGLDisplay from _eglQueryContext()
[mesa.git] / src / egl / main / eglcontext.c
index ecc546e113222d89928ccb7c9526a1a9397ff91d..65dc886abbb0fc53ac95090cd6a358e6e97ddac4 100644 (file)
@@ -37,6 +37,7 @@
 #include "eglcurrent.h"
 #include "eglsurface.h"
 #include "egllog.h"
+#include "util/macros.h"
 
 
 /**
@@ -81,7 +82,7 @@ _eglGetContextAPIBit(_EGLContext *ctx)
  * Parse the list of context attributes and return the proper error code.
  */
 static EGLint
-_eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
+_eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *disp,
                            const EGLint *attrib_list)
 {
    EGLenum api = ctx->ClientAPI;
@@ -118,7 +119,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
           *      generate an error."
           */
          if ((api != EGL_OPENGL_ES_API &&
-             (!dpy->Extensions.KHR_create_context || api != EGL_OPENGL_API))) {
+             (!disp->Extensions.KHR_create_context || api != EGL_OPENGL_API))) {
                err = EGL_BAD_ATTRIBUTE;
                break;
          }
@@ -135,7 +136,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
           *      contexts, and specifying them for other types of contexts will
           *      generate an error."
           */
-         if (!dpy->Extensions.KHR_create_context ||
+         if (!disp->Extensions.KHR_create_context ||
              (api != EGL_OPENGL_ES_API && api != EGL_OPENGL_API)) {
             err = EGL_BAD_ATTRIBUTE;
             break;
@@ -145,7 +146,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_FLAGS_KHR:
-         if (!dpy->Extensions.KHR_create_context) {
+         if (!disp->Extensions.KHR_create_context) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -177,9 +178,12 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
           *     is supported for OpenGL contexts, and requesting a
           *     forward-compatible context for OpenGL versions less than 3.0
           *     will generate an error."
+          *
+          * Note: since the forward-compatible flag can be set more than one way,
+          *       the OpenGL version check is performed once, below.
           */
          if ((val & EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR) &&
-             (api != EGL_OPENGL_API || ctx->ClientMajorVersion < 3)) {
+              api != EGL_OPENGL_API) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -219,7 +223,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
-         if (!dpy->Extensions.KHR_create_context) {
+         if (!disp->Extensions.KHR_create_context) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -246,9 +250,17 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
           *     meaningful for OpenGL contexts, and specifying it for other
           *     types of contexts, including OpenGL ES contexts, will generate
           *     an error."
+          *
+          * EGL 1.5 defines EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
+          * (without a suffix) which has the same value as the KHR token,
+          * and specifies that it now works with both GL and ES contexts:
+          *
+          *    "This attribute is supported only for OpenGL and OpenGL ES
+          *     contexts."
           */
-           if (!dpy->Extensions.KHR_create_context
-               || api != EGL_OPENGL_API) {
+           if (!(disp->Extensions.KHR_create_context && api == EGL_OPENGL_API)
+               && !(disp->Version >= 15 && (api == EGL_OPENGL_API ||
+                                            api == EGL_OPENGL_ES_API))) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -263,7 +275,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
           *     meaningful for OpenGL ES contexts, and specifying it for other
           *     types of contexts will generate an EGL_BAD_ATTRIBUTE error."
           */
-         if (!dpy->Extensions.EXT_create_context_robustness
+         if (!disp->Extensions.EXT_create_context_robustness
              || api != EGL_OPENGL_ES_API) {
             err = EGL_BAD_ATTRIBUTE;
             break;
@@ -273,7 +285,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
-         if (!dpy->Extensions.EXT_create_context_robustness) {
+         if (!disp->Extensions.EXT_create_context_robustness) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -283,7 +295,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_ROBUST_ACCESS:
-         if (dpy->Version < 15) {
+         if (disp->Version < 15) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -293,7 +305,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_DEBUG:
-         if (dpy->Version < 15) {
+         if (disp->Version < 15) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -303,7 +315,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE:
-         if (dpy->Version < 15) {
+         if (disp->Version < 15) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -313,8 +325,8 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
          break;
 
       case EGL_CONTEXT_OPENGL_NO_ERROR_KHR:
-         if (dpy->Version < 14 ||
-             !dpy->Extensions.KHR_create_context_no_error) {
+         if (disp->Version < 14 ||
+             !disp->Extensions.KHR_create_context_no_error) {
             err = EGL_BAD_ATTRIBUTE;
             break;
          }
@@ -380,7 +392,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
              * the driver would fail, and ctx->ContextPriority matches the
              * hint applied to the driver/hardware backend.
              */
-            if (dpy->Extensions.IMG_context_priority & (1 << bit))
+            if (disp->Extensions.IMG_context_priority & (1 << bit))
                ctx->ContextPriority = val;
 
             break;
@@ -576,7 +588,7 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
  * responsible for determining whether that's an API it supports.
  */
 EGLBoolean
-_eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
+_eglInitContext(_EGLContext *ctx, _EGLDisplay *disp, _EGLConfig *conf,
                 const EGLint *attrib_list)
 {
    const EGLenum api = eglQueryAPI();
@@ -585,7 +597,7 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
    if (api == EGL_NONE)
       return _eglError(EGL_BAD_MATCH, "eglCreateContext(no client API)");
 
-   _eglInitResource(&ctx->Resource, sizeof(*ctx), dpy);
+   _eglInitResource(&ctx->Resource, sizeof(*ctx), disp);
    ctx->ClientAPI = api;
    ctx->Config = conf;
    ctx->Profile = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
@@ -597,7 +609,7 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
    ctx->ContextPriority = EGL_CONTEXT_PRIORITY_MEDIUM_IMG;
    ctx->ReleaseBehavior = EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR;
 
-   err = _eglParseContextAttribList(ctx, dpy, attrib_list);
+   err = _eglParseContextAttribList(ctx, disp, attrib_list);
    if (err == EGL_SUCCESS && ctx->Config) {
       EGLint api_bit;
 
@@ -659,12 +671,8 @@ _eglQueryContextRenderBuffer(_EGLContext *ctx)
 
 
 EGLBoolean
-_eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c,
-                 EGLint attribute, EGLint *value)
+_eglQueryContext(_EGLContext *c, EGLint attribute, EGLint *value)
 {
-   (void) drv;
-   (void) dpy;
-
    if (!value)
       return _eglError(EGL_BAD_PARAMETER, "eglQueryContext");
 
@@ -730,7 +738,7 @@ static EGLBoolean
 _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
 {
    _EGLThreadInfo *t = _eglGetCurrentThread();
-   _EGLDisplay *dpy;
+   _EGLDisplay *disp;
 
    if (_eglIsCurrentThreadDummy())
       return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
@@ -742,8 +750,8 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
       return EGL_TRUE;
    }
 
-   dpy = ctx->Resource.Display;
-   if (!dpy->Extensions.KHR_surfaceless_context
+   disp = ctx->Resource.Display;
+   if (!disp->Extensions.KHR_surfaceless_context
        && (draw == NULL || read == NULL))
       return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
 
@@ -779,7 +787,7 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
    } else {
       /* Otherwise we must be using the EGL_KHR_no_config_context
        * extension */
-      assert(dpy->Extensions.KHR_no_config_context);
+      assert(disp->Extensions.KHR_no_config_context);
 
       /* The extension doesn't permit binding draw and read buffers with
        * differing contexts */