summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-04-10 23:43:34 -0700
committerJason Ekstrand <[email protected]>2016-04-10 23:43:38 -0700
commit3aa1a5ee8841fa93da5617630601e8110d428e8a (patch)
treef7084fcb8d956b2131691b580d913c456f922d8a
parentbff7a8c4f343a67149e6a6854e0597696b3d4b03 (diff)
nir/lower_system_values: Simplify the computation of LocalInvocationIndex
-rw-r--r--src/compiler/nir/nir_lower_system_values.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index c1cd1398aa1..2d3ccd7d0f9 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -83,7 +83,7 @@ convert_block(nir_block *block, void *void_state)
case SYSTEM_VALUE_LOCAL_INVOCATION_INDEX: {
/* From the GLSL man page for gl_LocalInvocationIndex:
*
- * ?The value of gl_LocalInvocationIndex is equal to
+ * "The value of gl_LocalInvocationIndex is equal to
* gl_LocalInvocationID.z * gl_WorkGroupSize.x *
* gl_WorkGroupSize.y + gl_LocalInvocationID.y *
* gl_WorkGroupSize.x + gl_LocalInvocationID.x"
@@ -91,15 +91,14 @@ convert_block(nir_block *block, void *void_state)
nir_ssa_def *local_id =
nir_load_system_value(b, nir_intrinsic_load_local_invocation_id, 0);
- unsigned stride_y = b->shader->info.cs.local_size[0];
- unsigned stride_z = b->shader->info.cs.local_size[0] *
- b->shader->info.cs.local_size[1];
+ nir_ssa_def *size_x = nir_imm_int(b, b->shader->info.cs.local_size[0]);
+ nir_ssa_def *size_y = nir_imm_int(b, b->shader->info.cs.local_size[1]);
- sysval = nir_iadd(b, nir_imul(b, nir_channel(b, local_id, 2),
- nir_imm_int(b, stride_z)),
- nir_iadd(b, nir_imul(b, nir_channel(b, local_id, 1),
- nir_imm_int(b, stride_y)),
- nir_channel(b, local_id, 0)));
+ sysval = nir_imul(b, nir_channel(b, local_id, 2),
+ nir_imul(b, size_x, size_y));
+ sysval = nir_iadd(b, sysval,
+ nir_imul(b, nir_channel(b, local_id, 1), size_x));
+ sysval = nir_iadd(b, sysval, nir_channel(b, local_id, 0));
break;
}