spirv: Deal with glslang bug not setting the decoration for stores.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 24 Aug 2020 22:20:18 +0000 (00:20 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 2 Sep 2020 19:16:57 +0000 (21:16 +0200)
Fixes: af81486a8cd "spirv: Simplify our handling of NonUniform"
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6451>

src/compiler/spirv/vtn_variables.c

index f5ba73f4fca761f8e0d98efd89d0ab0af2d8b077..a2707ac3886ba4a1ad8a1287dd95ef4284dd452d 100644 (file)
@@ -2515,6 +2515,22 @@ vtn_emit_make_available_barrier(struct vtn_builder *b, SpvMemoryAccessMask acces
                                      vtn_mode_to_memory_semantics(mode));
 }
 
+static void
+ptr_nonuniform_workaround_cb(struct vtn_builder *b, struct vtn_value *val,
+                  int member, const struct vtn_decoration *dec, void *void_ptr)
+{
+   enum gl_access_qualifier *access = void_ptr;
+
+   switch (dec->decoration) {
+   case SpvDecorationNonUniformEXT:
+      *access |= ACCESS_NON_UNIFORM;
+      break;
+
+   default:
+      break;
+   }
+}
+
 void
 vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
                      const uint32_t *w, unsigned count)
@@ -2598,12 +2614,20 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
             chain->link[idx].mode = vtn_access_mode_id;
             chain->link[idx].id = w[i];
          }
+
+         /* Workaround for https://gitlab.freedesktop.org/mesa/mesa/-/issues/3406 */
+         vtn_foreach_decoration(b, link_val, ptr_nonuniform_workaround_cb, &access);
+
          idx++;
       }
 
       struct vtn_type *ptr_type = vtn_get_type(b, w[1]);
       struct vtn_pointer *base =
          vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
+
+      /* Workaround for https://gitlab.freedesktop.org/mesa/mesa/-/issues/3406 */
+      access |= base->access & ACCESS_NON_UNIFORM;
+
       struct vtn_pointer *ptr = vtn_pointer_dereference(b, base, chain);
       ptr->ptr_type = ptr_type;
       ptr->access |= access;