[Mesa-dev] [PATCH 31/51] i965: Refactor the always_flush check

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 10 21:23:54 UTC 2017


Provide a common routine for doing conditional batch flushes.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 src/mesa/drivers/dri/i965/brw_batch.h       | 6 ++++++
 src/mesa/drivers/dri/i965/brw_compute.c     | 3 +--
 src/mesa/drivers/dri/i965/brw_draw.c        | 3 +--
 src/mesa/drivers/dri/i965/genX_blorp_exec.c | 3 +--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_batch.h b/src/mesa/drivers/dri/i965/brw_batch.h
index 396e71306a..e9605cdb2f 100644
--- a/src/mesa/drivers/dri/i965/brw_batch.h
+++ b/src/mesa/drivers/dri/i965/brw_batch.h
@@ -223,6 +223,12 @@ brw_batch_reloc(brw_batch *batch,
 struct perf_debug;
 int brw_batch_flush(struct brw_batch *batch, struct perf_debug *info);
 
+inline static void brw_batch_maybe_flush(struct brw_batch *batch)
+{
+   if (unlikely(batch->always_flush))
+      brw_batch_flush(batch, NULL);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/drivers/dri/i965/brw_compute.c b/src/mesa/drivers/dri/i965/brw_compute.c
index 767e68eda1..cde63522d5 100644
--- a/src/mesa/drivers/dri/i965/brw_compute.c
+++ b/src/mesa/drivers/dri/i965/brw_compute.c
@@ -236,8 +236,7 @@ brw_dispatch_compute_common(struct gl_context *ctx)
     */
    brw_compute_state_finished(brw);
 
-   if (brw->batch.always_flush)
-      brw_batch_flush(&brw->batch, NULL);
+   brw_batch_maybe_flush(&brw->batch);
 
    brw_program_cache_check_size(brw);
 
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index a74cb61af5..eaa9f9173c 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -617,8 +617,7 @@ retry:
          brw_render_state_finished(brw);
    }
 
-   if (brw->batch.always_flush)
-      brw_batch_flush(&brw->batch, NULL);
+   brw_batch_maybe_flush(&brw->batch);
 
    brw_program_cache_check_size(brw);
    brw_postdraw_set_buffers_need_resolve(brw);
diff --git a/src/mesa/drivers/dri/i965/genX_blorp_exec.c b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
index ed0e08be04..e9a564135d 100644
--- a/src/mesa/drivers/dri/i965/genX_blorp_exec.c
+++ b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
@@ -231,8 +231,7 @@ retry:
       }
    }
 
-   if (unlikely(brw->always_flush_batch))
-      brw_batch_flush(&brw->batch, NULL);
+   brw_batch_maybe_flush(&brw->batch);
 
    /* We've smashed all state compared to what the normal 3D pipeline
     * rendering tracks for GL.
-- 
2.11.0



More information about the mesa-dev mailing list