[Mesa-dev] [PATCH 07/13] nir/vtn: handle WorkGroupSize for kernels

Rob Clark robdclark at gmail.com
Wed Feb 28 19:51:37 UTC 2018


Unlike glsl/vk compute shaders, this isn't a builtin constant.

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/compiler/spirv/spirv_to_nir.c  | 3 +++
 src/compiler/spirv/vtn_private.h   | 2 ++
 src/compiler/spirv/vtn_variables.c | 6 +++---
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index c6df764682e..e539d944302 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3054,6 +3054,9 @@ stage_for_execution_model(struct vtn_builder *b, SpvExecutionModel model)
       return MESA_SHADER_FRAGMENT;
    case SpvExecutionModelGLCompute:
       return MESA_SHADER_COMPUTE;
+   case SpvExecutionModelKernel:
+      b->kernel_mode = true;
+      return MESA_SHADER_COMPUTE;
    default:
       vtn_fail("Unsupported execution model");
    }
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 3e49df4dac8..0d0c7bcc43a 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -580,6 +580,8 @@ struct vtn_builder {
    unsigned func_param_idx;
 
    bool has_loop_continue;
+
+   bool kernel_mode;
 };
 
 nir_ssa_def *
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 84d2f4f1b57..62f0592690b 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1259,8 +1259,8 @@ vtn_get_builtin_location(struct vtn_builder *b,
       set_mode_system_value(b, mode);
       break;
    case SpvBuiltInWorkgroupSize:
-      /* This should already be handled */
-      vtn_fail("unsupported builtin");
+      *location = SYSTEM_VALUE_LOCAL_GROUP_SIZE;
+      set_mode_system_value(b, mode);
       break;
    case SpvBuiltInWorkgroupId:
       *location = SYSTEM_VALUE_WORK_GROUP_ID;
@@ -1341,7 +1341,7 @@ apply_var_decoration(struct vtn_builder *b, nir_variable *nir_var,
    case SpvDecorationBuiltIn: {
       SpvBuiltIn builtin = dec->literals[0];
 
-      if (builtin == SpvBuiltInWorkgroupSize) {
+      if ((builtin == SpvBuiltInWorkgroupSize) && !b->kernel_mode) {
          /* This shouldn't be a builtin.  It's actually a constant. */
          nir_var->data.mode = nir_var_global;
          nir_var->data.read_only = true;
-- 
2.14.3



More information about the mesa-dev mailing list