[Mesa-dev] [PATCH v2 12/18] nir: use load_local_group_size
Karol Herbst
kherbst at redhat.com
Thu Mar 8 15:25:58 UTC 2018
From: Rob Clark <robdclark at gmail.com>
If local_size is not known at compile time, which is the case with
clover, use the load_local_group_size intrinsic instead.
Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
src/compiler/nir/nir_lower_system_values.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 200b876901..1b8b015917 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -56,18 +56,27 @@ convert_block(nir_block *block, nir_builder *b)
* "The value of gl_GlobalInvocationID is equal to
* gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID"
*/
+ nir_ssa_def *local_size_def;
- 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];
+ /* if local_size[] is already known, use that, otherwise use
+ * load_local_group_size intrinsic:
+ */
+ if (b->shader->info.cs.local_size[0]) {
+ 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];
+
+ local_size_def = nir_build_imm(b, 3, 32, local_size);
+ } else {
+ local_size_def = nir_load_local_group_size(b);
+ }
nir_ssa_def *group_id = nir_load_work_group_id(b);
nir_ssa_def *local_id = nir_load_local_invocation_id(b);
- sysval = nir_iadd(b, nir_imul(b, group_id,
- nir_build_imm(b, 3, 32, local_size)),
+ sysval = nir_iadd(b, nir_imul(b, group_id, local_size_def),
local_id);
break;
}
--
2.14.3
More information about the mesa-dev
mailing list