summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-12-14 20:33:46 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2015-12-15 10:20:23 -0800
commit2d4b7eda23c04ac7b4b4ec155d7100abcb74ea86 (patch)
tree11cd0b50c5ada9373d491ff0c48157a6cffa286f /src
parent1035108a7f5ed2fc3698c3e9a0934d1bd0ab104b (diff)
downloadexternal_mesa3d-2d4b7eda23c04ac7b4b4ec155d7100abcb74ea86.zip
external_mesa3d-2d4b7eda23c04ac7b4b4ec155d7100abcb74ea86.tar.gz
external_mesa3d-2d4b7eda23c04ac7b4b4ec155d7100abcb74ea86.tar.bz2
nir/spirv: Add support for more CS intrinsics
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/spirv_to_nir.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c
index a8f3016..6fe68f9 100644
--- a/src/glsl/nir/spirv_to_nir.c
+++ b/src/glsl/nir/spirv_to_nir.c
@@ -818,14 +818,12 @@ vtn_get_builtin_location(struct vtn_builder *b,
assert(*mode == nir_var_shader_out);
break;
case SpvBuiltInNumWorkgroups:
+ *location = SYSTEM_VALUE_NUM_WORK_GROUPS;
+ set_mode_system_value(mode);
case SpvBuiltInWorkgroupSize:
- /* these are constants, need to be handled specially */
+ /* This should already be handled */
unreachable("unsupported builtin");
break;
- case SpvBuiltInGlobalInvocationId:
- case SpvBuiltInLocalInvocationIndex:
- /* these are computed values, need to be handled specially */
- unreachable("unsupported builtin");
case SpvBuiltInWorkgroupId:
*location = SYSTEM_VALUE_WORK_GROUP_ID;
set_mode_system_value(mode);
@@ -834,6 +832,14 @@ vtn_get_builtin_location(struct vtn_builder *b,
*location = SYSTEM_VALUE_LOCAL_INVOCATION_ID;
set_mode_system_value(mode);
break;
+ case SpvBuiltInLocalInvocationIndex:
+ *location = SYSTEM_VALUE_LOCAL_INVOCATION_INDEX;
+ set_mode_system_value(mode);
+ break;
+ case SpvBuiltInGlobalInvocationId:
+ *location = SYSTEM_VALUE_GLOBAL_INVOCATION_ID;
+ set_mode_system_value(mode);
+ break;
case SpvBuiltInHelperInvocation:
default:
unreachable("unsupported builtin");
@@ -894,6 +900,19 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
case SpvDecorationBuiltIn: {
SpvBuiltIn builtin = dec->literals[0];
+ if (builtin == SpvBuiltInWorkgroupSize) {
+ /* This shouldn't be a builtin. It's actually a constant. */
+ var->data.mode = nir_var_global;
+ var->data.read_only = true;
+
+ nir_constant *val = ralloc(var, nir_constant);
+ val->value.u[0] = b->shader->info.cs.local_size[0];
+ val->value.u[1] = b->shader->info.cs.local_size[1];
+ val->value.u[2] = b->shader->info.cs.local_size[2];
+ var->constant_initializer = val;
+ break;
+ }
+
nir_variable_mode mode = var->data.mode;
vtn_get_builtin_location(b, builtin, &var->data.location, &mode);
var->data.explicit_location = true;