nak: Implement load_sample_id and load_sample_mask_in

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-09-12 01:52:36 -05:00 committed by Marge Bot
parent 595f03957c
commit 24c2728ca5
3 changed files with 64 additions and 1 deletions

View file

@ -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"),
}

View file

@ -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();

View file

@ -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(_)