nir/spirv: Handle the WorkgroupSize builtin decoration
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 1 Jun 2016 18:20:22 +0000 (11:20 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 4 Jun 2016 02:29:28 +0000 (19:29 -0700)
This fixes the 7 dEQP-VK.pipeline.spec_constant.compute.local_size.* tests
in the latest dev version of the Vulkan CTS.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/compiler/spirv/spirv_to_nir.c

index bb7aba4d9d45780a8da05a599f0360b191537b9e..cece645c6bc4fa6c65f9148a46c729f3baa0dabf 100644 (file)
@@ -931,6 +931,25 @@ get_specialization(struct vtn_builder *b, struct vtn_value *val,
    return const_value;
 }
 
+static void
+handle_workgroup_size_decoration_cb(struct vtn_builder *b,
+                                    struct vtn_value *val,
+                                    int member,
+                                    const struct vtn_decoration *dec,
+                                    void *data)
+{
+   assert(member == -1);
+   if (dec->decoration != SpvDecorationBuiltIn ||
+       dec->literals[0] != SpvBuiltInWorkgroupSize)
+      return;
+
+   assert(val->const_type == glsl_vector_type(GLSL_TYPE_UINT, 3));
+
+   b->shader->info.cs.local_size[0] = val->constant->value.u[0];
+   b->shader->info.cs.local_size[1] = val->constant->value.u[1];
+   b->shader->info.cs.local_size[2] = val->constant->value.u[2];
+}
+
 static void
 vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
                     const uint32_t *w, unsigned count)
@@ -1151,6 +1170,9 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
    default:
       unreachable("Unhandled opcode");
    }
+
+   /* Now that we have the value, update the workgroup size if needed */
+   vtn_foreach_decoration(b, val, handle_workgroup_size_decoration_cb, NULL);
 }
 
 static void