<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Nov 11, 2018 at 3:35 PM Plamena Manolova <<a href="mailto:plamena.n.manolova@gmail.com">plamena.n.manolova@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Lowering shader variables which depend on the local work group<br>
size being available in nir_lower_system_values is only possible<br>
if the local work group size isn't variable, otherwise this should<br>
be handled by the native driver (if it supports<br>
ARB_compute_variable_group_size).<br>
<br>
Signed-off-by: Plamena Manolova <<a href="mailto:plamena.n.manolova@gmail.com" target="_blank">plamena.n.manolova@gmail.com</a>><br>
---<br>
src/compiler/nir/nir_lower_system_values.c | 22 ++++++++++++++++++++++<br>
1 file changed, 22 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c<br>
index bde7eb1180..6fdf9f9c51 100644<br>
--- a/src/compiler/nir/nir_lower_system_values.c<br>
+++ b/src/compiler/nir/nir_lower_system_values.c<br>
@@ -77,6 +77,15 @@ 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>
+<br>
+ /*<br>
+ * If the local work group size is variable we can't lower the global<br>
+ * invocation id here.<br></blockquote><div><br></div><div>Why not?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ */<br>
+ if (b->shader->info.cs.local_size_variable) {<br></blockquote><div><br></div><div>I didn't realize we'd added a bit for this. At one point in time, Karol
had patches which had it keyed off of the size being zero. Having a
separate bit is probably fine, it just surpised me.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ break;<br>
+ }<br>
+<br>
nir_ssa_def *group_size = build_local_group_size(b);<br>
nir_ssa_def *group_id = nir_load_work_group_id(b);<br>
nir_ssa_def *local_id = nir_load_local_invocation_id(b);<br>
@@ -115,6 +124,11 @@ convert_block(nir_block *block, nir_builder *b)<br>
}<br>
<br>
case SYSTEM_VALUE_LOCAL_GROUP_SIZE: {<br>
+ /* If the local work group size is variable we can't lower it here */<br>
+ if (b->shader->info.cs.local_size_variable) {<br>
+ break;<br>
+ }<br>
+<br>
sysval = build_local_group_size(b);<br>
break;<br>
}<br>
@@ -189,6 +203,14 @@ convert_block(nir_block *block, nir_builder *b)<br>
break;<br>
<br>
case SYSTEM_VALUE_GLOBAL_GROUP_SIZE: {<br>
+ /*<br>
+ * If the local work group size is variable we can't lower the global<br>
+ * group size here.<br>
+ */<br>
+ if (b->shader->info.cs.local_size_variable) {<br>
+ break;<br>
+ }<br></blockquote><div><br></div><div>Why can't we lower the global size? It seems like we would want the below multiplication regardless of whether the local size is constant.<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_size = build_local_group_size(b);<br>
nir_ssa_def *num_work_groups = nir_load_num_work_groups(b);<br>
sysval = nir_imul(b, group_size, num_work_groups);<br>
-- <br>
2.11.0<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></div>