[Mesa-dev] [RFC 1/3] dri: add support for CONTEXT_FLAG_NO_ERROR_BIT_KHR

Timothy Arceri tarceri at itsqueeze.com
Tue Mar 28 04:35:27 UTC 2017


The KHR_no_error spec says:

   "CONTEXT_FLAG_NO_ERROR_BIT_KHR is only supported if the
   OpenGL version has support for context flags (as defined
   in the OpenGL 4.5 core spec) or an  extension supporting
   equivalent functionality is exposed."

But the OpenGL 4.5 core spec just has referenced to
{WGL,GLX}_ARB_create_context. There is also no
GLX_create_context_no_error so I'm unsure if the text from
the spec implies that it extends {WGL,GLX}_ARB_create_context
or if a new extension is actually required.
---
 include/GL/internal/dri_interface.h    |  2 ++
 src/mesa/drivers/dri/common/dri_util.c | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 86efd1b..44840a9 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1041,20 +1041,22 @@ struct __DRIdri2LoaderExtensionRec {
 #define __DRI_CTX_ATTRIB_RESET_STRATEGY		3
 
 #define __DRI_CTX_FLAG_DEBUG			0x00000001
 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE	0x00000002
 
 /**
  * \requires __DRI2_ROBUSTNESS.
  */
 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS	0x00000004
 
+#define __DRI_CTX_FLAG_NO_ERROR			0x00000008
+
 /**
  * \name Context reset strategies.
  */
 /*@{*/
 #define __DRI_CTX_RESET_NO_NOTIFICATION		0
 #define __DRI_CTX_RESET_LOSE_CONTEXT		1
 /*@}*/
 
 /**
  * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index f6df488..6d7f1df 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -418,21 +418,22 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
      * requested API to API_OPENGL_CORE.
      *
      * In Mesa, a debug context is the same as a regular context.
      */
     if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
        mesa_api = API_OPENGL_CORE;
     }
 
     const uint32_t allowed_flags = (__DRI_CTX_FLAG_DEBUG
                                     | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
-                                    | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS);
+                                    | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS
+                                    | __DRI_CTX_FLAG_NO_ERROR);
     if (flags & ~allowed_flags) {
 	*error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
 	return NULL;
     }
 
     if (!validate_context_version(screen, mesa_api,
                                   major_version, minor_version, error))
        return NULL;
 
     context = calloc(1, sizeof *context);
@@ -459,20 +460,33 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
 }
 
 void
 driContextSetFlags(struct gl_context *ctx, uint32_t flags)
 {
     if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0)
         ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
     if ((flags & __DRI_CTX_FLAG_DEBUG) != 0) {
        _mesa_set_debug_state_int(ctx, GL_DEBUG_OUTPUT, GL_TRUE);
         ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
+    } else if ((flags & __DRI_CTX_FLAG_NO_ERROR) != 0) {
+        /* From Issue (1) of the KHR_no_error spec:
+         *
+         *    "How does this extension interact with KHR_robustness and debug
+         *    contexts?
+         *
+         *    RESOLVED: The EGL/WGL/GLX layers should prevent these features
+         *    from being enabled at the same time.  However, if they are
+         *    somehow enabled at the same time this extension should be
+         *    ignored."
+         */
+        if ((flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS) == 0)
+           ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
     }
 }
 
 static __DRIcontext *
 driCreateNewContextForAPI(__DRIscreen *screen, int api,
                           const __DRIconfig *config,
                           __DRIcontext *shared, void *data)
 {
     unsigned error;
 
-- 
2.9.3



More information about the mesa-dev mailing list