[Mesa-dev] [PATCH 4/8] dri: Add a flush control extension
Neil Roberts
neil at linux.intel.com
Wed Oct 1 12:00:47 PDT 2014
Adds a DRI extension which advertises that the driver can accept a new
__DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in the createContextAttribs
function. If the attribute is specified then it will be passed down to the
CreateContext function in the release_behavior member of
__DriverContextConfig. The attribute is needed to implement the
GLX_ARB_context_flush_control extension.
---
include/GL/internal/dri_interface.h | 25 +++++++++++++++++++++++++
src/mesa/drivers/dri/common/dri_util.c | 14 ++++++++++++++
src/mesa/drivers/dri/common/dri_util.h | 5 +++++
3 files changed, 44 insertions(+)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 8c5ceb9..a2b6c40 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -909,6 +909,8 @@ struct __DRIdri2LoaderExtensionRec {
*/
#define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
+#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 4
+
#define __DRI_CTX_FLAG_DEBUG 0x00000001
#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
@@ -926,6 +928,14 @@ struct __DRIdri2LoaderExtensionRec {
/*@}*/
/**
+ * \name Context release behaviors.
+ */
+/*@{*/
+#define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0
+#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1
+/*@}*/
+
+/**
* \name Reasons that __DRIdri2Extension::createContextAttribs might fail
*/
/*@{*/
@@ -1331,6 +1341,21 @@ struct __DRIrobustnessExtensionRec {
};
/**
+ * 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.
*
* This extension provides the XML string containing driver options for use by
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 3125c65..f73a7db 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -360,6 +360,16 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
~__DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY;
}
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.
@@ -793,6 +803,10 @@ const __DRI2configQueryExtension dri2ConfigQueryExtension = {
.configQueryf = dri2ConfigQueryf,
};
+const __DRI2flushControlExtension dri2FlushControlExtension = {
+ .base = { __DRI2_FLUSH_CONTROL, 1 }
+};
+
void
dri2InvalidateDrawable(__DRIdrawable *drawable)
{
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 0369987..c2970eb 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -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.
@@ -90,9 +91,13 @@ struct __DriverContextConfig {
/* Only valid if __DRIVER_CONTEXT_ATTRIB_RESET_STRATEGY is set */
int reset_strategy;
+
+ /* 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_RELEASE_BEHAVIOR (1 << 1)
/**
* Driver callback functions.
--
1.9.3
More information about the mesa-dev
mailing list