<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 23, 2018 at 12:33 PM, Karol Herbst <span dir="ltr"><<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Rob Clark <<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>><br>
<br>
If local_size is not known at compile time, which is the case with<br>
clover, use the load_local_group_size intrinsic instead.<br>
<br>
Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
---<br>
 src/compiler/nir/nir_lower_sy<wbr>stem_values.c | 25 +++++++++++++++++--------<br>
 1 file changed, 17 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_s<wbr>ystem_values.c b/src/compiler/nir/nir_lower_s<wbr>ystem_values.c<br>
index d507c28f421..ff4e09c8e61 100644<br>
--- a/src/compiler/nir/nir_lower_s<wbr>ystem_values.c<br>
+++ b/src/compiler/nir/nir_lower_s<wbr>ystem_values.c<br>
@@ -57,19 +57,28 @@ convert_block(nir_block *block, nir_builder *b)<br>
           *    "The value of gl_GlobalInvocationID is equal to<br>
           *    gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID"<br>
           */<br>
+         nir_ssa_def *local_size_def;<br>
<br>
-         nir_const_value local_size;<br>
-         memset(&local_size, 0, sizeof(local_size));<br>
-         local_size.u64[0] = b->shader->info.cs.local_size[<wbr>0];<br>
-         local_size.u64[1] = b->shader->info.cs.local_size[<wbr>1];<br>
-         local_size.u64[2] = b->shader->info.cs.local_size[<wbr>2];<br>
+         /* if local_size[] is already known, use that, otherwise use<br>
+          * load_local_group_size intrinsic:<br>
+          */<br>
+         if (b->shader->info.cs.local_size<wbr>[0]) {<br>
+            nir_const_value local_size;<br>
+            memset(&local_size, 0, sizeof(local_size));<br>
+            local_size.u64[0] = b->shader->info.cs.local_size[<wbr>0];<br>
+            local_size.u64[1] = b->shader->info.cs.local_size[<wbr>1];<br>
+            local_size.u64[2] = b->shader->info.cs.local_size[<wbr>2];<br>
+<br>
+            local_size_def = nir_build_imm(b, 3, bit_size, local_size); </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+         } else {<br>
+            local_size_def = nir_load_local_group_size(b, bit_size);<br>
+         }<br></blockquote><div><br></div><div>I commented on an earlier patch about how the approach to building the 32/64-bit immediates is wrong.<br><br></div><div>Setting that aside, this patch looks fine to me in principal.  There's a part of me that doesn't like using cs.local_size[0] being the trigger but I think it's probably ok.  Maybe we should assert that cs_local_size is either all zero (second case) or all not zero (first case) just to be safe.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
          nir_ssa_def *group_id = nir_load_work_group_id(b, bit_size);<br>
          nir_ssa_def *local_id = nir_load_local_invocation_id(b<wbr>, bit_size);<br>
<br>
-         sysval = nir_iadd(b, nir_imul(b, group_id,<br>
-                                       nir_build_imm(b, 3, bit_size, local_size)),<br>
-                              local_id);<br>
+         sysval = nir_iadd(b, nir_imul(b, group_id, local_size_def),<br>
+                           local_id);<br>
          break;<br>
       }<br>
<span class="m_2059378228461333298HOEnZb"><font color="#888888"><br>
--<br>
2.14.3<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>