st/mesa: set a device reset callback when available
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 30 Sep 2016 12:06:04 +0000 (14:06 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 5 Oct 2016 13:51:53 +0000 (15:51 +0200)
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_cb_flush.c
src/mesa/state_tracker/st_cb_flush.h
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_manager.c

index 87c3d819a611b6f82496340bff7b039d73f9786e..6442fc922532988096554084cffc7c5f1ff5a7cc 100644 (file)
@@ -171,12 +171,41 @@ st_get_graphics_reset_status(struct gl_context *ctx)
    struct st_context *st = st_context(ctx);
    enum pipe_reset_status status;
 
-   status = st->pipe->get_device_reset_status(st->pipe);
+   if (st->reset_status != PIPE_NO_RESET) {
+      status = st->reset_status;
+      st->reset_status = PIPE_NO_RESET;
+   } else {
+      status = st->pipe->get_device_reset_status(st->pipe);
+   }
 
    return gl_reset_status_from_pipe_reset_status(status);
 }
 
 
+static void
+st_device_reset_callback(void *data, enum pipe_reset_status status)
+{
+   struct st_context *st = data;
+
+   assert(status != PIPE_NO_RESET);
+
+   st->reset_status = status;
+   _mesa_set_context_lost_dispatch(st->ctx);
+}
+
+
+void
+st_install_device_reset_callback(struct st_context *st)
+{
+   if (st->pipe->set_device_reset_callback) {
+      struct pipe_device_reset_callback cb;
+      cb.reset = st_device_reset_callback;
+      cb.data = st;
+      st->pipe->set_device_reset_callback(st->pipe, &cb);
+   }
+}
+
+
 void st_init_flush_functions(struct pipe_screen *screen,
                              struct dd_function_table *functions)
 {
index f92dcd56b64c36c02c7ff60dbd953c6443be1adc..5be68c9b68a3b5f58008c5ee969b606f2159aa93 100644 (file)
@@ -48,6 +48,9 @@ st_flush(struct st_context *st,
 extern void
 st_finish(struct st_context *st);
 
+extern void
+st_install_device_reset_callback(struct st_context *st);
+
 
 #endif /* ST_CB_FLUSH_H */
 
index 2b783e0028193aa500cf92957b41503b05bde51a..83d77fdf8f4b40cca7f57ad03452de06feaa9752 100644 (file)
@@ -253,6 +253,8 @@ struct st_context
    struct st_config_options options;
 
    struct st_perf_monitor_group *perfmon;
+
+   enum pipe_reset_status reset_status;
 };
 
 
index fece5d5dffd06b591504ca0394b0733debd84e74..69224544088318d282a278a776687b34872b915d 100644 (file)
@@ -688,8 +688,10 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
       st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
    if (attribs->flags & ST_CONTEXT_FLAG_ROBUST_ACCESS)
       st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
-   if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED)
+   if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED) {
       st->ctx->Const.ResetStrategy = GL_LOSE_CONTEXT_ON_RESET_ARB;
+      st_install_device_reset_callback(st);
+   }
 
    /* need to perform version check */
    if (attribs->major > 1 || attribs->minor > 0) {