diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_lower_double_packing.c | 42 |
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); |