aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_opt_intrinsics.c
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2017-06-22 16:37:51 -0700
committerMatt Turner <[email protected]>2017-07-20 16:56:49 -0700
commit43ef75b394f1cd779a54a22fe16fbb5ef23f0458 (patch)
tree60122c01065572e95fa49b427d7a0cfbc6066542 /src/compiler/nir/nir_opt_intrinsics.c
parent636fe4d1c6b21e9efecd4bce1cedd67afa33343a (diff)
nir: Add system values from ARB_shader_ballot
We already had a channel_num system value, which I'm renaming to subgroup_invocation to match the rest of the new system values. Note that while ballotARB(true) will return zeros in the high 32-bits on systems where gl_SubGroupSizeARB <= 32, the gl_SubGroup??MaskARB variables do not consider whether channels are enabled. See issue (1) of ARB_shader_ballot. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opt_intrinsics.c')
-rw-r--r--src/compiler/nir/nir_opt_intrinsics.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_intrinsics.c b/src/compiler/nir/nir_opt_intrinsics.c
index bdb46e9300b..4f36166510b 100644
--- a/src/compiler/nir/nir_opt_intrinsics.c
+++ b/src/compiler/nir/nir_opt_intrinsics.c
@@ -62,6 +62,37 @@ opt_intrinsics_impl(nir_function_impl *impl)
replacement = nir_imm_int(&b, NIR_TRUE);
break;
}
+ case nir_intrinsic_load_subgroup_eq_mask:
+ case nir_intrinsic_load_subgroup_ge_mask:
+ case nir_intrinsic_load_subgroup_gt_mask:
+ case nir_intrinsic_load_subgroup_le_mask:
+ case nir_intrinsic_load_subgroup_lt_mask: {
+ if (!b.shader->options->lower_subgroup_masks)
+ break;
+
+ nir_ssa_def *count = nir_load_subgroup_invocation(&b);
+
+ switch (intrin->intrinsic) {
+ case nir_intrinsic_load_subgroup_eq_mask:
+ replacement = nir_ishl(&b, nir_imm_int64(&b, 1ull), count);
+ break;
+ case nir_intrinsic_load_subgroup_ge_mask:
+ replacement = nir_ishl(&b, nir_imm_int64(&b, ~0ull), count);
+ break;
+ case nir_intrinsic_load_subgroup_gt_mask:
+ replacement = nir_ishl(&b, nir_imm_int64(&b, ~1ull), count);
+ break;
+ case nir_intrinsic_load_subgroup_le_mask:
+ replacement = nir_inot(&b, nir_ishl(&b, nir_imm_int64(&b, ~1ull), count));
+ break;
+ case nir_intrinsic_load_subgroup_lt_mask:
+ replacement = nir_inot(&b, nir_ishl(&b, nir_imm_int64(&b, ~0ull), count));
+ break;
+ default:
+ unreachable("you seriously can't tell this is unreachable?");
+ }
+ break;
+ }
default:
break;
}