dri: Add a flush control extension
authorNeil Roberts <neil@linux.intel.com>
Wed, 1 Oct 2014 19:00:47 +0000 (20:00 +0100)
committerAdam Jackson <ajax@redhat.com>
Mon, 6 Nov 2017 21:09:02 +0000 (16:09 -0500)
This advertises that the driver can accept a new context attribute
__DRI_CTX_ATTRIB_RELEASE_BEHAVIOR.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
include/GL/internal/dri_interface.h
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h

index 98402eae057e6ffda2773529b751f014b23f793a..b47947380c4a88be85a07bcdf18412ebffbda43e 100644 (file)
@@ -1106,6 +1106,16 @@ struct __DRIdri2LoaderExtensionRec {
 #define __DRI_CTX_PRIORITY_MEDIUM              1
 #define __DRI_CTX_PRIORITY_HIGH                        2
 
+/**
+ * \name Context release behaviors.
+ */
+/*@{*/
+#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR      5
+
+#define __DRI_CTX_RELEASE_BEHAVIOR_NONE         0
+#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH        1
+/*@}*/
+
 /**
  * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
  */
@@ -1715,6 +1725,21 @@ typedef struct __DRInoErrorExtensionRec {
    __DRIextension base;
 } __DRInoErrorExtension;
 
+/*
+ * Flush control driver extension.
+ *
+ * Existence of this extension means the driver can accept the
+ * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
+ * \c __DRIdri2ExtensionRec::createContextAttribs.
+ */
+#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
+#define __DRI2_FLUSH_CONTROL_VERSION 1
+
+typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
+struct __DRI2flushControlExtensionRec {
+   __DRIextension base;
+};
+
 /**
  * DRI config options extension.
  *
index dc5260ca5b9715748299f55fecd9edf621b02d74..d504751c3929ed3d308d849a638988843b3fcd29 100644 (file)
@@ -361,6 +361,16 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
             ctx_config.attribute_mask |= __DRIVER_CONTEXT_ATTRIB_PRIORITY;
            ctx_config.priority = attribs[i * 2 + 1];
            break;
+        case __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR:
+            if (attribs[i * 2 + 1] != __DRI_CTX_RELEASE_BEHAVIOR_FLUSH) {
+                ctx_config.attribute_mask |=
+                    __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
+                ctx_config.release_behavior = attribs[i * 2 + 1];
+            } else {
+                ctx_config.attribute_mask &=
+                    ~__DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR;
+            }
+            break;
        default:
            /* We can't create a context that satisfies the requirements of an
             * attribute that we don't understand.  Return failure.
@@ -833,6 +843,10 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension = {
    .configQueryf        = dri2ConfigQueryf,
 };
 
+const __DRI2flushControlExtension dri2FlushControlExtension = {
+   .base = { __DRI2_FLUSH_CONTROL, 1 }
+};
+
 void
 dri2InvalidateDrawable(__DRIdrawable *drawable)
 {
index 13d07dd51301398528bacf28cecad5b1a4d1dce9..5018f2fbf68123d9dee1e00a57958650fc49e4e4 100644 (file)
@@ -67,6 +67,7 @@ extern const __DRIswrastExtension driSWRastExtension;
 extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRI2configQueryExtension dri2ConfigQueryExtension;
 extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+extern const __DRI2flushControlExtension dri2FlushControlExtension;
 
 /**
  * Description of the attributes used to create a config.
@@ -93,10 +94,14 @@ struct __DriverContextConfig {
 
     /* Only valid if __DRIVER_CONTEXT_PRIORITY is set */
     unsigned priority;
+
+    /* Only valid if __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR is set */
+    int release_behavior;
 };
 
-#define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY  (1 << 0)
-#define __DRIVER_CONTEXT_ATTRIB_PRIORITY        (1 << 1)
+#define __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY   (1 << 0)
+#define __DRIVER_CONTEXT_ATTRIB_PRIORITY         (1 << 1)
+#define __DRIVER_CONTEXT_ATTRIB_RELEASE_BEHAVIOR (1 << 2)
 
 /**
  * Driver callback functions.