From 9b4a005bf867958d33d549a35118c18e01f3c7c9 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 12 Jul 2024 12:26:17 -0500 Subject: [PATCH] nak/sm50: Implement OpPixLd Part-of: --- src/nouveau/compiler/nak/ir.rs | 25 +++++++++++++++++-------- src/nouveau/compiler/nak/sm50.rs | 25 +++++++++++++++++++++++++ src/nouveau/compiler/nak/sm70.rs | 3 ++- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 431a80d42a4..7345c574808 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -4832,11 +4832,27 @@ impl_display_for_op!(OpNop); pub enum PixVal { MsCount, CovMask, + Covered, + Offset, CentroidOffset, MyIndex, InnerCoverage, } +impl fmt::Display for PixVal { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + PixVal::MsCount => write!(f, ".mscount"), + PixVal::CovMask => write!(f, ".covmask"), + PixVal::Covered => write!(f, ".covered"), + PixVal::Offset => write!(f, ".offset"), + PixVal::CentroidOffset => write!(f, ".centroid_offset"), + PixVal::MyIndex => write!(f, ".my_index"), + PixVal::InnerCoverage => write!(f, ".inner_coverage"), + } + } +} + #[repr(C)] #[derive(SrcsAsSlice, DstsAsSlice)] pub struct OpPixLd { @@ -4846,14 +4862,7 @@ pub struct OpPixLd { impl DisplayOp for OpPixLd { fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "pixld")?; - match self.val { - PixVal::MsCount => write!(f, ".mscount"), - PixVal::CovMask => write!(f, ".covmask"), - PixVal::CentroidOffset => write!(f, ".centroid_offset"), - PixVal::MyIndex => write!(f, ".my_index"), - PixVal::InnerCoverage => write!(f, ".inner_coverage"), - } + write!(f, "pixld{}", self.val) } } impl_display_for_op!(OpPixLd); diff --git a/src/nouveau/compiler/nak/sm50.rs b/src/nouveau/compiler/nak/sm50.rs index 62a3f60bf87..9f5a0b724af 100644 --- a/src/nouveau/compiler/nak/sm50.rs +++ b/src/nouveau/compiler/nak/sm50.rs @@ -2746,6 +2746,30 @@ impl SM50Op for OpNop { } } +impl SM50Op for OpPixLd { + fn legalize(&mut self, _b: &mut LegalizeBuilder) { + // Nothing to do + } + + fn encode(&self, e: &mut SM50Encoder<'_>) { + e.set_opcode(0xefe8); + e.set_dst(self.dst); + e.set_reg_src(8..16, 0.into()); + e.set_field( + 31..34, + match &self.val { + PixVal::CovMask => 1_u8, + PixVal::Covered => 2_u8, + PixVal::Offset => 3_u8, + PixVal::CentroidOffset => 4_u8, + PixVal::MyIndex => 5_u8, + other => panic!("Unsupported PixVal: {other}"), + }, + ); + e.set_pred_dst(45..48, Dst::None); + } +} + impl SM50Op for OpS2R { fn legalize(&mut self, _b: &mut LegalizeBuilder) { // Nothing to do @@ -2882,6 +2906,7 @@ macro_rules! as_sm50_op_match { Op::Kill(op) => op, Op::CS2R(op) => op, Op::Nop(op) => op, + Op::PixLd(op) => op, Op::Isberd(op) => op, Op::Out(op) => op, Op::Bfe(op) => op, diff --git a/src/nouveau/compiler/nak/sm70.rs b/src/nouveau/compiler/nak/sm70.rs index 46fd74ef467..a6ecc30f073 100644 --- a/src/nouveau/compiler/nak/sm70.rs +++ b/src/nouveau/compiler/nak/sm70.rs @@ -3239,12 +3239,13 @@ impl SM70Op for OpPixLd { e.set_dst(self.dst); e.set_field( 78..81, - match self.val { + match &self.val { PixVal::MsCount => 0_u8, PixVal::CovMask => 1_u8, PixVal::CentroidOffset => 2_u8, PixVal::MyIndex => 3_u8, PixVal::InnerCoverage => 4_u8, + other => panic!("Unsupported PixVal: {other}"), }, ); e.set_pred_dst(81..84, Dst::None);