summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2016-09-02 08:09:53 -0700
committerIan Romanick <[email protected]>2017-01-20 15:41:23 -0800
commit8ad74a2745162f8f5dcf6d0d2ec1e17fedb4b0d2 (patch)
treed6385f68af1e294197d36d0ea79f8b5e6ffbe5f0 /src/compiler
parent3460d05a718f3859a77fe100f3972095d194be26 (diff)
nir: Lower packing and unpacking of 64-bit integer types
This change makes me wonder whether double packing should be reimplemented as int64BitsToDouble(packInt2x32(v)). I'm a little on the fence since not all platforms that support fp64 natively support int64. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_double_packing.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/compiler/nir/nir_lower_double_packing.c b/src/compiler/nir/nir_lower_double_packing.c
index ed1e7078e4d..6bb01ff1909 100644
--- a/src/compiler/nir/nir_lower_double_packing.c
+++ b/src/compiler/nir/nir_lower_double_packing.c
@@ -30,6 +30,8 @@
*
* packDouble2x32(foo) -> packDouble2x32Split(foo.x, foo.y)
* unpackDouble2x32(foo) -> vec2(unpackDouble2x32_x(foo), unpackDouble2x32_y(foo))
+ * packInt2x32(foo) -> packInt2x32Split(foo.x, foo.y)
+ * unpackInt2x32(foo) -> vec2(unpackInt2x32_x(foo), unpackInt2x32_y(foo))
*/
static nir_ssa_def *
@@ -46,6 +48,20 @@ lower_unpack_double(nir_builder *b, nir_ssa_def *src)
nir_unpack_double_2x32_split_y(b, src));
}
+static nir_ssa_def *
+lower_pack_int(nir_builder *b, nir_ssa_def *src)
+{
+ return nir_pack_int_2x32_split(b, nir_channel(b, src, 0),
+ nir_channel(b, src, 1));
+}
+
+static nir_ssa_def *
+lower_unpack_int(nir_builder *b, nir_ssa_def *src)
+{
+ return nir_vec2(b, nir_unpack_int_2x32_split_x(b, src),
+ nir_unpack_int_2x32_split_y(b, src));
+}
+
static void
lower_double_pack_impl(nir_function_impl *impl)
{
@@ -60,16 +76,32 @@ lower_double_pack_impl(nir_function_impl *impl)
nir_alu_instr *alu_instr = (nir_alu_instr *) instr;
if (alu_instr->op != nir_op_pack_double_2x32 &&
- alu_instr->op != nir_op_unpack_double_2x32)
+ alu_instr->op != nir_op_unpack_double_2x32 &&
+ alu_instr->op != nir_op_pack_int_2x32 &&
+ alu_instr->op != nir_op_unpack_int_2x32)
continue;
b.cursor = nir_before_instr(&alu_instr->instr);
nir_ssa_def *src = nir_ssa_for_alu_src(&b, alu_instr, 0);
- nir_ssa_def *dest =
- alu_instr->op == nir_op_pack_double_2x32 ?
- lower_pack_double(&b, src) :
- lower_unpack_double(&b, src);
+ nir_ssa_def *dest;
+
+ switch (alu_instr->op) {
+ case nir_op_pack_double_2x32:
+ dest = lower_pack_double(&b, src);
+ break;
+ case nir_op_unpack_double_2x32:
+ dest = lower_unpack_double(&b, src);
+ break;
+ case nir_op_pack_int_2x32:
+ dest = lower_pack_int(&b, src);
+ break;
+ case nir_op_unpack_int_2x32:
+ dest = lower_unpack_int(&b, src);
+ break;
+ default:
+ unreachable("Impossible opcode");
+ }
nir_ssa_def_rewrite_uses(&alu_instr->dest.dest.ssa, nir_src_for_ssa(dest));
nir_instr_remove(&alu_instr->instr);