dri: Add KHR_no_error DRI extension
authorGrigori Goronzy <greg@chown.ath.cx>
Thu, 29 Jun 2017 01:24:15 +0000 (03:24 +0200)
committerGrigori Goronzy <greg@chown.ath.cx>
Fri, 14 Jul 2017 19:20:31 +0000 (21:20 +0200)
This basic extension allows usage of the __DRI_CTX_FLAG_NO_ERROR flag.
This includes support code for classic Mesa drivers to switch on the
no-error mode if the flag is set.

v2: Move to common DRI code.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
include/GL/internal/dri_interface.h
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/dri_context.c
src/gallium/state_trackers/dri/drisw.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/nouveau/nouveau_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/swrast/swrast.c

index 1893d4c4a5e0db6eed688716a5b160418147ccbf..a8f5af145df079143b54d1a4b4966e02b047bc93 100644 (file)
@@ -1049,6 +1049,12 @@ struct __DRIdri2LoaderExtensionRec {
  */
 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS    0x00000004
 
+/**
+ * \requires __DRI2_NO_ERROR.
+ *
+ */
+#define __DRI_CTX_FLAG_NO_ERROR                        0x00000008
+
 /**
  * \name Context reset strategies.
  */
@@ -1611,6 +1617,19 @@ struct __DRIrobustnessExtensionRec {
    __DRIextension base;
 };
 
+/**
+ * No-error context driver extension.
+ *
+ * Existence of this extension means the driver can accept the
+ * __DRI_CTX_FLAG_NO_ERROR flag.
+ */
+#define __DRI2_NO_ERROR "DRI_NoError"
+#define __DRI2_NO_ERROR_VERSION 1
+
+typedef struct __DRInoErrorExtensionRec {
+   __DRIextension base;
+} __DRInoErrorExtension;
+
 /**
  * DRI config options extension.
  *
index e20b2c0753615dd32332d13497e8d0d6430f17c9..787949ec396c2f5a5e6283a649c6a23cd4671a20 100644 (file)
@@ -1995,6 +1995,7 @@ static const __DRIextension *dri_screen_extensions[] = {
    &dri2ThrottleExtension.base,
    &dri2FenceExtension.base,
    &dri2InteropExtension.base,
+   &dri2NoErrorExtension.base,
    NULL
 };
 
@@ -2008,6 +2009,7 @@ static const __DRIextension *dri_robust_screen_extensions[] = {
    &dri2FenceExtension.base,
    &dri2InteropExtension.base,
    &dri2Robustness.base,
+   &dri2NoErrorExtension.base,
    NULL
 };
 
index ec555e44d74f8616d8382e1dc6a34e44fac1c834..e25f186deb86b6a48fbab44be04d56eec867d183 100644 (file)
@@ -57,7 +57,8 @@ dri_create_context(gl_api api, const struct gl_config * visual,
    struct st_context_attribs attribs;
    enum st_context_error ctx_err = 0;
    unsigned allowed_flags = __DRI_CTX_FLAG_DEBUG |
-                            __DRI_CTX_FLAG_FORWARD_COMPATIBLE;
+                            __DRI_CTX_FLAG_FORWARD_COMPATIBLE |
+                            __DRI_CTX_FLAG_NO_ERROR;
    const __DRIbackgroundCallableExtension *backgroundCallable =
       screen->sPriv->dri2.backgroundCallable;
 
index 189d61c4cb6e16f780734deba78e3fbbec47120f..ac4095618c0b9025435eb2dab757e5466fef20f2 100644 (file)
@@ -371,6 +371,7 @@ static const __DRIextension *drisw_screen_extensions[] = {
    &dri2RendererQueryExtension.base,
    &dri2ConfigQueryExtension.base,
    &dri2FenceExtension.base,
+   &dri2NoErrorExtension.base,
    NULL
 };
 
index f6df48802f310a8a192fb5c03c56cf90c8b2ac5b..bfae0209d1862d9d54bf8f3f836f0ff726cc6067 100644 (file)
@@ -403,7 +403,8 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
     if (mesa_api != API_OPENGL_COMPAT
         && mesa_api != API_OPENGL_CORE
         && (flags & ~(__DRI_CTX_FLAG_DEBUG |
-                     __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS))) {
+                     __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS |
+                     __DRI_CTX_FLAG_NO_ERROR))) {
        *error = __DRI_CTX_ERROR_BAD_FLAG;
        return NULL;
     }
@@ -425,7 +426,8 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
 
     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;
@@ -467,6 +469,8 @@ driContextSetFlags(struct gl_context *ctx, uint32_t flags)
        _mesa_set_debug_state_int(ctx, GL_DEBUG_OUTPUT, GL_TRUE);
         ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
     }
+    if ((flags & __DRI_CTX_FLAG_NO_ERROR) != 0)
+        ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
 }
 
 static __DRIcontext *
@@ -935,3 +939,7 @@ const __DRIcopySubBufferExtension driCopySubBufferExtension = {
 
    .copySubBuffer               = driCopySubBuffer,
 };
+
+const __DRInoErrorExtension dri2NoErrorExtension = {
+   .base = { __DRI2_NO_ERROR, 1 },
+};
index 8fcd6322d04a775bbd62b0288c5d156a10d24b75..3e1ce624c7b21402a950243b60a7141608bce46a 100644 (file)
@@ -293,4 +293,6 @@ driContextSetFlags(struct gl_context *ctx, uint32_t flags);
 
 extern const __DRIimageDriverExtension driImageDriverExtension;
 
+extern const __DRInoErrorExtension dri2NoErrorExtension;
+
 #endif /* _DRI_UTIL_H_ */
index 686cbf5ec123972f3232f2af20178800f824132c..9e23552b9987c4c0af31c4efa2fc40564277b6d2 100644 (file)
@@ -802,6 +802,7 @@ static const __DRIextension *intelScreenExtensions[] = {
     &intelImageExtension.base,
     &intelRendererQueryExtension.base,
     &dri2ConfigQueryExtension.base,
+    &dri2NoErrorExtension.base,
     NULL
 };
 
index 641edb7e72be8f21fb66d5395c32f4e89170b49b..0f4fed515a01be69563546e4ecfed48413697832 100644 (file)
@@ -1274,6 +1274,7 @@ static const __DRIextension *screenExtensions[] = {
     &intelImageExtension.base,
     &intelRendererQueryExtension.base,
     &dri2ConfigQueryExtension.base,
+    &dri2NoErrorExtension.base,
     NULL
 };
 
@@ -1285,6 +1286,7 @@ static const __DRIextension *intelRobustScreenExtensions[] = {
     &intelRendererQueryExtension.base,
     &dri2ConfigQueryExtension.base,
     &dri2Robustness.base,
+    &dri2NoErrorExtension.base,
     NULL
 };
 
index 375f640f3d08667336d21a26b7743c9f9a839a1b..65caec27eb3e4a88ae77d387b4cad9f4acc25910 100644 (file)
@@ -324,6 +324,7 @@ static const __DRIextension *nouveau_screen_extensions[] = {
     &nouveau_texbuffer_extension.base,
     &nouveau_renderer_query_extension.base,
     &dri2ConfigQueryExtension.base,
+    &dri2NoErrorExtension.base,
     NULL
 };
 
index 79e388988a0484ee44a5fa2706378b35b894f7b0..526d197452791be6e3c3199ac66d49152b49c840 100644 (file)
@@ -544,6 +544,7 @@ static const __DRIextension *radeon_screen_extensions[] = {
     &radeonFlushExtension.base,
     &radeonImageExtension.base,
     &radeonRendererQueryExtension.base,
+    &dri2NoErrorExtension.base,
     NULL
 };
 
index e66b2257de85e8eea7864175d3e7f79285546988..c2aa4da75a39bd0a7af47c40dec08e7b1c96597b 100644 (file)
@@ -208,6 +208,7 @@ static const __DRI2rendererQueryExtension swrast_query_renderer_extension = {
 static const __DRIextension *dri_screen_extensions[] = {
     &swrastTexBufferExtension.base,
     &swrast_query_renderer_extension.base,
+    &dri2NoErrorExtension.base,
     NULL
 };