<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 6, 2018 at 7:43 AM, Rob Clark <span dir="ltr"><<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>><br>
---<br>
I can't say for sure that this will work on all drivers, but it is<br>
what the blob driver does, and it seems to make deqp happy.  I could<br>
move this to it's own pass inside ir3, but that seemed like overkill<br>
<br>
 src/compiler/nir/nir.h                      | 10 ++++++++++<br>
 src/compiler/nir/nir_lower_<wbr>system_values.c  | 17 +++++++++++++++++<br>
 src/gallium/drivers/freedreno/<wbr>ir3/ir3_nir.c |  1 +<br>
 3 files changed, 28 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index 073ab4e82ea..de3d55d83af 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -1963,6 +1963,16 @@ typedef struct nir_shader_compiler_options {<br>
     */<br>
    bool lower_base_vertex;<br>
<br>
+   /**<br>
+    * If enabled, gl_HelperInvocation will be lowered as:<br>
+    *<br>
+    *   !((1 << gl_SampleID) & gl_SampleMaskIN[0]))<br></blockquote><div><br></div><div>This only works for multi-sampling.  What about the single-sampled case?</div><div><br></div><div>--Jason</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    *<br>
+    * TODO any hw w/ more than 32 samples?  For them (if they<br>
+    * used this option), a bit more math would be involved.<br>
+    */<br>
+   bool lower_helper_invocation;<br>
+<br>
    bool lower_cs_local_index_from_id;<br>
<br>
    bool lower_device_index_to_zero;<br>
diff --git a/src/compiler/nir/nir_lower_<wbr>system_values.c b/src/compiler/nir/nir_lower_<wbr>system_values.c<br>
index 487da042620..6668cbb5dcd 100644<br>
--- a/src/compiler/nir/nir_lower_<wbr>system_values.c<br>
+++ b/src/compiler/nir/nir_lower_<wbr>system_values.c<br>
@@ -136,6 +136,23 @@ convert_block(nir_block *block, nir_builder *b)<br>
                               nir_load_first_vertex(b));<br>
          break;<br>
<br>
+      case SYSTEM_VALUE_HELPER_<wbr>INVOCATION:<br>
+         if (b->shader->options->lower_<wbr>helper_invocation) {<br>
+            nir_ssa_def *tmp;<br>
+<br>
+            tmp = nir_ushr(b,<br>
+                           nir_imm_int(b, 1),<br>
+                           nir_load_sample_id(b));<br>
+<br>
+            tmp = nir_iand(b,<br>
+                           nir_load_sample_mask_in(b),<br>
+                           tmp);<br>
+<br>
+            sysval = nir_inot(b, nir_i2b(b, tmp));<br>
+         }<br>
+<br>
+         break;<br>
+<br>
       case SYSTEM_VALUE_INSTANCE_INDEX:<br>
          sysval = nir_iadd(b,<br>
                            nir_load_instance_id(b),<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
index cd1f9c526f2..341d990b269 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
@@ -51,6 +51,7 @@ static const nir_shader_compiler_options options = {<br>
                .lower_extract_byte = true,<br>
                .lower_extract_word = true,<br>
                .lower_all_io_to_temps = true,<br>
+               .lower_helper_invocation = true,<br>
 };<br>
<br>
 struct nir_shader *<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.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>