<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 30, 2018 at 7:18 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">With 16-bit support we can now do 32-bit packing, a follow-up patch will<br>
rename the pass to something more generic.<br>
---<br>
 src/compiler/nir/nir_lower_<wbr>64bit_packing.c | 64 +++++++++++++++++++++++++++---<br>
 1 file changed, 59 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_<wbr>64bit_packing.c b/src/compiler/nir/nir_lower_<wbr>64bit_packing.c<br>
index abae173ce3..dd435490e3 100644<br>
--- a/src/compiler/nir/nir_lower_<wbr>64bit_packing.c<br>
+++ b/src/compiler/nir/nir_lower_<wbr>64bit_packing.c<br>
@@ -35,19 +35,57 @@<br>
  */<br>
<br>
 static nir_ssa_def *<br>
-lower_pack_64(nir_builder *b, nir_ssa_def *src)<br>
+lower_pack_64_from_32(nir_<wbr>builder *b, nir_ssa_def *src)<br>
 {<br>
    return nir_pack_64_2x32_split(b, nir_channel(b, src, 0),<br>
                                     nir_channel(b, src, 1));<br>
 }<br>
<br>
 static nir_ssa_def *<br>
-lower_unpack_64(nir_builder *b, nir_ssa_def *src)<br>
+lower_unpack_64_to_32(nir_<wbr>builder *b, nir_ssa_def *src)<br>
 {<br>
    return nir_vec2(b, nir_unpack_64_2x32_split_x(b, src),<br>
                       nir_unpack_64_2x32_split_y(b, src));<br>
 }<br>
<br>
+static nir_ssa_def *<br>
+lower_pack_32_from_16(nir_<wbr>builder *b, nir_ssa_def *src)<br>
+{<br>
+   return nir_pack_32_2x16_split(b, nir_channel(b, src, 0),<br>
+                                    nir_channel(b, src, 1));<br>
+}<br>
+<br>
+static nir_ssa_def *<br>
+lower_unpack_32_to_16(nir_<wbr>builder *b, nir_ssa_def *src)<br>
+{<br>
+   return nir_vec2(b, nir_unpack_32_2x16_split_x(b, src),<br>
+                      nir_unpack_32_2x16_split_y(b, src));<br>
+}<br></blockquote><div><br></div><div>I guess this isn't really lower_64bit_packing anymore. :-)  We may want to consider re-naming this pass at some point.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+static nir_ssa_def *<br>
+lower_pack_64_from_16(nir_<wbr>builder *b, nir_ssa_def *src)<br>
+{<br>
+   nir_ssa_def *xy = nir_pack_32_2x16_split(b, nir_channel(b, src, 0),<br>
+                                               nir_channel(b, src, 1));<br>
+<br>
+   nir_ssa_def *zw = nir_pack_32_2x16_split(b, nir_channel(b, src, 2),<br>
+                                               nir_channel(b, src, 3));<br>
+<br>
+   return nir_pack_64_2x32_split(b, xy, zw);<br>
+}<br>
+<br>
+static nir_ssa_def *<br>
+lower_unpack_64_to_16(nir_<wbr>builder *b, nir_ssa_def *src)<br>
+{<br>
+   nir_ssa_def *xy = nir_unpack_64_2x32_split_x(b, src);<br>
+   nir_ssa_def *zw = nir_unpack_64_2x32_split_y(b, src);<br>
+<br>
+   return nir_vec4(b, nir_unpack_32_2x16_split_x(b, xy),<br>
+                      nir_unpack_32_2x16_split_y(b, xy),<br>
+                      nir_unpack_32_2x16_split_x(b, zw),<br>
+                      nir_unpack_32_2x16_split_y(b, zw));<br>
+}<br>
+<br>
 static bool<br>
 lower_64bit_pack_impl(nir_<wbr>function_impl *impl)<br>
 {<br>
@@ -63,7 +101,11 @@ lower_64bit_pack_impl(nir_<wbr>function_impl *impl)<br>
          nir_alu_instr *alu_instr = (nir_alu_instr *) instr;<br>
<br>
          if (alu_instr->op != nir_op_pack_64_2x32 &&<br>
-             alu_instr->op != nir_op_unpack_64_2x32)<br>
+             alu_instr->op != nir_op_unpack_64_2x32 &&<br>
+             alu_instr->op != nir_op_pack_64_4x16 &&<br>
+             alu_instr->op != nir_op_unpack_64_4x16 &&<br>
+             alu_instr->op != nir_op_pack_32_2x16 &&<br>
+             alu_instr->op != nir_op_unpack_32_2x16)<br>
             continue;<br>
<br>
          b.cursor = nir_before_instr(&alu_instr-><wbr>instr);<br>
@@ -73,10 +115,22 @@ lower_64bit_pack_impl(nir_<wbr>function_impl *impl)<br>
<br>
          switch (alu_instr->op) {<br>
          case nir_op_pack_64_2x32:<br>
-            dest = lower_pack_64(&b, src);<br>
+            dest = lower_pack_64_from_32(&b, src);<br>
             break;<br>
          case nir_op_unpack_64_2x32:<br>
-            dest = lower_unpack_64(&b, src);<br>
+            dest = lower_unpack_64_to_32(&b, src);<br>
+            break;<br>
+         case nir_op_pack_64_4x16:<br>
+            dest = lower_pack_64_from_16(&b, src);<br>
+            break;<br>
+         case nir_op_unpack_64_4x16:<br>
+            dest = lower_unpack_64_to_16(&b, src);<br>
+            break;<br>
+         case nir_op_pack_32_2x16:<br>
+            dest = lower_pack_32_from_16(&b, src);<br>
+            break;<br>
+         case nir_op_unpack_32_2x16:<br>
+            dest = lower_unpack_32_to_16(&b, src);<br>
             break;<br>
          default:<br>
             unreachable("Impossible opcode");<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.14.1<br>
<br>
</font></span></blockquote></div><br></div></div>