summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-11-19 17:01:23 -0800
committerIan Romanick <[email protected]>2013-11-26 13:10:52 -0800
commit9b1c68638d8096304d3c4e0cceb97bb4dc61acc5 (patch)
tree42f67b22556ced73b9c3d70086489b2c6fb1aec9
parent0ae84399069b77e9464462c53405baf6f854a6fd (diff)
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 <[email protected]> Suggested-by: Kristian Høgsberg <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Cc: "10.0" <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c15
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c24
2 files changed, 23 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index d5c18bb7a3b..67ac01c23db 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -682,21 +682,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 81901cc5a0a..051c000ef44 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
};
@@ -1323,7 +1332,20 @@ __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);
+
+ psp->extensions = (ret == -1 && errno == EINVAL)
+ ? intelScreenExtensions : intelRobustScreenExtensions;
return (const __DRIconfig**) intel_screen_make_configs(psp);
}