panfrost: Stop passing a ctx to functions being passed a batch
[mesa.git] / src / gallium / drivers / iris / iris_context.c
index 5d4d27edf4e113dbcaab129f49cfb94686a3b59c..11762cbebd2e4a42cf7822e2534056eaca6694ae 100644 (file)
@@ -98,7 +98,44 @@ iris_lost_context_state(struct iris_batch *batch)
    }
 
    ice->state.dirty = ~0ull;
+   ice->state.current_hash_scale = 0;
    memset(ice->state.last_grid, 0, sizeof(ice->state.last_grid));
+   batch->last_surface_base_address = ~0ull;
+   ice->vtbl.lost_genx_state(ice, batch);
+}
+
+static enum pipe_reset_status
+iris_get_device_reset_status(struct pipe_context *ctx)
+{
+   struct iris_context *ice = (struct iris_context *)ctx;
+
+   enum pipe_reset_status worst_reset = PIPE_NO_RESET;
+
+   /* Check the reset status of each batch's hardware context, and take the
+    * worst status (if one was guilty, proclaim guilt).
+    */
+   for (int i = 0; i < IRIS_BATCH_COUNT; i++) {
+      /* This will also recreate the hardware contexts as necessary, so any
+       * future queries will show no resets.  We only want to report once.
+       */
+      enum pipe_reset_status batch_reset =
+         iris_batch_check_for_reset(&ice->batches[i]);
+
+      if (batch_reset == PIPE_NO_RESET)
+         continue;
+
+      if (worst_reset == PIPE_NO_RESET) {
+         worst_reset = batch_reset;
+      } else {
+         /* GUILTY < INNOCENT < UNKNOWN */
+         worst_reset = MIN2(worst_reset, batch_reset);
+      }
+   }
+
+   if (worst_reset != PIPE_NO_RESET && ice->reset.reset)
+      ice->reset.reset(ice->reset.data, worst_reset);
+
+   return worst_reset;
 }
 
 static void
@@ -177,6 +214,9 @@ iris_destroy_context(struct pipe_context *ctx)
 
 #define genX_call(devinfo, func, ...)             \
    switch (devinfo->gen) {                        \
+   case 12:                                       \
+      gen12_##func(__VA_ARGS__);                  \
+      break;                                      \
    case 11:                                       \
       gen11_##func(__VA_ARGS__);                  \
       break;                                      \
@@ -223,6 +263,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
    ctx->destroy = iris_destroy_context;
    ctx->set_debug_callback = iris_set_debug_callback;
    ctx->set_device_reset_callback = iris_set_device_reset_callback;
+   ctx->get_device_reset_status = iris_get_device_reset_status;
    ctx->get_sample_position = iris_get_sample_position;
 
    ice->shaders.urb_size = devinfo->urb.size;
@@ -232,7 +273,6 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
    iris_init_clear_functions(ctx);
    iris_init_program_functions(ctx);
    iris_init_resource_functions(ctx);
-   iris_init_query_functions(ctx);
    iris_init_flush_functions(ctx);
 
    iris_init_program_cache(ice);
@@ -254,6 +294,7 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
 
    genX_call(devinfo, init_state, ice);
    genX_call(devinfo, init_blorp, ice);
+   genX_call(devinfo, init_query, ice);
 
    int priority = 0;
    if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
@@ -261,9 +302,13 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
    if (flags & PIPE_CONTEXT_LOW_PRIORITY)
       priority = GEN_CONTEXT_LOW_PRIORITY;
 
+   if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
+      ice->state.sizes = _mesa_hash_table_u64_create(ice);
+
    for (int i = 0; i < IRIS_BATCH_COUNT; i++) {
       iris_init_batch(&ice->batches[i], screen, &ice->vtbl, &ice->dbg,
-                      &ice->reset, ice->batches, (enum iris_batch_name) i,
+                      &ice->reset, ice->state.sizes,
+                      ice->batches, (enum iris_batch_name) i,
                       I915_EXEC_RENDER, priority);
    }