<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 24, 2018 at 4:33 PM, Rafael Antognolli <span dir="ltr"><<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Similar to the GL driver, ignore 3DSTATE_CONSTANT_* packets when doing a<br>
context restore.<br>
<br>
Signed-off-by: Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>><br>
Cc: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
Cc: "18.0" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
---<br>
src/intel/vulkan/anv_private.h | 1 +<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 47 ++++++++++++++++++++++++++++++<wbr>++++++++<br>
2 files changed, 48 insertions(+)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index b351c6f63b3..a4c84d2c295 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -1458,6 +1458,7 @@ enum anv_pipe_bits {<br>
ANV_PIPE_CONSTANT_CACHE_<wbr>INVALIDATE_BIT = (1 << 3),<br>
ANV_PIPE_VF_CACHE_INVALIDATE_<wbr>BIT = (1 << 4),<br>
ANV_PIPE_DATA_CACHE_FLUSH_BIT = (1 << 5),<br>
+ ANV_PIPE_ISP_DISABLE_BIT = (1 << 9),<br></blockquote><div><br></div><div>Let's drop this if we're not going to use it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ANV_PIPE_TEXTURE_CACHE_<wbr>INVALIDATE_BIT = (1 << 10),<br>
ANV_PIPE_INSTRUCTION_CACHE_<wbr>INVALIDATE_BIT = (1 << 11),<br>
ANV_PIPE_RENDER_TARGET_CACHE_<wbr>FLUSH_BIT = (1 << 12),<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index c23a54fb7b9..7028c1ce9df 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -1008,6 +1008,50 @@ genX(BeginCommandBuffer)(<br>
return result;<br>
}<br>
<br>
+/**<br>
+ * From the PRM, Volume 2a:<br>
+ *<br>
+ * "Indirect State Pointers Disable<br>
+ *<br>
+ * At the completion of the post-sync operation associated with this pipe<br>
+ * control packet, the indirect state pointers in the hardware are<br>
+ * considered invalid; the indirect pointers are not saved in the context.<br>
+ * If any new indirect state commands are executed in the command stream<br>
+ * while the pipe control is pending, the new indirect state commands are<br>
+ * preserved.<br>
+ *<br>
+ * [DevIVB+]: Using Invalidate State Pointer (ISP) only inhibits context<br>
+ * restoring of Push Constant (3DSTATE_CONSTANT_*) commands. Push Constant<br>
+ * commands are only considered as Indirect State Pointers. Once ISP is<br>
+ * issued in a context, SW must initialize by programming push constant<br>
+ * commands for all the shaders (at least to zero length) before attempting<br>
+ * any rendering operation for the same context."<br>
+ *<br>
+ * 3DSTATE_CONSTANT_* packets are restored during a context restore,<br>
+ * even though they point to a BO that has been already unreferenced at<br>
+ * the end of the previous batch buffer. This has been fine so far since<br>
+ * we are protected by these scratch page (every address not covered by<br>
+ * a BO should be pointing to the scratch page). But on CNL, it is<br>
+ * causing a GPU hang during context restore at the 3DSTATE_CONSTANT_*<br>
+ * instruction.<br>
+ *<br>
+ * The flag "Indirect State Pointers Disable" in PIPE_CONTROL tells the<br>
+ * hardware to ignore previous 3DSTATE_CONSTANT_* packets during a<br>
+ * context restore, so the mentioned hang doesn't happen. However,<br>
+ * software must program push constant commands for all stages prior to<br>
+ * rendering anything, so we flag them as dirty.<br></blockquote><div><br></div><div>And... The next command buffer won't. I just looked at it and we won't set up push constants again until we use them. We could either set 3DSTATE_CONSTANT_* instead or we can make sure that push constants are flagged as dirty in BeginCommandBuffer.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ */<br>
+static void<br>
+emit_isp_disable(struct anv_cmd_buffer *cmd_buffer)<br>
+{<br>
+ anv_batch_emit(&cmd_buffer-><wbr>batch, GENX(PIPE_CONTROL), pc) {<br>
+ pc.<wbr>IndirectStatePointersDisable = true;<br>
+ pc.PostSyncOperation = WriteImmediateData;<br>
+ pc.Address =<br>
+ (struct anv_address) { &cmd_buffer->device-><wbr>workaround_bo, 0 };'<br></blockquote><div><br></div><div>Is the W/A BO write needed?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+}<br>
+<br>
VkResult<br>
genX(EndCommandBuffer)(<br>
VkCommandBuffer commandBuffer)<br>
@@ -1024,6 +1068,9 @@ genX(EndCommandBuffer)(<br>
<br>
genX(cmd_buffer_apply_pipe_<wbr>flushes)(cmd_buffer);<br>
<br>
+ if (GEN_GEN == 10)<br>
+ emit_isp_disable(cmd_buffer);<br>
+<br>
anv_cmd_buffer_end_batch_<wbr>buffer(cmd_buffer);<br>
<br>
return VK_SUCCESS;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>