spirv: handle OpCopyObject correctly with any types
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 5 May 2020 16:25:08 +0000 (18:25 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 15 May 2020 19:18:53 +0000 (19:18 +0000)
This implements OpCopyObject as a blind copy and propagates the
access mask properly even if the source object type isn't a SSA
value.

This fixes some recent dEQP-VK.descriptor_indexing.* failures
since CTS changed and now apply nonUniformEXT after constructing
a combined image/sampler.

Original patch is from Jason Ekstrand.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4909>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index 2ea517077344a990e9dcce5a5305428409624489..6ae1ea81188217f28e4b4d3e6cf35981c323d509 100644 (file)
@@ -3469,9 +3469,11 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,
       break;
 
    case SpvOpCopyLogical:
-   case SpvOpCopyObject:
       ssa = vtn_composite_copy(b, vtn_ssa_value(b, w[3]));
       break;
+   case SpvOpCopyObject:
+      vtn_copy_value(b, w[3], w[2]);
+      return;
 
    default:
       vtn_fail_with_opcode("unknown composite operation", opcode);
index 787dfdb244e3ef5a8085f3d9d8ee7bd4a3d8e3cb..484ab853a821064b338e40b80b21c6db732ec815 100644 (file)
@@ -807,6 +807,10 @@ struct vtn_value *vtn_push_value_pointer(struct vtn_builder *b,
 struct vtn_value *vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
                                struct vtn_type *type, struct vtn_ssa_value *ssa);
 
+void
+vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
+               uint32_t dst_value_id);
+
 struct vtn_ssa_value *vtn_create_ssa_value(struct vtn_builder *b,
                                            const struct glsl_type *type);
 
index 9a6ddc2db1ee04e88c7d611e333a8b5410788cca..318df77669f6f34f0107aaba4a9282a537d05536 100644 (file)
@@ -78,13 +78,19 @@ vtn_push_value_pointer(struct vtn_builder *b, uint32_t value_id,
 
 static void
 ssa_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
-                  const struct vtn_decoration *dec, void *void_ssa)
+                  const struct vtn_decoration *dec, void *void_ctx)
 {
-   struct vtn_ssa_value *ssa = void_ssa;
-
    switch (dec->decoration) {
    case SpvDecorationNonUniformEXT:
-      ssa->access |= ACCESS_NON_UNIFORM;
+      if (val->value_type == vtn_value_type_ssa) {
+         val->ssa->access |= ACCESS_NON_UNIFORM;
+      } else if (val->value_type == vtn_value_type_pointer) {
+         val->pointer->access |= ACCESS_NON_UNIFORM;
+      } else if (val->value_type == vtn_value_type_sampled_image) {
+         val->sampled_image->image->access |= ACCESS_NON_UNIFORM;
+      } else if (val->value_type == vtn_value_type_image_pointer) {
+         val->image->image->access |= ACCESS_NON_UNIFORM;
+      }
       break;
 
    default:
@@ -102,11 +108,30 @@ vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
    } else {
       val = vtn_push_value(b, value_id, vtn_value_type_ssa);
       val->ssa = ssa;
-      vtn_foreach_decoration(b, val, ssa_decoration_cb, val->ssa);
+      vtn_foreach_decoration(b, val, ssa_decoration_cb, NULL);
    }
    return val;
 }
 
+void
+vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
+               uint32_t dst_value_id)
+{
+   struct vtn_value *src = vtn_untyped_value(b, src_value_id);
+   struct vtn_value *dst = vtn_push_value(b, dst_value_id, src->value_type);
+   struct vtn_value src_copy = *src;
+
+   vtn_fail_if(dst->type->id != src->type->id,
+               "Result Type must equal Operand type");
+
+   src_copy.name = dst->name;
+   src_copy.decoration = dst->decoration;
+   src_copy.type = dst->type;
+   *dst = src_copy;
+
+   vtn_foreach_decoration(b, dst, ssa_decoration_cb, NULL);
+}
+
 static struct vtn_access_chain *
 vtn_access_chain_create(struct vtn_builder *b, unsigned length)
 {