From: Karol Herbst <kher...@redhat.com>

Signed-off-by: Rob Clark <robdcl...@gmail.com>
---
 src/compiler/nir/nir_lower_system_values.c | 8 ++++++++
 src/compiler/shader_enums.c                | 1 +
 src/compiler/shader_enums.h                | 2 ++
 src/compiler/spirv/vtn_variables.c         | 4 ++++
 4 files changed, 15 insertions(+)

diff --git a/src/compiler/nir/nir_lower_system_values.c 
b/src/compiler/nir/nir_lower_system_values.c
index 3594f4ae5ce..f458a87e5aa 100644
--- a/src/compiler/nir/nir_lower_system_values.c
+++ b/src/compiler/nir/nir_lower_system_values.c
@@ -133,6 +133,14 @@ convert_block(nir_block *block, nir_builder *b)
          break;
       }
 
+      case SYSTEM_VALUE_GLOBAL_SIZE: {
+         nir_ssa_def *group_size = nir_load_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;
       }
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index 2179c475abd..aa80e1fb6cf 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -234,6 +234,7 @@ gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
      ENUM(SYSTEM_VALUE_VIEW_INDEX),
      ENUM(SYSTEM_VALUE_VERTEX_CNT),
+     ENUM(SYSTEM_VALUE_GLOBAL_SIZE),
    };
    STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX);
    return NAME(sysval);
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index ac83c65b30c..69afb7dfac4 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -567,6 +567,8 @@ typedef enum
     */
    SYSTEM_VALUE_VERTEX_CNT,
 
+   SYSTEM_VALUE_GLOBAL_SIZE,
+
    SYSTEM_VALUE_MAX             /**< Number of values */
 } gl_system_value;
 
diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index 62f0592690b..9680d074131 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1294,6 +1294,10 @@ vtn_get_builtin_location(struct vtn_builder *b,
       *location = SYSTEM_VALUE_VIEW_INDEX;
       set_mode_system_value(b, mode);
       break;
+   case SpvBuiltInGlobalSize:
+      *location = SYSTEM_VALUE_GLOBAL_SIZE;
+      set_mode_system_value(b, mode);
+      break;
    default:
       vtn_fail("unsupported builtin");
    }
-- 
2.14.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to