<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 2, 2017 at 4:07 PM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">WaFlushHangWhenNonPipelineStat<wbr>eAndMarkerStalled goes along<br>
with WaSampleOffsetIZ. Both recommends the same.<br>
<br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.<wbr>org</a><br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>context.h | 2 +<br>
src/mesa/drivers/dri/i965/brw_<wbr>defines.h | 1 +<br>
src/mesa/drivers/dri/i965/brw_<wbr>pipe_control.c | 54 ++++++++++++++++++++++<br>
src/mesa/drivers/dri/i965/<wbr>gen8_multisample_state.c | 8 ++++<br>
4 files changed, 65 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.h b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
index 92fc16de13..f0e8d562e9 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.h<br>
@@ -1647,6 +1647,8 @@ void brw_emit_post_sync_nonzero_<wbr>flush(struct brw_context *brw);<br>
void brw_emit_depth_stall_flushes(<wbr>struct brw_context *brw);<br>
void gen7_emit_vs_workaround_flush(<wbr>struct brw_context *brw);<br>
void gen7_emit_cs_stall_flush(<wbr>struct brw_context *brw);<br>
+void gen10_emit_wa_cs_stall_flush(<wbr>struct brw_context *brw);<br>
+void gen10_emit_wa_lri_to_cache_<wbr>mode_zero(struct brw_context *brw);<br>
<br>
/* brw_queryformat.c */<br>
void brw_query_internal_format(<wbr>struct gl_context *ctx, GLenum target,<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_defines.h b/src/mesa/drivers/dri/i965/<wbr>brw_defines.h<br>
index 4abb790612..270cdf29db 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_defines.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_defines.h<br>
@@ -1609,6 +1609,7 @@ enum brw_pixel_shader_coverage_<wbr>mask_mode {<br>
#define GEN7_GPGPU_DISPATCHDIMY 0x2504<br>
#define GEN7_GPGPU_DISPATCHDIMZ 0x2508<br>
<br>
+#define GEN7_CACHE_MODE_0 0x7000<br>
#define GEN7_CACHE_MODE_1 0x7004<br>
# define GEN9_FLOAT_BLEND_OPTIMIZATION_<wbr>ENABLE (1 << 4)<br>
# define GEN8_HIZ_NP_PMA_FIX_ENABLE (1 << 11)<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_pipe_control.c b/src/mesa/drivers/dri/i965/<wbr>brw_pipe_control.c<br>
index 460b8f73b6..6326957a7a 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_pipe_control.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_pipe_control.c<br>
@@ -278,6 +278,60 @@ gen7_emit_cs_stall_flush(<wbr>struct brw_context *brw)<br>
brw->workaround_bo, 0, 0);<br>
}<br>
<br>
+static void<br>
+brw_flush_write_caches(struct brw_context *brw) {<br>
+ brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_CACHE_FLUSH_BITS)<wbr>;<br>
+}<br>
+<br>
+static void<br>
+brw_flush_read_caches(struct brw_context *brw) {<br>
+ brw_emit_pipe_control_flush(<wbr>brw, PIPE_CONTROL_CACHE_INVALIDATE_<wbr>BITS);<br>
+}<br>
+<br>
+/**<br>
+ * From Gen10 Workarounds page in h/w specs:<br>
+ * WaSampleOffsetIZ:<br>
+ * Prior to the 3DSTATE_SAMPLE_PATTERN driver must ensure there are no<br>
+ * markers in the pipeline by programming a PIPE_CONTROL with stall.<br>
+ */<br>
+void<br>
+gen10_emit_wa_cs_stall_flush(<wbr>struct brw_context *brw)<br>
+{<br>
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;<br>
+ assert(devinfo->gen == 10);<br>
+ brw_emit_pipe_control_flush(<wbr>brw,<br>
+ PIPE_CONTROL_CS_STALL |<br>
+ PIPE_CONTROL_STALL_AT_<wbr>SCOREBOARD);<br>
+}<br>
+<br>
+/**<br>
+ * From Gen10 Workarounds page in h/w specs:<br>
+ * WaSampleOffsetIZ:<br>
+ * When 3DSTATE_SAMPLE_PATTERN is programmed, driver must then issue an<br>
+ * MI_LOAD_REGISTER_IMM command to an offset between 0x7000 and 0x7FFF(SVL)<br>
+ * after the command to ensure the state has been delivered prior to any<br>
+ * command causing a marker in the pipeline.<br>
+ */<br>
+void<br>
+gen10_emit_wa_lri_to_cache_<wbr>mode_zero(struct brw_context *brw)<br>
+{<br>
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;<br>
+ assert(devinfo->gen == 10);<br>
+<br>
+ /* Before changing the value of CACHE_MODE_0 register, GFX pipeline must<br>
+ * be idle; i.e., full flush is required.<br>
+ */<br>
+ brw_flush_write_caches(brw);<br>
+ brw_flush_read_caches(brw);<br></blockquote><div><br></div><div>If you do</div><div><br></div><div>brw_emit_pipe_control_flush(brw, PIPE_CONTROL_CACHE_FLUSH_BITS |</div><div> PIPE_CONTROL_CACHE_INVALIDATE_BITS)</div><div><br></div><div>It will automatically do both and insert a stall between them. What you have above, I don't think will actually every CS stall which appears to be required when changing CACHE_MODE_0</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ /* Write to CACHE_MODE_0 (0x7000) */<br>
+ BEGIN_BATCH(3);<br>
+ OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));<br>
+ OUT_BATCH(GEN7_CACHE_MODE_0);<br>
+ OUT_BATCH(0);<br></blockquote><div><br></div><div>I believe this won't actually change the register which is good. But is that sufficient for the workaround?<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ ADVANCE_BATCH();<br>
+}<br>
+<br>
/**<br>
* Emits a PIPE_CONTROL with a non-zero post-sync operation, for<br>
* implementing two workarounds on gen6. From section 1.4.7.1<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>gen8_multisample_state.c b/src/mesa/drivers/dri/i965/<wbr>gen8_multisample_state.c<br>
index 7a31a5df4a..14043025b6 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>gen8_multisample_state.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>gen8_multisample_state.c<br>
@@ -49,6 +49,11 @@ gen8_emit_3dstate_multisample(<wbr>struct brw_context *brw, unsigned num_samples)<br>
void<br>
gen8_emit_3dstate_sample_<wbr>pattern(struct brw_context *brw)<br>
{<br>
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;<br>
+<br>
+ if (devinfo->gen == 10)<br>
+ gen10_emit_wa_cs_stall_flush(<wbr>brw);<br>
+<br>
BEGIN_BATCH(9);<br>
OUT_BATCH(_3DSTATE_SAMPLE_<wbr>PATTERN << 16 | (9 - 2));<br>
<br>
@@ -68,4 +73,7 @@ gen8_emit_3dstate_sample_<wbr>pattern(struct brw_context *brw)<br>
/* 1x and 2x MSAA */<br>
OUT_BATCH(brw_multisample_<wbr>positions_1x_2x);<br>
ADVANCE_BATCH();<br>
+<br>
+ if (devinfo->gen == 10)<br>
+ gen10_emit_wa_lri_to_cache_<wbr>mode_zero(brw);<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.5<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>