<div dir="ltr"><div>Sounds like a plan.<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 16, 2017 at 12:37 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We want to emit invariant state at the start of a render batch.  In the<br>
past, this more or less happened: a new batch flagged BRW_NEW_CONTEXT<br>
(because we don't have hardware contexts), which triggered the<br>
brw_invariant_state atom.  So, it would be emitted before any 3D<br>
drawing.  (Technically, there might be some BLT commands in the batch<br>
because Gen4-5 have a single combined render/BLT ring, but that should<br>
be harmless).<br>
<br>
With the advent of BLORP, this broke.  The first item in a batch might<br>
be a BLORP operation, which bypasses the normal draw upload path.  So,<br>
we need to ensure invariant state happens first.  To do that, we just<br>
upload it when creating a new batch.  On Gen6+ we'd need to worry about<br>
whether it's a RENDER or BLT batch, but because we have a combined ring,<br>
this approach should work fine on Gen4-5.<br>
<br>
Seems to fix GPU hangs when playing hardware accelerated video with<br>
mpv -hwdec=vaapi on Ironlake.<br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=103529" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=103529</a><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>misc_state.c    | 9 ---------<br>
 src/mesa/drivers/dri/i965/brw_<wbr>state.h         | 1 -<br>
 src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c | 2 --<br>
 src/mesa/drivers/dri/i965/<wbr>intel_batchbuffer.c | 4 +++-<br>
 4 files changed, 3 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
index fd96485d574..94d5c9783db 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_misc_state.c<br>
@@ -560,15 +560,6 @@ brw_upload_invariant_state(<wbr>struct brw_context *brw)<br>
    ADVANCE_BATCH();<br>
 }<br>
<br>
-const struct brw_tracked_state brw_invariant_state = {<br>
-   .dirty = {<br>
-      .mesa = 0,<br>
-      .brw = BRW_NEW_BLORP |<br>
-             BRW_NEW_CONTEXT,<br>
-   },<br>
-   .emit = brw_upload_invariant_state<br>
-};<br>
-<br>
 /**<br>
  * Define the base addresses which some state is referenced from.<br>
  *<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_state.h b/src/mesa/drivers/dri/i965/<wbr>brw_state.h<br>
index cf13eca3438..ad508950f78 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_state.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_state.h<br>
@@ -51,7 +51,6 @@ extern const struct brw_tracked_state brw_wm_pull_constants;<br>
 extern const struct brw_tracked_state brw_cs_pull_constants;<br>
 extern const struct brw_tracked_state brw_constant_buffer;<br>
 extern const struct brw_tracked_state brw_curbe_offsets;<br>
-extern const struct brw_tracked_state brw_invariant_state;<br>
 extern const struct brw_tracked_state brw_binding_table_pointers;<br>
 extern const struct brw_tracked_state brw_depthbuffer;<br>
 extern const struct brw_tracked_state brw_recalculate_urb_fence;<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c b/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
index d4b0de850c9..112f48181b0 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
@@ -5366,8 +5366,6 @@ genX(init_atoms)(struct brw_context *brw)<br>
<br>
       /* Command packets:<br>
        */<br>
-      &brw_invariant_state,<br>
-<br>
       &brw_binding_table_pointers,<br>
       &genX(blend_constant_color),<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_batchbuffer.c b/src/mesa/drivers/dri/i965/<wbr>intel_batchbuffer.c<br>
index bbe13f34cef..3412b1d0a5f 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_batchbuffer.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_batchbuffer.c<br>
@@ -601,8 +601,10 @@ brw_new_batch(struct brw_context *brw)<br>
     * would otherwise be stored in the context (which for all intents and<br>
     * purposes means everything).<br>
     */<br>
-   if (brw->hw_ctx == 0)<br>
+   if (brw->hw_ctx == 0) {<br>
       brw->ctx.NewDriverState |= BRW_NEW_CONTEXT;<br>
+      brw_upload_invariant_state(<wbr>brw);<br>
+   }<br>
<br>
    brw->ctx.NewDriverState |= BRW_NEW_BATCH;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.15.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>