[PATCH xserver 3/3] glx/dri2: Enable GLX_ARB_context_flush_control

Neil Roberts neil at linux.intel.com
Wed Oct 1 12:06:57 PDT 2014


If the driver supports __DRI2_FLUSH_CONTROL then the
GLX_ARB_context_flush_control extension will now be enabled as well.
If the flush behavior attribute is passed to
glXCreateContextAttribsARB and the driver doesn't support
__DRI2_FLUSH_CONTROL then the driver should already generate the
correct error values so that the correct GLX errors are generated.

The required Mesa version when building with DRI2 support has been
bumped up to 10.4.0 so that it can be sure the __DRI2_FLUSH_CONTROL
extension is defined.
---
 configure.ac  |  2 +-
 glx/glxdri2.c | 36 +++++++++++++++++++++++++++++++++---
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 30c0c5c..2a061c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1108,7 +1108,7 @@ case "$DRI2,$HAVE_DRI2PROTO" in
 	yes,yes | auto,yes)
 		AC_DEFINE(DRI2, 1, [Build DRI2 extension])
 		DRI2=yes
-		LIBGL="gl >= 9.2.0"
+		LIBGL="gl >= 10.4.0"
 		SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $DRI2PROTO"
 		;;
 esac
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index c756bf5..1801a95 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -371,7 +371,8 @@ static Bool
 dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
                          const uint32_t *attribs,
                          unsigned *major_ver, unsigned *minor_ver,
-                         uint32_t *flags, int *api, int *reset, unsigned *error)
+                         uint32_t *flags, int *api, int *reset, int *release,
+                         unsigned *error)
 {
     unsigned i;
 
@@ -386,6 +387,7 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
     *major_ver = 1;
     *minor_ver = 0;
     *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
+    *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
 
     for (i = 0; i < num_attribs; i++) {
         switch (attribs[i * 2]) {
@@ -434,6 +436,19 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
                 return False;
             }
             break;
+        case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
+            switch (attribs[i * 2 + 1]) {
+            case GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB:
+                *release = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
+                break;
+            case GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB:
+                *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
+                break;
+            default:
+                *error = BadValue;
+                return False;
+            }
+            break;
         default:
             /* If an unknown attribute is received, fail.
              */
@@ -475,19 +490,20 @@ create_driver_context(__GLXDRIcontext * context,
     context->driContext = NULL;
 
     if (screen->dri2->base.version >= 3) {
-        uint32_t ctx_attribs[3 * 2];
+        uint32_t ctx_attribs[4 * 2];
         unsigned num_ctx_attribs = 0;
         unsigned dri_err = 0;
         unsigned major_ver;
         unsigned minor_ver;
         uint32_t flags = 0;
         int reset;
+        int release;
         int api = __DRI_API_OPENGL;
 
         if (num_attribs != 0) {
             if (!dri2_convert_glx_attribs(screen, num_attribs, attribs,
                                           &major_ver, &minor_ver,
-                                          &flags, &api, &reset,
+                                          &flags, &api, &reset, &release,
                                           (unsigned *) error))
                 return;
 
@@ -510,6 +526,12 @@ create_driver_context(__GLXDRIcontext * context,
                     __DRI_CTX_ATTRIB_RESET_STRATEGY;
                 ctx_attribs[num_ctx_attribs++] = reset;
             }
+
+            if (release != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH) {
+                ctx_attribs[num_ctx_attribs++] =
+                    __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR;
+                ctx_attribs[num_ctx_attribs++] = release;
+            }
         }
 
         context->driContext =
@@ -919,6 +941,14 @@ initializeExtensions(__GLXDRIscreen * screen)
                        "AIGLX: enabled GLX_ARB_create_context_robustness\n");
         }
 
+        if (strcmp(extensions[i]->name, __DRI2_FLUSH_CONTROL) == 0 &&
+            screen->dri2->base.version >= 3) {
+                __glXEnableExtension(screen->glx_enable_bits,
+                                     "GLX_ARB_context_flush_control");
+                LogMessage(X_INFO,
+                           "AIGLX: enabled GLX_ARB_context_flush_control\n");
+        }
+
         /* Ignore unknown extensions */
     }
 }
-- 
1.9.3



More information about the xorg-devel mailing list