summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarol Herbst <[email protected]>2018-07-11 02:42:03 +0200
committerKarol Herbst <[email protected]>2018-07-12 13:09:00 +0200
commit31cbcbdb873bc7437e02fbe7ba54b864245c7830 (patch)
tree98cb66731b201b48a5817748d496028547d022cc /src
parent529aa9e646333926fba9ba792ef77f0d04a4e6c8 (diff)
nir: move lowering of SYSTEM_VALUE_LOCAL_GROUP_SIZE into a function
we already have this code duplicated and we will need it for the global group size as well Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Karol Herbst <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_lower_system_values.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index f315b7ae96f..e8367981a5f 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -28,6 +28,17 @@
#include "nir.h"
#include "nir_builder.h"
+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);
+}
+
static bool
convert_block(nir_block *block, nir_builder *b)
{
@@ -66,19 +77,11 @@ convert_block(nir_block *block, nir_builder *b)
* "The value of gl_GlobalInvocationID is equal to
* gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID"
*/
-
- 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];
-
+ nir_ssa_def *group_size = build_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)),
- local_id);
+ sysval = nir_iadd(b, nir_imul(b, group_id, group_size), local_id);
break;
}
@@ -112,12 +115,7 @@ convert_block(nir_block *block, nir_builder *b)
}
case SYSTEM_VALUE_LOCAL_GROUP_SIZE: {
- 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];
- sysval = nir_build_imm(b, 3, 32, local_size);
+ sysval = build_local_group_size(b);
break;
}