[Mesa-dev] [PATCH v2 1/4] dri: Add KHR_no_error DRI extension
Grigori Goronzy
greg at chown.ath.cx
Thu Jul 13 11:30:21 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.
v2: Move to common DRI code.
---
include/GL/internal/dri_interface.h | 19 +++++++++++++++++++
src/gallium/state_trackers/dri/dri2.c | 2 ++
src/gallium/state_trackers/dri/dri_context.c | 3 ++-
src/gallium/state_trackers/dri/drisw.c | 1 +
src/mesa/drivers/dri/common/dri_util.c | 12 ++++++++++--
src/mesa/drivers/dri/common/dri_util.h | 2 ++
src/mesa/drivers/dri/i915/intel_screen.c | 1 +
src/mesa/drivers/dri/i965/intel_screen.c | 2 ++
src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 +
src/mesa/drivers/dri/radeon/radeon_screen.c | 1 +
src/mesa/drivers/dri/swrast/swrast.c | 1 +
11 files changed, 42 insertions(+), 3 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..6cd1582 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -2002,6 +2002,7 @@ static const __DRIextension *dri_screen_extensions[] = {
&dri2ThrottleExtension.base,
&dri2FenceExtension.base,
&dri2InteropExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
@@ -2015,6 +2016,7 @@ static const __DRIextension *dri_robust_screen_extensions[] = {
&dri2FenceExtension.base,
&dri2InteropExtension.base,
&dri2Robustness.base,
+ &dri2NoErrorExtension.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/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index 189d61c..ac40956 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -371,6 +371,7 @@ static const __DRIextension *drisw_screen_extensions[] = {
&dri2RendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
&dri2FenceExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index f6df488..bfae020 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 *
@@ -935,3 +939,7 @@ const __DRIcopySubBufferExtension driCopySubBufferExtension = {
.copySubBuffer = driCopySubBuffer,
};
+
+const __DRInoErrorExtension dri2NoErrorExtension = {
+ .base = { __DRI2_NO_ERROR, 1 },
+};
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index 8fcd632..3e1ce62 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -293,4 +293,6 @@ driContextSetFlags(struct gl_context *ctx, uint32_t flags);
extern const __DRIimageDriverExtension driImageDriverExtension;
+extern const __DRInoErrorExtension dri2NoErrorExtension;
+
#endif /* _DRI_UTIL_H_ */
diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c
index 686cbf5..9e23552 100644
--- a/src/mesa/drivers/dri/i915/intel_screen.c
+++ b/src/mesa/drivers/dri/i915/intel_screen.c
@@ -802,6 +802,7 @@ static const __DRIextension *intelScreenExtensions[] = {
&intelImageExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index c75f212..ef923c3 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1257,6 +1257,7 @@ static const __DRIextension *screenExtensions[] = {
&intelImageExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
@@ -1268,6 +1269,7 @@ static const __DRIextension *intelRobustScreenExtensions[] = {
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
&dri2Robustness.base,
+ &dri2NoErrorExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 375f640..65caec2 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -324,6 +324,7 @@ static const __DRIextension *nouveau_screen_extensions[] = {
&nouveau_texbuffer_extension.base,
&nouveau_renderer_query_extension.base,
&dri2ConfigQueryExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
index 79e3889..526d197 100644
--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -544,6 +544,7 @@ static const __DRIextension *radeon_screen_extensions[] = {
&radeonFlushExtension.base,
&radeonImageExtension.base,
&radeonRendererQueryExtension.base,
+ &dri2NoErrorExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index e66b225..c2aa4da 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -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
};
--
2.7.4
More information about the mesa-dev
mailing list