nak: Implement discard and demote

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

View file

@ -1536,6 +1536,11 @@ impl SM75Instr {
self.set_field(72..80, op.idx);
}
fn encode_kill(&mut self, op: &OpKill) {
self.set_opcode(0x95b);
self.set_pred_src(87..90, 90, SrcRef::True.into());
}
fn encode_pixld(&mut self, op: &OpPixLd) {
self.set_opcode(0x925);
self.set_dst(op.dst);
@ -1621,6 +1626,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::Kill(op) => si.encode_kill(&op),
Op::PixLd(op) => si.encode_pixld(&op),
Op::S2R(op) => si.encode_s2r(&op),
_ => panic!("Unhandled instruction"),

View file

@ -1110,6 +1110,13 @@ impl<'a> ShaderFromNir<'a> {
data: data,
});
}
nir_intrinsic_demote | nir_intrinsic_discard => {
b.push_op(OpKill {});
}
nir_intrinsic_demote_if | nir_intrinsic_discard_if => {
let cond = self.get_ssa(&srcs[0].as_def())[0];
b.predicate(cond.into()).push_op(OpKill {});
}
nir_intrinsic_global_atomic => {
let bit_size = intrin.def.bit_size();
let (addr, offset) = self.get_io_addr_offset(&srcs[0], 24);

View file

@ -3277,6 +3277,16 @@ impl fmt::Display for OpCS2R {
}
}
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
pub struct OpKill {}
impl fmt::Display for OpKill {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "KILL")
}
}
pub enum PixVal {
MsCount,
CovMask,
@ -3685,6 +3695,7 @@ pub enum Op {
Exit(OpExit),
Bar(OpBar),
CS2R(OpCS2R),
Kill(OpKill),
PixLd(OpPixLd),
S2R(OpS2R),
Undef(OpUndef),
@ -4002,6 +4013,7 @@ impl Instr {
| Op::Atom(_)
| Op::AtomCas(_)
| Op::MemBar(_)
| Op::Kill(_)
| Op::Bra(_)
| Op::Exit(_)
| Op::Bar(_)
@ -4074,7 +4086,11 @@ impl Instr {
Op::Bra(_) | Op::Exit(_) => true,
// Miscellaneous ops
Op::Bar(_) | Op::CS2R(_) | Op::PixLd(_) | Op::S2R(_) => false,
Op::Bar(_)
| Op::CS2R(_)
| Op::Kill(_)
| Op::PixLd(_)
| Op::S2R(_) => false,
// Virtual ops
Op::Undef(_)