<div dir="ltr">I've updated the comments a bit and pushed to master.  Thanks for all your debugging!<br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 19, 2018 at 11:21 AM Sergii Romantsov <<a href="mailto:sergii.romantsov@gmail.com">sergii.romantsov@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Skylake enabling of ForceThreadDispatchEnable causes gpu-hang.<br>
<br>
-v2: enabling of  ForceThreadDispatchEnable is only for gen8, for<br>
     gen9 and higher reverted enabling of PixelShaderHasUAV.<br>
<br>
CC: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com" target="_blank">jason.ekstrand@intel.com</a>><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=107941" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=107941</a><br>
Fixes: 79270d2140ec (anv: Stop setting 3DSTATE_PS_EXTRA::PixelShaderHasUAV)<br>
Signed-off-by: Sergii Romantsov <<a href="mailto:sergii.romantsov@globallogic.com" target="_blank">sergii.romantsov@globallogic.com</a>><br>
---<br>
 src/intel/vulkan/genX_pipeline.c | 33 ++++++++++++++++++++++++++++++++-<br>
 1 file changed, 32 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c<br>
index 9595a71..b469270 100644<br>
--- a/src/intel/vulkan/genX_pipeline.c<br>
+++ b/src/intel/vulkan/genX_pipeline.c<br>
@@ -1445,7 +1445,7 @@ emit_3dstate_wm(struct anv_pipeline *pipeline, struct anv_subpass *subpass,<br>
             wm.EarlyDepthStencilControl         = EDSC_NORMAL;<br>
          }<br>
<br>
-#if GEN_GEN >= 8<br>
+#if GEN_GEN == 8<br>
          /* Gen8 hardware tries to compute ThreadDispatchEnable for us but<br>
           * doesn't take into account KillPixels when no depth or stencil<br>
           * writes are enabled.  In order for occlusion queries to work<br>
@@ -1663,6 +1663,37 @@ emit_3dstate_ps_extra(struct anv_pipeline *pipeline,<br>
                                          wm_prog_data->uses_kill;<br>
<br>
 #if GEN_GEN >= 9<br>
+      /* The stricter cross-primitive coherency guarantees that the hardware<br>
+       * gives us with the "Accesses UAV" bit set for at least one shader stage<br>
+       * and the "UAV coherency required" bit set on the 3DPRIMITIVE command are<br>
+       * redundant within the current image, atomic counter and SSBO GL APIs,<br>
+       * which all have very loose ordering and coherency requirements and<br>
+       * generally rely on the application to insert explicit barriers when a<br>
+       * shader invocation is expected to see the memory writes performed by the<br>
+       * invocations of some previous primitive.  Regardless of the value of<br>
+       * "UAV coherency required", the "Accesses UAV" bits will implicitly cause<br>
+       * an in most cases useless DC flush when the lowermost stage with the bit<br>
+       * set finishes execution.<br>
+       *<br>
+       * It would be nice to disable it, but in some cases we can't because on<br>
+       * Gen8+ it also has an influence on rasterization via the PS UAV-only<br>
+       * signal (which could be set independently from the coherency mechanism<br>
+       * in the 3DSTATE_WM command on Gen7), and because in some cases it will<br>
+       * determine whether the hardware skips execution of the fragment shader<br>
+       * or not via the ThreadDispatchEnable signal.  However if we know that<br>
+       * GEN8_PS_BLEND_HAS_WRITEABLE_RT is going to be set and<br>
+       * GEN8_PSX_PIXEL_SHADER_NO_RT_WRITE is not set it shouldn't make any<br>
+       * difference so we may just disable it here.<br>
+       *<br>
+       * Gen8 hardware tries to compute ThreadDispatchEnable for us but doesn't<br>
+       * take into account KillPixels when no depth or stencil writes are<br>
+       * enabled. In order for occlusion queries to work correctly with no<br>
+       * attachments, we need to force-enable here.<br>
+       */<br>
+      if ((wm_prog_data->has_side_effects || wm_prog_data->uses_kill) &&<br>
+          !has_color_buffer_write_enabled(pipeline, blend))<br>
+         ps.PixelShaderHasUAV = true;<br>
+<br>
       ps.PixelShaderComputesStencil = wm_prog_data->computed_stencil;<br>
       ps.PixelShaderPullsBary    = wm_prog_data->pulls_bary;<br>
<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>