---
 src/gallium/state_trackers/glx/xlib/glx_api.c | 55 ++++++++++++++++++++++++---
 src/gallium/state_trackers/glx/xlib/xm_api.c  |  6 ++-
 src/gallium/state_trackers/glx/xlib/xm_api.h  |  4 +-
 3 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c 
b/src/gallium/state_trackers/glx/xlib/glx_api.c
index c473a0f..ac50dc6 100644
--- a/src/gallium/state_trackers/glx/xlib/glx_api.c
+++ b/src/gallium/state_trackers/glx/xlib/glx_api.c
@@ -66,6 +66,7 @@
    "GLX_MESA_pixmap_colormap " \
    "GLX_MESA_release_buffers " \
    "GLX_ARB_create_context " \
+   "GLX_ARB_create_context_no_error " \
    "GLX_ARB_create_context_profile " \
    "GLX_ARB_get_proc_address " \
    "GLX_EXT_create_context_es_profile " \
@@ -1108,7 +1109,8 @@ static GLXContext
 create_context(Display *dpy, XMesaVisual xmvis,
                XMesaContext shareCtx, Bool direct,
                unsigned major, unsigned minor,
-               unsigned profileMask, unsigned contextFlags)
+               unsigned profileMask, unsigned contextFlags,
+               Bool noError)
 {
    GLXContext glxCtx;
 
@@ -1125,7 +1127,8 @@ create_context(Display *dpy, XMesaVisual xmvis,
 #endif
 
    glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx, major, minor,
-                                             profileMask, contextFlags);
+                                             profileMask, contextFlags,
+                                             (GLboolean)noError);
    if (!glxCtx->xmesaContext) {
       free(glxCtx);
       return NULL;
@@ -1158,7 +1161,8 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo,
    return create_context(dpy, xmvis,
                          shareCtx ? shareCtx->xmesaContext : NULL,
                          direct,
-                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
+                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0,
+                         False);
 }
 
 
@@ -2194,7 +2198,8 @@ glXCreateNewContext( Display *dpy, GLXFBConfig config,
    return create_context(dpy, xmvis,
                          shareCtx ? shareCtx->xmesaContext : NULL,
                          direct,
-                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
+                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0,
+                         False);
 }
 
 
@@ -2409,7 +2414,8 @@ glXCreateContextWithConfigSGIX(Display *dpy, 
GLXFBConfigSGIX config,
    return create_context(dpy, xmvis,
                          shareCtx ? shareCtx->xmesaContext : NULL,
                          direct,
-                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
+                         1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0,
+                         False);
 }
 
 
@@ -2741,6 +2747,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig 
config,
    int renderType = GLX_RGBA_TYPE;
    unsigned i;
    Bool done = False;
+   Bool noError = False;
    const int contextFlagsAll = (GLX_CONTEXT_DEBUG_BIT_ARB |
                                 GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
    GLXContext ctx;
@@ -2757,6 +2764,9 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig 
config,
       case GLX_CONTEXT_FLAGS_ARB:
          contextFlags = attrib_list[++i];
          break;
+      case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
+         noError = attrib_list[++i];
+         break;
       case GLX_CONTEXT_PROFILE_MASK_ARB:
          profileMask = attrib_list[++i];
          break;
@@ -2826,16 +2836,49 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig 
config,
       return NULL;
    }
 
+   /* The KHR_no_error specs say:
+    *
+    *    Requires OpenGL ES 2.0 or OpenGL 2.0.
+    */
+   if (noError && majorVersion < 2) {
+      generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True);
+      return NULL;
+   }
+
    if (renderType == GLX_COLOR_INDEX_TYPE && majorVersion >= 3) {
       generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True);
       return NULL;
    }
 
+   /* The GLX_ARB_create_context_no_error specs say:
+    *
+    *    BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
+    *    used to create <share_context> does not match the value of
+    *    GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
+    */
+   if (shareCtx && shareCtx->xmesaContext->no_error != noError) {
+      generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True);
+      return NULL;
+   }
+
+   /* The GLX_ARB_create_context_no_error specs say:
+    *
+    *    BadMatch is generated if the GLX_CONTEXT_OPENGL_NO_ERROR_ARB is TRUE 
at
+    *    the same time as a debug or robustness context is specified.
+    *
+    * Robustness isn't supported by this GLX implementation yet, so doesn't
+    * apply.
+    */
+   if (noError && (contextFlags & GLX_CONTEXT_DEBUG_BIT_ARB)) {
+      generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True);
+      return NULL;
+   }
+
    ctx = create_context(dpy, xmvis,
                         shareCtx ? shareCtx->xmesaContext : NULL,
                         direct,
                         majorVersion, minorVersion,
-                        profileMask, contextFlags);
+                        profileMask, contextFlags, noError);
    if (!ctx) {
       generate_error(dpy, GLXBadFBConfig, 0, X_GLXCreateContextAttribsARB, 
False);
    }
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c 
b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 828253b..508db5c 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -952,7 +952,8 @@ xmesa_init( Display *display )
 PUBLIC
 XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
                                  GLuint major, GLuint minor,
-                                 GLuint profileMask, GLuint contextFlags)
+                                 GLuint profileMask, GLuint contextFlags,
+                                 GLboolean noError)
 {
    XMesaDisplay xmdpy = xmesa_init_display(v->display);
    struct st_context_attribs attribs;
@@ -970,6 +971,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
    c->xm_visual = v;
    c->xm_buffer = NULL;   /* set later by XMesaMakeCurrent */
    c->xm_read_buffer = NULL;
+   c->no_error = noError;
 
    memset(&attribs, 0, sizeof(attribs));
    attribs.visual = v->stvis;
@@ -981,6 +983,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, 
XMesaContext share_list,
       attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
    if (contextFlags & GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
       attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS;
+   if (noError)
+      attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR;
 
    switch (profileMask) {
    case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h 
b/src/gallium/state_trackers/glx/xlib/xm_api.h
index 06bf839..6da6b58 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -145,7 +145,8 @@ extern XMesaContext XMesaCreateContext( XMesaVisual v,
                                        XMesaContext share_list,
                                         GLuint major, GLuint minor,
                                         GLuint profileMask,
-                                        GLuint contextFlags);
+                                        GLuint contextFlags,
+                                        GLboolean noError);
 
 
 /*
@@ -308,6 +309,7 @@ struct xmesa_context {
    XMesaBuffer xm_buffer;      /** current drawbuffer */
    XMesaBuffer xm_read_buffer;  /** current readbuffer */
    struct hud_context *hud;
+   GLboolean no_error;
 };
 
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to