nak: add support for nir_op_unpack_half_2x16_split_{x|y}

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Daniel Almeida 2023-07-24 18:56:55 -03:00 committed by Marge Bot
parent 59c05e16e4
commit d7d330754b
3 changed files with 28 additions and 0 deletions

View file

@ -717,6 +717,11 @@ impl SM75Instr {
ALUSrc::from_src(&op.src.into()),
ALUSrc::None,
);
if op.high {
self.set_field(60..62, 1_u8); // .H1
}
self.set_field(75..77, (op.dst_type.bits() / 8).ilog2());
self.set_rnd_mode(78..80, op.rnd_mode);
self.set_bit(80, op.ftz);

View file

@ -368,6 +368,7 @@ impl<'a> ShaderFromNir<'a> {
dst_type: FloatType::F16,
rnd_mode: FRndMode::NearestEven,
ftz: true,
high: false,
});
assert!(alu.def.bit_size() == 32);
let dst = b.alloc_ssa(RegFile::GPR, 1);
@ -378,6 +379,7 @@ impl<'a> ShaderFromNir<'a> {
dst_type: FloatType::F32,
rnd_mode: FRndMode::NearestEven,
ftz: true,
high: false,
});
dst
}
@ -677,6 +679,7 @@ impl<'a> ShaderFromNir<'a> {
dst_type: FloatType::F16,
rnd_mode: FRndMode::NearestEven,
ftz: false,
high: false,
});
let src_bits = usize::from(alu.get_src(1).bit_size());
@ -689,6 +692,7 @@ impl<'a> ShaderFromNir<'a> {
dst_type: FloatType::F16,
rnd_mode: FRndMode::NearestEven,
ftz: false,
high: false,
});
let dst = b.alloc_ssa(RegFile::GPR, 1);
@ -742,6 +746,23 @@ impl<'a> ShaderFromNir<'a> {
let src0_y = srcs[0].as_ssa().unwrap()[1];
b.mov(src0_y.into())
}
nir_op_unpack_half_2x16_split_x
| nir_op_unpack_half_2x16_split_y => {
assert!(alu.def.bit_size() == 32);
let dst = b.alloc_ssa(RegFile::GPR, 1);
b.push_op(OpF2F {
dst: dst[0].into(),
src: srcs[0],
src_type: FloatType::F16,
dst_type: FloatType::F32,
rnd_mode: FRndMode::NearestEven,
ftz: false,
high: alu.op == nir_op_unpack_half_2x16_split_y,
});
dst
}
nir_op_ushr => {
assert!(alu.def.bit_size() == 32);
let dst = b.alloc_ssa(RegFile::GPR, 1);

View file

@ -2100,6 +2100,8 @@ pub struct OpF2F {
pub dst_type: FloatType,
pub rnd_mode: FRndMode,
pub ftz: bool,
/// Place the result into the upper 16 bits of the destination register
pub high: bool,
}
impl fmt::Display for OpF2F {