nak: Implement nir_op_[iu](min|max)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand
2023-04-10 17:23:28 -05:00
committed by Marge Bot
parent 63dcc7c75a
commit f2a7cda75a
3 changed files with 55 additions and 0 deletions
+19
View File
@@ -475,6 +475,24 @@ impl SM75Instr {
);
}
fn encode_imnmx(&mut self, op: &OpIMnMx) {
self.encode_alu(
0x017,
Some(op.dst),
ALUSrc::from_src(&op.srcs[0]),
ALUSrc::from_src(&op.srcs[1]),
ALUSrc::None,
);
self.set_pred_src(87..90, 90, op.min);
self.set_bit(
73,
match op.cmp_type {
IntCmpType::U32 => false,
IntCmpType::I32 => true,
},
);
}
fn set_int_cmp_op(&mut self, range: Range<usize>, op: IntCmpOp) {
assert!(range.len() == 3);
self.set_field(
@@ -751,6 +769,7 @@ impl SM75Instr {
Op::FSet(op) => si.encode_fset(&op),
Op::FSetP(op) => si.encode_fsetp(&op),
Op::IAdd3(op) => si.encode_iadd3(&op),
Op::IMnMx(op) => si.encode_imnmx(&op),
Op::ISetP(op) => si.encode_isetp(&op),
Op::Lop3(op) => si.encode_lop3(&op),
Op::Shl(op) => si.encode_shl(&op),
+15
View File
@@ -328,6 +328,21 @@ impl<'a> ShaderFromNir<'a> {
));
}
}
nir_op_imax | nir_op_imin | nir_op_umax | nir_op_umin => {
let (tp, min) = match alu.op {
nir_op_imax => (IntCmpType::I32, SrcRef::False),
nir_op_imin => (IntCmpType::I32, SrcRef::True),
nir_op_umax => (IntCmpType::U32, SrcRef::False),
nir_op_umin => (IntCmpType::U32, SrcRef::True),
_ => panic!("Not an integer min/max"),
};
self.instrs.push(Instr::new(Op::IMnMx(OpIMnMx {
dst: dst,
cmp_type: tp,
srcs: [srcs[0], srcs[1]],
min: min.into(),
})));
}
nir_op_ineg => {
self.instrs.push(Instr::new(Op::IMov(OpIMov {
dst: dst,
+21
View File
@@ -1102,6 +1102,25 @@ impl fmt::Display for OpIAdd3 {
}
}
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
pub struct OpIMnMx {
pub dst: Dst,
pub cmp_type: IntCmpType,
pub srcs: [Src; 2],
pub min: Src,
}
impl fmt::Display for OpIMnMx {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"IMNMX.{} {} {{ {}, {} }} {}",
self.cmp_type, self.dst, self.srcs[0], self.srcs[1], self.min
)
}
}
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
pub struct OpISetP {
@@ -1644,6 +1663,7 @@ pub enum Op {
FSet(OpFSet),
FSetP(OpFSetP),
IAdd3(OpIAdd3),
IMnMx(OpIMnMx),
ISetP(OpISetP),
Lop3(OpLop3),
Shl(OpShl),
@@ -2069,6 +2089,7 @@ impl Instr {
| Op::FSet(_)
| Op::FSetP(_)
| Op::IAdd3(_)
| Op::IMnMx(_)
| Op::Lop3(_)
| Op::PLop3(_)
| Op::ISetP(_)