summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2020-05-05 18:25:08 +0200
committerMarge Bot <eric+marge@anholt.net>2020-05-15 19:18:53 +0000
commit844d561c580188dad583dd4bad3b77d55e39372f (patch)
tree6aa7bfa3508708809cbd8de14849f1440370774e
parent9d1821adf0bc51958becf116d6df5c65514d58b6 (diff)
spirv: handle OpCopyObject correctly with any types
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>
-rw-r--r--src/compiler/spirv/spirv_to_nir.c4
-rw-r--r--src/compiler/spirv/vtn_private.h4
-rw-r--r--src/compiler/spirv/vtn_variables.c35
3 files changed, 37 insertions, 6 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 2ea51707734..6ae1ea81188 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -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);
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 787dfdb244e..484ab853a82 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -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);
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 9a6ddc2db1e..318df77669f 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -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)
{