compiler: Add two new system values for subgroups
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 30 Sep 2017 21:50:40 +0000 (14:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 7 Mar 2018 20:13:47 +0000 (12:13 -0800)
This will be required for SPIR-V subgroup support

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/compiler/nir/nir.c
src/compiler/nir/nir_intrinsics.h
src/compiler/shader_enums.c
src/compiler/shader_enums.h

index bdd8960403cd2be0c217ea01453aa114c4c854c3..f5fd1dc586b73edaa471bb7c8bcdc22d2db0bb20 100644 (file)
@@ -1969,6 +1969,10 @@ nir_intrinsic_from_system_value(gl_system_value val)
       return nir_intrinsic_load_subgroup_le_mask;
    case SYSTEM_VALUE_SUBGROUP_LT_MASK:
       return nir_intrinsic_load_subgroup_lt_mask;
+   case SYSTEM_VALUE_NUM_SUBGROUPS:
+      return nir_intrinsic_load_num_subgroups;
+   case SYSTEM_VALUE_SUBGROUP_ID:
+      return nir_intrinsic_load_subgroup_id;
    case SYSTEM_VALUE_LOCAL_GROUP_SIZE:
       return nir_intrinsic_load_local_group_size;
    default:
@@ -2040,6 +2044,10 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
       return SYSTEM_VALUE_SUBGROUP_LE_MASK;
    case nir_intrinsic_load_subgroup_lt_mask:
       return SYSTEM_VALUE_SUBGROUP_LT_MASK;
+   case nir_intrinsic_load_num_subgroups:
+      return SYSTEM_VALUE_NUM_SUBGROUPS;
+   case nir_intrinsic_load_subgroup_id:
+      return SYSTEM_VALUE_SUBGROUP_ID;
    case nir_intrinsic_load_local_group_size:
       return SYSTEM_VALUE_LOCAL_GROUP_SIZE;
    default:
index b8a673559001028abd30b213aef376abb5d2ab5d..1a816b46792a862ed7760b2d22c18080c8e6e87e 100644 (file)
@@ -381,6 +381,7 @@ SYSTEM_VALUE(subgroup_ge_mask, 0, 0, xx, xx, xx)
 SYSTEM_VALUE(subgroup_gt_mask, 0, 0, xx, xx, xx)
 SYSTEM_VALUE(subgroup_le_mask, 0, 0, xx, xx, xx)
 SYSTEM_VALUE(subgroup_lt_mask, 0, 0, xx, xx, xx)
+SYSTEM_VALUE(num_subgroups, 1, 0, xx, xx, xx)
 SYSTEM_VALUE(subgroup_id, 1, 0, xx, xx, xx)
 SYSTEM_VALUE(local_group_size, 3, 0, xx, xx, xx)
 
index 62c1ac1f0730afcea7e64febf790074a44de0a31..d0ff11b41e21b36af84b6d5bb3b0ab4d3a0b40e3 100644 (file)
@@ -210,6 +210,8 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_SUBGROUP_GT_MASK),
      ENUM(SYSTEM_VALUE_SUBGROUP_LE_MASK),
      ENUM(SYSTEM_VALUE_SUBGROUP_LT_MASK),
+     ENUM(SYSTEM_VALUE_NUM_SUBGROUPS),
+     ENUM(SYSTEM_VALUE_SUBGROUP_ID),
      ENUM(SYSTEM_VALUE_VERTEX_ID),
      ENUM(SYSTEM_VALUE_INSTANCE_ID),
      ENUM(SYSTEM_VALUE_INSTANCE_INDEX),
index 64fb68828ed808c8a78bed9d759db51883ae038c..2aedbb9b3fa4c3f744569fc681d126dfda951771 100644 (file)
@@ -397,6 +397,14 @@ typedef enum
    SYSTEM_VALUE_SUBGROUP_LT_MASK,
    /*@}*/
 
+   /**
+    * Builtin variables added by VK_KHR_subgroups
+    */
+   /*@{*/
+   SYSTEM_VALUE_NUM_SUBGROUPS,
+   SYSTEM_VALUE_SUBGROUP_ID,
+   /*@}*/
+
    /*@}*/
 
    /**