summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPlamena Manolova <[email protected]>2018-11-11 22:30:09 +0200
committerPlamena Manolova <[email protected]>2018-11-13 10:57:04 +0200
commitc5f3013cba2b11198643310386915c10d38377f7 (patch)
treebb94889e00ac58661b57d799b41021251f1025a2
parentefb1ccadca89b1b3f39fb52b7b83154dff764a15 (diff)
nir: Don't lower the local work group size if it's variable.
If the local work group size is variable it won't be available at compile time so we can't lower it in nir_lower_system_values(). Signed-off-by: Plamena Manolova <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Karol Herbst <[email protected]>
-rw-r--r--src/compiler/nir/nir_lower_system_values.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index bde7eb11801..fbc40573579 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -31,12 +31,24 @@
static nir_ssa_def*
build_local_group_size(nir_builder *b)
{
- nir_const_value local_size;
- memset(&local_size, 0, sizeof(local_size));
- local_size.u32[0] = b->shader->info.cs.local_size[0];
- local_size.u32[1] = b->shader->info.cs.local_size[1];
- local_size.u32[2] = b->shader->info.cs.local_size[2];
- return nir_build_imm(b, 3, 32, local_size);
+ nir_ssa_def *local_size;
+
+ /*
+ * If the local work group size is variable it can't be lowered at this
+ * point, but its intrinsic can still be used.
+ */
+ if (b->shader->info.cs.local_size_variable) {
+ local_size = nir_load_local_group_size(b);
+ } else {
+ nir_const_value local_size_const;
+ memset(&local_size_const, 0, sizeof(local_size_const));
+ local_size_const.u32[0] = b->shader->info.cs.local_size[0];
+ local_size_const.u32[1] = b->shader->info.cs.local_size[1];
+ local_size_const.u32[2] = b->shader->info.cs.local_size[2];
+ local_size = nir_build_imm(b, 3, 32, local_size_const);
+ }
+
+ return local_size;
}
static bool