[Mesa-dev] [PATCH] i965: Perform manual preemption checks between commands

Chris Wilson chris at chris-wilson.co.uk
Tue Mar 5 09:39:17 UTC 2019


Not all commands support being preempted as they execute, and for those
make sure we at least check for being preempted before we start so as to
try and minimise the latency of whomever is more important than
ourselves.

Cc: Jari Tahvanainen <jari.tahvanainen at intel.com>,
Cc: Rafael Antognolli <rafael.antognolli at intel.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_defines.h | 1 +
 src/mesa/drivers/dri/i965/brw_draw.c    | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h
index 2729a54e144..ef71c556cca 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -1420,6 +1420,7 @@ enum brw_pixel_shader_coverage_mask_mode {
 
 #define MI_NOOP				(CMD_MI | 0)
 
+#define MI_ARB_CHECK			(CMD_MI | 0x5 << 23)
 #define MI_BATCH_BUFFER_END		(CMD_MI | 0xA << 23)
 
 #define MI_FLUSH			(CMD_MI | (4 << 23))
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index d07349419cc..49bb531ae7b 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -196,6 +196,13 @@ brw_emit_prim(struct brw_context *brw,
    if (verts_per_instance == 0 && !prim->is_indirect && !xfb_obj)
       return;
 
+   /* If this object is not itself preemptible, check before we begin. */
+   if (!brw->object_preemption) {
+      BEGIN_BATCH(3);
+      OUT_BATCH(MI_ARB_CHECK);
+      ADVANCE_BATCH();
+   }
+
    /* If we're set to always flush, do it before and after the primitive emit.
     * We want to catch both missed flushes that hurt instruction/state cache
     * and missed flushes of the render cache as it heads to other parts of
-- 
2.20.1



More information about the mesa-dev mailing list