[Mesa-dev] [PATCH 2/4] dri: Add KHR_no_error DRI extension
Grigori Goronzy
greg at chown.ath.cx
Tue Jul 11 22:26:13 UTC 2017
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.
---
include/GL/internal/dri_interface.h | 19 +++++++++++++++++++
src/gallium/state_trackers/dri/dri2.c | 6 ++++++
src/gallium/state_trackers/dri/dri_context.c | 3 ++-
src/mesa/drivers/dri/common/dri_util.c | 8 ++++++--
src/mesa/drivers/dri/i965/intel_screen.c | 8 +++++++-
5 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 2da46f7..da60648 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -1050,6 +1050,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.
*/
/*@{*/
@@ -1612,6 +1618,19 @@ struct __DRIrobustnessExtensionRec {
};
/**
+ * 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.
*
* This extension provides the XML string containing driver options for use by
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 5da1c4e..244a6ad 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1667,6 +1667,10 @@ static const __DRIrobustnessExtension dri2Robustness = {
.base = { __DRI2_ROBUSTNESS, 1 }
};
+static const __DRInoErrorExtension driNoError = {
+ .base = { __DRI2_NO_ERROR, 1 }
+};
+
static int
dri2_interop_query_device_info(__DRIcontext *_ctx,
struct mesa_glinterop_device_info *out)
@@ -2002,6 +2006,7 @@ static const __DRIextension *dri_screen_extensions[] = {
&dri2ThrottleExtension.base,
&dri2FenceExtension.base,
&dri2InteropExtension.base,
+ &driNoError.base,
NULL
};
@@ -2015,6 +2020,7 @@ static const __DRIextension *dri_robust_screen_extensions[] = {
&dri2FenceExtension.base,
&dri2InteropExtension.base,
&dri2Robustness.base,
+ &driNoError.base,
NULL
};
diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index ec555e4..e25f186 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -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;
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index f6df488..174356f 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -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 *
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index c75f212..2bfe0b9 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1247,7 +1247,11 @@ static const __DRI2rendererQueryExtension intelRendererQueryExtension = {
};
static const __DRIrobustnessExtension dri2Robustness = {
- .base = { __DRI2_ROBUSTNESS, 1 }
+ .base = { __DRI2_NO_ERROR, 1 }
+};
+
+static const __DRInoErrorExtension driNoErrorExtension = {
+ .base = { __DRI2_NO_ERROR, 1 }
};
static const __DRIextension *screenExtensions[] = {
@@ -1257,6 +1261,7 @@ static const __DRIextension *screenExtensions[] = {
&intelImageExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
+ &driNoErrorExtension.base,
NULL
};
@@ -1268,6 +1273,7 @@ static const __DRIextension *intelRobustScreenExtensions[] = {
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
&dri2Robustness.base,
+ &driNoErrorExtension.base,
NULL
};
--
2.7.4
More information about the mesa-dev
mailing list