Mesa (staging/20.0): spirv: Implement OpCopyObject and OpCopyLogical as blind copies

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 1 16:06:15 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 84531156eeae2b3c8980322c02babc894d852984
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=84531156eeae2b3c8980322c02babc894d852984

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Mon Mar 30 11:25:07 2020 -0500

spirv: Implement OpCopyObject and OpCopyLogical as blind copies

Because the types etc. are required to logically match, we can just
copy-propagate the guts of the vtn_value.  This was causing issues with
some new CTS tests that are doing an OpCopyObject of a sampler which is
a special-cased type in spirv_to_nir.  Of course, this is only a partial
solution.  Ideally, we've got a bit of work to do to make all the
composite stuff able to handle all types including images, sampler, and
combined image/samplers but this gets some CTS tests passing.

Cc: mesa-stable at lists.freedesktop.org
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Acked-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4375>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4375>
(cherry picked from commit 7a53e67816ed9baf7d825ed60ee59f0c05f9df48)

---

 .pick_status.json                 |  2 +-
 src/compiler/spirv/spirv_to_nir.c | 26 +++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 4c59485c058..f6ee36e8648 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -346,7 +346,7 @@
         "description": "spirv: Implement OpCopyObject and OpCopyLogical as blind copies",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 2f9d2eecad9..5b0d35c8167 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3569,10 +3569,30 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,
                                  w + 5, count - 5);
       break;
 
-   case SpvOpCopyLogical:
    case SpvOpCopyObject:
-      ssa = vtn_composite_copy(b, vtn_ssa_value(b, w[3]));
-      break;
+   case SpvOpCopyLogical: {
+      struct vtn_value *src = vtn_untyped_value(b, w[3]);
+      struct vtn_value *dst = vtn_push_value(b, w[2], src->value_type);
+      if (opcode == SpvOpCopyObject) {
+         vtn_fail_if(dst->type->id != src->type->id,
+                     "Result Type of OpCopyObject must equal Operand type");
+      } else {
+         assert(opcode == SpvOpCopyLogical);
+         /* The logical type matching rules should guarantee we have exactly
+          * the same GLSL type which means that, if it's an SSA value, we
+          * don't actually need to clone it; we can just copy it blind.
+          */
+         vtn_fail_if(dst->type->type != src->type->type,
+                     "Result Type of OpCopyLogical must logically match "
+                     "the Operand type");
+      }
+      struct vtn_value src_copy = *src;
+      src_copy.name = dst->name;
+      src_copy.decoration = dst->decoration;
+      src_copy.type = dst->type;
+      *dst = src_copy;
+      return;
+   }
 
    default:
       vtn_fail_with_opcode("unknown composite operation", opcode);



More information about the mesa-commit mailing list