nir/spirv: implement BuiltInGlobalSize
authorKarol Herbst <kherbst@redhat.com>
Thu, 22 Feb 2018 22:35:50 +0000 (23:35 +0100)
committerKarol Herbst <kherbst@redhat.com>
Thu, 12 Jul 2018 11:09:00 +0000 (13:09 +0200)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
src/compiler/nir/nir_lower_system_values.c
src/compiler/shader_enums.c
src/compiler/shader_enums.h
src/compiler/spirv/vtn_variables.c

index e8367981a5fa29fb0dc5d5b4fa57f925c08a7849..da04895d66cc4ff7f2a63f5c922810816fa78088 100644 (file)
@@ -171,6 +171,13 @@ convert_block(nir_block *block, nir_builder *b)
             sysval = nir_imm_int(b, 0);
          break;
 
+      case SYSTEM_VALUE_GLOBAL_GROUP_SIZE: {
+         nir_ssa_def *group_size = build_local_group_size(b);
+         nir_ssa_def *num_work_groups = nir_load_num_work_groups(b);
+         sysval = nir_imul(b, group_size, num_work_groups);
+         break;
+      }
+
       default:
          break;
       }
index 0f3b1acae7a69d800c76086bca67a6b06a9d3f11..4eade256604e9bffff5112e15ffdd49f75606d84 100644 (file)
@@ -239,6 +239,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
      ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
      ENUM(SYSTEM_VALUE_LOCAL_GROUP_SIZE),
+     ENUM(SYSTEM_VALUE_GLOBAL_GROUP_SIZE),
      ENUM(SYSTEM_VALUE_DEVICE_INDEX),
      ENUM(SYSTEM_VALUE_VIEW_INDEX),
      ENUM(SYSTEM_VALUE_VERTEX_CNT),
index 1ef4d5a33d0e08f8c6f436e5ac4e153fe031fea2..280bf1d2835a687e518c59aa89ef5b190e340ae9 100644 (file)
@@ -585,6 +585,7 @@ typedef enum
    SYSTEM_VALUE_WORK_GROUP_ID,
    SYSTEM_VALUE_NUM_WORK_GROUPS,
    SYSTEM_VALUE_LOCAL_GROUP_SIZE,
+   SYSTEM_VALUE_GLOBAL_GROUP_SIZE,
    /*@}*/
 
    /** Required for VK_KHR_device_group */
index b7c9e6f2f706a2d5cb8dfc6782f1fac79769dc1e..c86416495b61005548a1b1346963c2ba5e19ffa8 100644 (file)
@@ -1208,6 +1208,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
       *location = FRAG_RESULT_STENCIL;
       vtn_assert(*mode == nir_var_shader_out);
       break;
+   case SpvBuiltInGlobalSize:
+      *location = SYSTEM_VALUE_GLOBAL_GROUP_SIZE;
+      set_mode_system_value(b, mode);
+      break;
    default:
       vtn_fail("unsupported builtin");
    }