From 24c2728ca5169e6d793dda4e178f73df2e1b890c Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 12 Sep 2023 01:52:36 -0500 Subject: [PATCH] nak: Implement load_sample_id and load_sample_mask_in Part-of: --- src/nouveau/compiler/nak_encode_sm75.rs | 17 +++++++++++++ src/nouveau/compiler/nak_from_nir.rs | 16 +++++++++++++ src/nouveau/compiler/nak_ir.rs | 32 ++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak_encode_sm75.rs b/src/nouveau/compiler/nak_encode_sm75.rs index 9333071f807..f3e8e6b39fd 100644 --- a/src/nouveau/compiler/nak_encode_sm75.rs +++ b/src/nouveau/compiler/nak_encode_sm75.rs @@ -1536,6 +1536,22 @@ impl SM75Instr { self.set_field(72..80, op.idx); } + fn encode_pixld(&mut self, op: &OpPixLd) { + self.set_opcode(0x925); + self.set_dst(op.dst); + self.set_field( + 78..81, + match op.val { + PixVal::MsCount => 0_u8, + PixVal::CovMask => 1_u8, + PixVal::CentroidOffset => 2_u8, + PixVal::MyIndex => 3_u8, + PixVal::InnerCoverage => 4_u8, + }, + ); + self.set_pred_dst(81..84, Dst::None); + } + fn encode_s2r(&mut self, op: &OpS2R) { self.set_opcode(0x919); self.set_dst(op.dst); @@ -1605,6 +1621,7 @@ impl SM75Instr { Op::Exit(op) => si.encode_exit(&op), Op::Bar(op) => si.encode_bar(&op), Op::CS2R(op) => si.encode_cs2r(&op), + Op::PixLd(op) => si.encode_pixld(&op), Op::S2R(op) => si.encode_s2r(&op), _ => panic!("Unhandled instruction"), } diff --git a/src/nouveau/compiler/nak_from_nir.rs b/src/nouveau/compiler/nak_from_nir.rs index ada3afc48c8..e153e2cdcfd 100644 --- a/src/nouveau/compiler/nak_from_nir.rs +++ b/src/nouveau/compiler/nak_from_nir.rs @@ -1264,6 +1264,22 @@ impl<'a> ShaderFromNir<'a> { } self.set_dst(&intrin.def, dst); } + nir_intrinsic_load_sample_id => { + let dst = b.alloc_ssa(RegFile::GPR, 1); + b.push_op(OpPixLd { + dst: dst.into(), + val: PixVal::MyIndex, + }); + self.set_dst(&intrin.def, dst); + } + nir_intrinsic_load_sample_mask_in => { + let dst = b.alloc_ssa(RegFile::GPR, 1); + b.push_op(OpPixLd { + dst: dst.into(), + val: PixVal::CovMask, + }); + self.set_dst(&intrin.def, dst); + } nir_intrinsic_load_scratch => { let size_B = (intrin.def.bit_size() / 8) * intrin.def.num_components(); diff --git a/src/nouveau/compiler/nak_ir.rs b/src/nouveau/compiler/nak_ir.rs index d6565342f76..b072e8a7eca 100644 --- a/src/nouveau/compiler/nak_ir.rs +++ b/src/nouveau/compiler/nak_ir.rs @@ -3277,6 +3277,35 @@ impl fmt::Display for OpCS2R { } } +pub enum PixVal { + MsCount, + CovMask, + CentroidOffset, + MyIndex, + InnerCoverage, +} + +#[repr(C)] +#[derive(SrcsAsSlice, DstsAsSlice)] +pub struct OpPixLd { + pub dst: Dst, + pub val: PixVal, +} + +impl fmt::Display for OpPixLd { + fn fmt(&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, " {}", self.dst) + } +} + #[repr(C)] #[derive(SrcsAsSlice, DstsAsSlice)] pub struct OpS2R { @@ -3656,6 +3685,7 @@ pub enum Op { Exit(OpExit), Bar(OpBar), CS2R(OpCS2R), + PixLd(OpPixLd), S2R(OpS2R), Undef(OpUndef), PhiSrcs(OpPhiSrcs), @@ -4044,7 +4074,7 @@ impl Instr { Op::Bra(_) | Op::Exit(_) => true, // Miscellaneous ops - Op::Bar(_) | Op::CS2R(_) | Op::S2R(_) => false, + Op::Bar(_) | Op::CS2R(_) | Op::PixLd(_) | Op::S2R(_) => false, // Virtual ops Op::Undef(_)