iris: Add support for the always_flush_cache=true debug option.
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 8 Sep 2019 04:18:51 +0000 (21:18 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Sep 2019 18:55:27 +0000 (11:55 -0700)
This can be useful for debugging missing flushes.

src/gallium/drivers/iris/driinfo_iris.h
src/gallium/drivers/iris/iris_blorp.c
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_draw.c
src/gallium/drivers/iris/iris_pipe_control.c
src/gallium/drivers/iris/iris_screen.c
src/gallium/drivers/iris/iris_screen.h

index 8525001a84f8c6462c4db2a12336cd2e7897b6d2..a85a806b4f776e9acafe8b1c49f8808b4c79a03e 100644 (file)
@@ -3,6 +3,7 @@
 DRI_CONF_SECTION_DEBUG
    DRI_CONF_DUAL_COLOR_BLEND_BY_LOCATION("false")
    DRI_CONF_DISABLE_THROTTLING("false")
+   DRI_CONF_ALWAYS_FLUSH_CACHE("false")
 DRI_CONF_SECTION_END
 
 DRI_CONF_SECTION_PERFORMANCE
index 7aae5ea7002377d3a506ab84a2611dd0d64cebdd..f357b922e58983aeb43df80635f5319664cb9506 100644 (file)
@@ -313,8 +313,12 @@ iris_blorp_exec(struct blorp_batch *blorp_batch,
                               params->y1 - params->y0, scale);
    }
 
+   iris_handle_always_flush_cache(batch);
+
    blorp_exec(blorp_batch, params);
 
+   iris_handle_always_flush_cache(batch);
+
    /* We've smashed all state compared to what the normal 3D pipeline
     * rendering tracks for GL.
     */
index e3dc00fbf84ee44379d4a60b6582cc78a14251f4..08533039d81d43f4ff631857f98ecf8c027e0171 100644 (file)
@@ -800,6 +800,11 @@ void iris_emit_pipe_control_write(struct iris_batch *batch,
                                   uint64_t imm);
 void iris_emit_end_of_pipe_sync(struct iris_batch *batch,
                                 const char *reason, uint32_t flags);
+void iris_flush_all_caches(struct iris_batch *batch);
+
+#define iris_handle_always_flush_cache(batch) \
+   if (unlikely(batch->screen->driconf.always_flush_cache)) \
+      iris_flush_all_caches(batch);
 
 void iris_init_flush_functions(struct pipe_context *ctx);
 
index dc7fa98480267527ca6a5ae7837a4629aa93b985..caf5c002eecad4f57b6e8ede3c92d91a1a92c2e7 100644 (file)
@@ -241,11 +241,15 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 
    ice->vtbl.update_surface_base_address(batch, &ice->state.binder);
 
+   iris_handle_always_flush_cache(batch);
+
    if (info->indirect)
       iris_indirect_draw_vbo(ice, info);
    else
       iris_simple_draw_vbo(ice, info);
 
+   iris_handle_always_flush_cache(batch);
+
    iris_postdraw_update_resolve_tracking(ice, batch);
 
    ice->state.dirty &= ~IRIS_ALL_DIRTY_FOR_RENDER;
@@ -342,8 +346,12 @@ iris_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info *grid)
       ice->state.compute_predicate = NULL;
    }
 
+   iris_handle_always_flush_cache(batch);
+
    ice->vtbl.upload_compute_state(ice, batch, grid);
 
+   iris_handle_always_flush_cache(batch);
+
    ice->state.dirty &= ~IRIS_ALL_DIRTY_FOR_COMPUTE;
 
    /* Note: since compute shaders can't access the framebuffer, there's
index 4633ac11134d98abcbd6a016a95db0a3425af51a..75ec25a404d2578cb81195ccbdd0adcf0d413951 100644 (file)
@@ -151,6 +151,24 @@ iris_emit_end_of_pipe_sync(struct iris_batch *batch,
                                 batch->screen->workaround_bo, 0, 0);
 }
 
+/**
+ * Flush and invalidate all caches (for debugging purposes).
+ */
+void
+iris_flush_all_caches(struct iris_batch *batch)
+{
+   iris_emit_pipe_control_flush(batch, "debug: flush all caches",
+                                PIPE_CONTROL_CS_STALL |
+                                PIPE_CONTROL_DATA_CACHE_FLUSH |
+                                PIPE_CONTROL_DEPTH_CACHE_FLUSH |
+                                PIPE_CONTROL_RENDER_TARGET_FLUSH |
+                                PIPE_CONTROL_VF_CACHE_INVALIDATE |
+                                PIPE_CONTROL_INSTRUCTION_INVALIDATE |
+                                PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
+                                PIPE_CONTROL_CONST_CACHE_INVALIDATE |
+                                PIPE_CONTROL_STATE_CACHE_INVALIDATE);
+}
+
 static void
 iris_texture_barrier(struct pipe_context *ctx, unsigned flags)
 {
index 6833bc96c71b6e9f82a36249ab71dc34d373cde2..e09f4fe4423cc5a0455e8c06722a347e04fa28c5 100644 (file)
@@ -657,6 +657,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
       driQueryOptionb(config->options, "dual_color_blend_by_location");
    screen->driconf.disable_throttling =
       driQueryOptionb(config->options, "disable_throttling");
+   screen->driconf.always_flush_cache =
+      driQueryOptionb(config->options, "always_flush_cache");
 
    screen->precompile = env_var_as_boolean("shader_precompile", true);
 
index 817ef372c9467dd8e1af25633c12a3746b6d7b43..60ff15904a7cd948f42089ac4124847ec93ad320 100644 (file)
@@ -67,6 +67,7 @@ struct iris_screen {
       /** Dual color blend by location instead of index (for broken apps) */
       bool dual_color_blend_by_location;
       bool disable_throttling;
+      bool always_flush_cache;
    } driconf;
 
    unsigned subslice_total;