iris: Skip resolves and flushes altogether if unnecessary
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 11 Mar 2019 07:04:56 +0000 (00:04 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 22 Mar 2019 03:28:17 +0000 (20:28 -0700)
Improves drawoverhead baseline scores by 1.17x.

src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_draw.c
src/gallium/drivers/iris/iris_state.c

index 3cd03850e1bc62c39400346b46f5e48f2490fe48..494c931d0f0a627df96a7eceecaaa06356032d1b 100644 (file)
@@ -125,12 +125,15 @@ enum iris_param_domain {
 #define IRIS_DIRTY_VF_SGVS                  (1ull << 52)
 #define IRIS_DIRTY_VF                       (1ull << 53)
 #define IRIS_DIRTY_VF_TOPOLOGY              (1ull << 54)
+#define IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES  (1ull << 55)
+#define IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES (1ull << 56)
 
 #define IRIS_ALL_DIRTY_FOR_COMPUTE (IRIS_DIRTY_CS | \
                                     IRIS_DIRTY_SAMPLER_STATES_CS | \
                                     IRIS_DIRTY_UNCOMPILED_CS | \
                                     IRIS_DIRTY_CONSTANTS_CS | \
-                                    IRIS_DIRTY_BINDINGS_CS)
+                                    IRIS_DIRTY_BINDINGS_CS | \
+                                    IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES)
 
 #define IRIS_ALL_DIRTY_FOR_RENDER ~IRIS_ALL_DIRTY_FOR_COMPUTE
 
index 82a78145ecdc48688855c126fc2d0cde61e38028..ab162583ca9054d7f75d5d57a4597b70b7943c11 100644 (file)
@@ -133,14 +133,15 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
 
    iris_update_compiled_shaders(ice);
 
-   bool draw_aux_buffer_disabled[BRW_MAX_DRAW_BUFFERS] = { };
-   for (gl_shader_stage stage = 0; stage < MESA_SHADER_COMPUTE; stage++) {
-      if (ice->shaders.prog[stage]) {
-         iris_predraw_resolve_inputs(ice, batch, draw_aux_buffer_disabled,
-                                     stage, true);
+   if (ice->state.dirty & IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES) {
+      bool draw_aux_buffer_disabled[BRW_MAX_DRAW_BUFFERS] = { };
+      for (gl_shader_stage stage = 0; stage < MESA_SHADER_COMPUTE; stage++) {
+         if (ice->shaders.prog[stage])
+            iris_predraw_resolve_inputs(ice, batch, draw_aux_buffer_disabled,
+                                        stage, true);
       }
+      iris_predraw_resolve_framebuffer(ice, batch, draw_aux_buffer_disabled);
    }
-   iris_predraw_resolve_framebuffer(ice, batch, draw_aux_buffer_disabled);
 
    iris_binder_reserve_3d(ice);
 
@@ -215,8 +216,10 @@ iris_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info *grid)
    /* We can't do resolves on the compute engine, so awkwardly, we have to
     * do them on the render batch...
     */
-   iris_predraw_resolve_inputs(ice, &ice->batches[IRIS_BATCH_RENDER], NULL,
-                               MESA_SHADER_COMPUTE, false);
+   if (ice->state.dirty & IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES) {
+      iris_predraw_resolve_inputs(ice, &ice->batches[IRIS_BATCH_RENDER], NULL,
+                                  MESA_SHADER_COMPUTE, false);
+   }
 
    iris_batch_maybe_flush(batch, 1500);
 
index c16fa22b42b7c47cf2925a24a9fb21f257ce187d..e5f231158fcffa46714c539427c40fead760460b 100644 (file)
@@ -971,6 +971,7 @@ iris_bind_blend_state(struct pipe_context *ctx, void *state)
 
    ice->state.dirty |= IRIS_DIRTY_PS_BLEND;
    ice->state.dirty |= IRIS_DIRTY_BLEND_STATE;
+   ice->state.dirty |= IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
    ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_BLEND];
 }
 
@@ -1083,6 +1084,9 @@ iris_bind_zsa_state(struct pipe_context *ctx, void *state)
       if (cso_changed(alpha.func))
          ice->state.dirty |= IRIS_DIRTY_BLEND_STATE;
 
+      if (cso_changed(depth_writes_enabled))
+         ice->state.dirty |= IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
+
       ice->state.depth_writes_enabled = new_cso->depth_writes_enabled;
       ice->state.stencil_writes_enabled = new_cso->stencil_writes_enabled;
    }
@@ -1986,6 +1990,9 @@ iris_set_shader_images(struct pipe_context *ctx,
    }
 
    ice->state.dirty |= IRIS_DIRTY_BINDINGS_VS << stage;
+   ice->state.dirty |=
+      stage == MESA_SHADER_COMPUTE ? IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES
+                                   : IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
 
    /* Broadwell also needs brw_image_params re-uploaded */
    if (GEN_GEN < 9) {
@@ -2021,6 +2028,9 @@ iris_set_sampler_views(struct pipe_context *ctx,
    }
 
    ice->state.dirty |= (IRIS_DIRTY_BINDINGS_VS << stage);
+   ice->state.dirty |=
+      stage == MESA_SHADER_COMPUTE ? IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES
+                                   : IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
 }
 
 /**
@@ -2359,6 +2369,8 @@ iris_set_framebuffer_state(struct pipe_context *ctx,
    /* Render target change */
    ice->state.dirty |= IRIS_DIRTY_BINDINGS_FS;
 
+   ice->state.dirty |= IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES;
+
    ice->state.dirty |= ice->state.dirty_for_nos[IRIS_NOS_FRAMEBUFFER];
 
 #if GEN_GEN == 11