summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2017-06-01 19:20:45 -0700
committerConnor Abbott <cwabbott0@gmail.com>2017-06-08 17:23:15 -0700
commit81cb276e5a01e425f9b5c938bed3420292a0c8d9 (patch)
treec23ec6b0068f94bc6611e28e0f1737545e1bacf6
parente861c155c8c7b0c966318d28f035ca4e839fbc66 (diff)
nir: add ARB_shader_ballot and ARB_shader_group_vote instructionsnir-divergence-v3
v2: make every instruction an intrinsic, add missing subgroup_size, also add system value translation stuff
-rw-r--r--src/compiler/nir/nir.c28
-rw-r--r--src/compiler/nir/nir.h3
-rw-r--r--src/compiler/nir/nir_intrinsics.h30
3 files changed, 61 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 491b908396..266ca6d1be 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1864,6 +1864,20 @@ nir_intrinsic_op
nir_intrinsic_from_system_value(gl_system_value val)
{
switch (val) {
+ case SYSTEM_VALUE_SUBGROUP_SIZE:
+ return nir_intrinsic_load_subgroup_size;
+ case SYSTEM_VALUE_SUBGROUP_INVOCATION:
+ return nir_intrinsic_load_subgroup_invocation;
+ case SYSTEM_VALUE_SUBGROUP_EQ_MASK:
+ return nir_intrinsic_load_subgroup_eq_mask;
+ case SYSTEM_VALUE_SUBGROUP_GE_MASK:
+ return nir_intrinsic_load_subgroup_ge_mask;
+ case SYSTEM_VALUE_SUBGROUP_GT_MASK:
+ return nir_intrinsic_load_subgroup_gt_mask;
+ case SYSTEM_VALUE_SUBGROUP_LE_MASK:
+ return nir_intrinsic_load_subgroup_le_mask;
+ case SYSTEM_VALUE_SUBGROUP_LT_MASK:
+ return nir_intrinsic_load_subgroup_lt_mask;
case SYSTEM_VALUE_VERTEX_ID:
return nir_intrinsic_load_vertex_id;
case SYSTEM_VALUE_INSTANCE_ID:
@@ -1917,6 +1931,20 @@ gl_system_value
nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
{
switch (intrin) {
+ case nir_intrinsic_load_subgroup_size:
+ return SYSTEM_VALUE_SUBGROUP_SIZE;
+ case nir_intrinsic_load_subgroup_invocation:
+ return SYSTEM_VALUE_SUBGROUP_INVOCATION;
+ case nir_intrinsic_load_subgroup_eq_mask:
+ return SYSTEM_VALUE_SUBGROUP_EQ_MASK;
+ case nir_intrinsic_load_subgroup_ge_mask:
+ return SYSTEM_VALUE_SUBGROUP_GE_MASK;
+ case nir_intrinsic_load_subgroup_gt_mask:
+ return SYSTEM_VALUE_SUBGROUP_GT_MASK;
+ case nir_intrinsic_load_subgroup_le_mask:
+ return SYSTEM_VALUE_SUBGROUP_LE_MASK;
+ case nir_intrinsic_load_subgroup_lt_mask:
+ return SYSTEM_VALUE_SUBGROUP_LT_MASK;
case nir_intrinsic_load_vertex_id:
return SYSTEM_VALUE_VERTEX_ID;
case nir_intrinsic_load_instance_id:
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 64caccb621..f87e1c27c9 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1920,6 +1920,9 @@ typedef struct nir_shader_compiler_options {
bool use_interpolated_input_intrinsics;
unsigned max_unroll_iterations;
+
+ /* Number of channels in a subgroup. */
+ unsigned subgroup_size;
} nir_shader_compiler_options;
typedef struct nir_shader {
diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index 21e7d904b7..62e488428c 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -331,6 +331,36 @@ SYSTEM_VALUE(alpha_ref_float, 1, 0, xx, xx, xx)
SYSTEM_VALUE(layer_id, 1, 0, xx, xx, xx)
SYSTEM_VALUE(view_index, 1, 0, xx, xx, xx)
+
+/* ARB_shader_ballot instructions */
+
+SYSTEM_VALUE(subgroup_size, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_invocation, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_eq_mask, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_ge_mask, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_gt_mask, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_le_mask, 1, 0, xx, xx, xx)
+SYSTEM_VALUE(subgroup_lt_mask, 1, 0, xx, xx, xx)
+
+#define CROSS_THREAD(name, dest_components, src_components) \
+ INTRINSIC(name, 1, ARR(src_components), true, dest_components, 0, 0, \
+ xx, xx, xx, \
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER | \
+ NIR_INTRINSIC_CROSS_THREAD)
+
+CROSS_THREAD(ballot, 0, 0)
+INTRINSIC(read_invocation, 2, ARR(0, 1), true, 0, 0, 0,
+ xx, xx, xx,
+ NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER |
+ NIR_INTRINSIC_CROSS_THREAD)
+CROSS_THREAD(read_first_invocation, 0, 0)
+
+/* ARB_shader_group_vote instructions */
+
+CROSS_THREAD(any_invocations, 1, 1)
+CROSS_THREAD(all_invocations, 1, 1)
+CROSS_THREAD(all_invocations_equal, 1, 1)
+
/* Blend constant color values. Float values are clamped. */
SYSTEM_VALUE(blend_const_color_r_float, 1, 0, xx, xx, xx)
SYSTEM_VALUE(blend_const_color_g_float, 1, 0, xx, xx, xx)