From 325e25d689baf0da56ed51c941c72a86e00ce10f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 7 Sep 2019 21:18:51 -0700 Subject: [PATCH] iris: Add support for the always_flush_cache=true debug option. This can be useful for debugging missing flushes. --- src/gallium/drivers/iris/driinfo_iris.h | 1 + src/gallium/drivers/iris/iris_blorp.c | 4 ++++ src/gallium/drivers/iris/iris_context.h | 5 +++++ src/gallium/drivers/iris/iris_draw.c | 8 ++++++++ src/gallium/drivers/iris/iris_pipe_control.c | 18 ++++++++++++++++++ src/gallium/drivers/iris/iris_screen.c | 2 ++ src/gallium/drivers/iris/iris_screen.h | 1 + 7 files changed, 39 insertions(+) diff --git a/src/gallium/drivers/iris/driinfo_iris.h b/src/gallium/drivers/iris/driinfo_iris.h index 8525001a84f..a85a806b4f7 100644 --- a/src/gallium/drivers/iris/driinfo_iris.h +++ b/src/gallium/drivers/iris/driinfo_iris.h @@ -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 diff --git a/src/gallium/drivers/iris/iris_blorp.c b/src/gallium/drivers/iris/iris_blorp.c index 7aae5ea7002..f357b922e58 100644 --- a/src/gallium/drivers/iris/iris_blorp.c +++ b/src/gallium/drivers/iris/iris_blorp.c @@ -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. */ diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index e3dc00fbf84..08533039d81 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -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); diff --git a/src/gallium/drivers/iris/iris_draw.c b/src/gallium/drivers/iris/iris_draw.c index dc7fa984802..caf5c002eec 100644 --- a/src/gallium/drivers/iris/iris_draw.c +++ b/src/gallium/drivers/iris/iris_draw.c @@ -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 diff --git a/src/gallium/drivers/iris/iris_pipe_control.c b/src/gallium/drivers/iris/iris_pipe_control.c index 4633ac11134..75ec25a404d 100644 --- a/src/gallium/drivers/iris/iris_pipe_control.c +++ b/src/gallium/drivers/iris/iris_pipe_control.c @@ -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) { diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 6833bc96c71..e09f4fe4423 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -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); diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h index 817ef372c94..60ff15904a7 100644 --- a/src/gallium/drivers/iris/iris_screen.h +++ b/src/gallium/drivers/iris/iris_screen.h @@ -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; -- 2.30.2