From: Karol Herbst Date: Thu, 22 Feb 2018 22:35:50 +0000 (+0100) Subject: nir/spirv: implement BuiltInGlobalSize X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=154ef32e4633b9aa4eafc8c41e818943fe129630;p=mesa.git nir/spirv: implement BuiltInGlobalSize Reviewed-by: Jason Ekstrand Signed-off-by: Karol Herbst --- diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c index e8367981a5f..da04895d66c 100644 --- a/src/compiler/nir/nir_lower_system_values.c +++ b/src/compiler/nir/nir_lower_system_values.c @@ -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; } diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c index 0f3b1acae7a..4eade256604 100644 --- a/src/compiler/shader_enums.c +++ b/src/compiler/shader_enums.c @@ -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), diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 1ef4d5a33d0..280bf1d2835 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -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 */ diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index b7c9e6f2f70..c86416495b6 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -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"); }