nir/spirv: Fix group decorations
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 2 Jan 2016 19:51:40 +0000 (11:51 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 2 Jan 2016 19:53:36 +0000 (11:53 -0800)
They were completely bogus before.  For one thing, OpDecorationGroup
created a value of type undef rather than decoration_group.  Also
OpGroupMemberDecorate didn't properly apply the decoration to the different
members of the different groups.  It *should* be correct now but there's no
good way to test it yet.

src/glsl/nir/spirv/spirv_to_nir.c

index 681adc74d1f4173ab002e9d6ea1e79d37a1b2f34..3a8949438f49f697478353bf5c97f59a977926e7 100644 (file)
@@ -298,7 +298,7 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
 
    switch (opcode) {
    case SpvOpDecorationGroup:
-      vtn_push_value(b, target, vtn_value_type_undef);
+      vtn_push_value(b, target, vtn_value_type_decoration_group);
       break;
 
    case SpvOpDecorate:
@@ -331,21 +331,19 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
 
    case SpvOpGroupMemberDecorate:
    case SpvOpGroupDecorate: {
-      struct vtn_value *group = &b->values[target];
-      assert(group->value_type == vtn_value_type_decoration_group);
-
-      int scope;
-      if (opcode == SpvOpGroupDecorate) {
-         scope = VTN_DEC_DECORATION;
-      } else {
-         scope = VTN_DEC_STRUCT_MEMBER0 + *(w++);
-      }
+      struct vtn_value *group =
+         vtn_value(b, target, vtn_value_type_decoration_group);
 
       for (; w < w_end; w++) {
-         struct vtn_value *val = &b->values[*w];
+         struct vtn_value *val = vtn_untyped_value(b, *w);
          struct vtn_decoration *dec = rzalloc(b, struct vtn_decoration);
-         dec->scope = scope;
+
          dec->group = group;
+         if (opcode == SpvOpGroupDecorate) {
+            dec->scope = VTN_DEC_DECORATION;
+         } else {
+            dec->scope = VTN_DEC_STRUCT_MEMBER0 + *(w++);
+         }
 
          /* Link into the list */
          dec->next = val->decoration;