summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_lower_system_values.c
diff options
context:
space:
mode:
authorJordan Justen <[email protected]>2016-05-22 15:54:48 -0700
committerJordan Justen <[email protected]>2016-06-01 19:29:02 -0700
commit6f316c9d8658e870b0140b0f601d35d1fcf133b9 (patch)
treed530843779c528c1dd9693032484610e8f25af74 /src/compiler/nir/nir_lower_system_values.c
parent7b9def35835232a10010f256b9c108219f97f752 (diff)
nir: Make lowering gl_LocalInvocationIndex optional
Cc: "12.0" <[email protected]> Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_lower_system_values.c')
-rw-r--r--src/compiler/nir/nir_lower_system_values.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c
index 8310e3831f4..3ca8e082c46 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -48,7 +48,7 @@ convert_block(nir_block *block, nir_builder *b)
b->cursor = nir_after_instr(&load_var->instr);
- nir_ssa_def *sysval;
+ nir_ssa_def *sysval = NULL;
switch (var->data.location) {
case SYSTEM_VALUE_GLOBAL_INVOCATION_ID: {
/* From the GLSL man page for gl_GlobalInvocationID:
@@ -74,6 +74,12 @@ convert_block(nir_block *block, nir_builder *b)
}
case SYSTEM_VALUE_LOCAL_INVOCATION_INDEX: {
+ /* If lower_cs_local_index_from_id is true, then we derive the local
+ * index from the local id.
+ */
+ if (!b->shader->options->lower_cs_local_index_from_id)
+ break;
+
/* From the GLSL man page for gl_LocalInvocationIndex:
*
* "The value of gl_LocalInvocationIndex is equal to
@@ -111,12 +117,14 @@ convert_block(nir_block *block, nir_builder *b)
nir_load_system_value(b, nir_intrinsic_load_base_instance, 0));
break;
- default: {
+ default:
+ break;
+ }
+
+ if (sysval == NULL) {
nir_intrinsic_op sysval_op =
nir_intrinsic_from_system_value(var->data.location);
sysval = nir_load_system_value(b, sysval_op, 0);
- break;
- } /* default */
}
nir_ssa_def_rewrite_uses(&load_var->dest.ssa, nir_src_for_ssa(sysval));