[Mesa-dev] [PATCH 06/13] nir/vtn: implement SpvOpCopyMemorySized

Rob Clark robdclark at gmail.com
Wed Feb 28 19:51:36 UTC 2018


I think a new intrinsic is the easiest way to do this.  We can lower
this to a sequence of load/stores after vtn.

Signed-off-by: Rob Clark <robdclark at gmail.com>
---
 src/compiler/nir/nir_intrinsics.h  |  2 ++
 src/compiler/spirv/vtn_variables.c | 17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_intrinsics.h b/src/compiler/nir/nir_intrinsics.h
index fb58271931e..694ee2a5bd7 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -47,6 +47,8 @@ INTRINSIC(nop, 0, ARR(0), false, 0, 0, 0, xx, xx, xx,
 INTRINSIC(load_var, 0, ARR(0), true, 0, 1, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 INTRINSIC(store_var, 1, ARR(0), false, 0, 1, 1, WRMASK, xx, xx, 0)
 INTRINSIC(copy_var, 0, ARR(0), false, 0, 2, 0, xx, xx, xx, 0)
+/* src = { dst, src, size_in_bytes } */
+INTRINSIC(copy_mem, 3, ARR(1, 1, 1), false, 0, 0, 0, xx, xx, xx, 0)
 
 /*
  * Interpolation of input.  The interp_var_at* intrinsics are similar to the
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index ead68b47848..84d2f4f1b57 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -2022,6 +2022,22 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       break;
    }
 
+   case SpvOpCopyMemorySized: {
+      struct vtn_ssa_value *dest = vtn_ssa_value(b, w[1]);
+      struct vtn_ssa_value *src  = vtn_ssa_value(b, w[2]);
+      struct vtn_ssa_value *size = vtn_ssa_value(b, w[3]);
+      nir_intrinsic_op op = nir_intrinsic_copy_mem;
+
+      nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
+      intrin->src[0] = nir_src_for_ssa(dest->def);
+      intrin->src[1] = nir_src_for_ssa(src->def);
+      intrin->src[2] = nir_src_for_ssa(size->def);
+
+      nir_builder_instr_insert(&b->nb, &intrin->instr);
+
+      break;
+   }
+
    case SpvOpLoad: {
       struct vtn_type *res_type =
          vtn_value(b, w[1], vtn_value_type_type)->type;
@@ -2123,7 +2139,6 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       break;
    }
 
-   case SpvOpCopyMemorySized:
    default:
       vtn_fail("Unhandled opcode");
    }
-- 
2.14.3



More information about the mesa-dev mailing list