aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2012-09-11 11:07:25 +0300
committerIan Romanick <[email protected]>2013-11-07 17:40:25 -0800
commite8dac9632d35b5902b6565e64b22846ba6198b5b (patch)
tree68f977aa5049070fea000822654d0ddca483bd46 /src/mesa
parent8f2c93ff75c7fac6f9c7d6c8eb3dc8293c8aaf92 (diff)
i965: Propagate the GPU reset notifiction strategy down into the driver
If the application requests reset notifiction, connect up the reset status query method and set gl_context::ResetStrategy. v2: Update based on kernel interface / libdrm changes. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c26
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h8
2 files changed, 29 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 44a6de7f15a..5321f876478 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -587,11 +587,6 @@ brwCreateContext(gl_api api,
return false;
}
- if (notify_reset) {
- *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
- return false;
- }
-
struct brw_context *brw = rzalloc(NULL, struct brw_context);
if (!brw) {
printf("%s: failed to alloc context\n", __FUNCTION__);
@@ -634,6 +629,9 @@ brwCreateContext(gl_api api,
brw_init_driver_functions(brw, &functions);
+ if (notify_reset)
+ functions.GetGraphicsResetStatus = brw_get_graphics_reset_status;
+
struct gl_context *ctx = &brw->ctx;
if (mesaVis == NULL) {
@@ -675,6 +673,9 @@ brwCreateContext(gl_api api,
brw_process_intel_debug_variable(brw);
brw_initialize_context_constants(brw);
+ ctx->Const.ResetStrategy = notify_reset
+ ? GL_LOSE_CONTEXT_ON_RESET_ARB : GL_NO_RESET_NOTIFICATION_ARB;
+
/* Reinitialize the context point state. It depends on ctx->Const values. */
_mesa_init_point(ctx);
@@ -703,6 +704,21 @@ 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/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 9bc6f56590b..66c74f73cfa 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1019,6 +1019,14 @@ struct brw_context
drm_intel_context *hw_ctx;
+ /**
+ * Number of resets observed in the system at context creation.
+ *
+ * This is tracked in the context so that we can determine that another
+ * reset has occured.
+ */
+ uint32_t reset_count;
+
struct intel_batchbuffer batch;
bool no_batch_wrap;