Mesa (10.0): i965: Only enable __DRI2_ROBUSTNESS if kernel support is available
Ian Romanick
idr at kemper.freedesktop.org
Thu Nov 28 16:56:14 UTC 2013
Module: Mesa
Branch: 10.0
Commit: a5f78c40250802a5bd03d26f22155aa5a3d930e1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5f78c40250802a5bd03d26f22155aa5a3d930e1
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Tue Nov 19 17:01:23 2013 -0800
i965: Only enable __DRI2_ROBUSTNESS if kernel support is available
This is a squash of the following two cherry-picked patches:
i965: Only enable __DRI2_ROBUSTNESS if kernel support is available
Rather than always advertising the extension but failing to create a
context with reset notifiction, just don't advertise it. I don't know
why it didn't occur to me to do it this way in the first place.
NOTE: Kristian requested that I provide a follow-up for master that
dynamically generates the list of DRI extensions instead of selected
between two hardcoded lists.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Suggested-by: Kristian Høgsberg <krh at bitplanet.net>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>
Cc: "10.0" <mesa-stable at lists.freedesktop.org>
(cherry picked from commit 9b1c68638d8096304d3c4e0cceb97bb4dc61acc5)
and
i965: Properly reject __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS when __DRI2_ROBUSTNESS is not enabled
Only allow __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS in brwCreateContext if
intelInitScreen2 also enabled __DRI2_ROBUSTNESS (thereby enabling
GLX_ARB_create_context).
This fixes a regression in the piglit test
"glx/GLX_ARB_create_context/invalid flag"
v2: Remove commented debug code. Noticed by Jordan.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reported-by: Paul Berry <stereotype441 at gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Cc: "10.0" <mesa-stable at lists.freedesktop.org>
(cherry picked from commit 53a65e547c0bf769fff48b4ccb41d1477daa70de)
---
src/mesa/drivers/dri/i965/brw_context.c | 28 ++++++++++------------------
src/mesa/drivers/dri/i965/intel_screen.c | 26 +++++++++++++++++++++++++-
src/mesa/drivers/dri/i965/intel_screen.h | 5 +++++
3 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 0b22992..3facf78 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -589,9 +589,16 @@ brwCreateContext(gl_api api,
struct dd_function_table functions;
struct gl_config visual;
- if (flags & ~(__DRI_CTX_FLAG_DEBUG
- | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
- | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)) {
+ /* Only allow the __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag if the kernel
+ * provides us with context reset notifications.
+ */
+ uint32_t allowed_flags = __DRI_CTX_FLAG_DEBUG
+ | __DRI_CTX_FLAG_FORWARD_COMPATIBLE;
+
+ if (screen->has_context_reset_notification)
+ allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
+
+ if (flags & ~allowed_flags) {
*dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
return false;
}
@@ -713,21 +720,6 @@ brwCreateContext(gl_api api,
}
}
- /* Notification of GPU resets requires hardware contexts and a kernel new
- * enough to support DRM_IOCTL_I915_GET_RESET_STATS.
- */
- if (notify_reset &&
- (brw->hw_ctx == NULL
- || drm_intel_get_reset_stats(brw->hw_ctx, &brw->reset_count, NULL,
- NULL))) {
- /* This is the wrong error code, but the correct error code (one that
- * will cause EGL to generate EGL_BAD_MATCH) doesn't seem to exist.
- */
- *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
- intelDestroyContext(driContextPriv);
- return false;
- }
-
brw_init_surface_formats(brw);
if (brw->is_g4x || brw->gen >= 5) {
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index e44d0f6..6bbd6dd 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -899,6 +899,15 @@ static const __DRIextension *intelScreenExtensions[] = {
&intelImageExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
+ NULL
+};
+
+static const __DRIextension *intelRobustScreenExtensions[] = {
+ &intelTexBufferExtension.base,
+ &intelFlushExtension.base,
+ &intelImageExtension.base,
+ &intelRendererQueryExtension.base,
+ &dri2ConfigQueryExtension.base,
&dri2Robustness.base,
NULL
};
@@ -1302,7 +1311,22 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
set_max_gl_versions(intelScreen);
- psp->extensions = intelScreenExtensions;
+ /* Notification of GPU resets requires hardware contexts and a kernel new
+ * enough to support DRM_IOCTL_I915_GET_RESET_STATS. If the ioctl is
+ * supported, calling it with a context of 0 will either generate EPERM or
+ * no error. If the ioctl is not supported, it always generate EINVAL.
+ * Use this to determine whether to advertise the __DRI2_ROBUSTNESS
+ * extension to the loader.
+ */
+ struct drm_i915_reset_stats stats;
+ memset(&stats, 0, sizeof(stats));
+
+ const int ret = drmIoctl(psp->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats);
+
+ intelScreen->has_context_reset_notification = (ret != -1 || errno != EINVAL);
+
+ psp->extensions = !intelScreen->has_context_reset_notification
+ ? intelScreenExtensions : intelRobustScreenExtensions;
return (const __DRIconfig**) intel_screen_make_configs(psp);
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index eb9bfca..abaa05f 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -50,6 +50,11 @@ struct intel_screen
bool hw_has_swizzling;
+ /**
+ * Does the kernel support context reset notifications?
+ */
+ bool has_context_reset_notification;
+
dri_bufmgr *bufmgr;
/**
More information about the mesa-commit
mailing list