mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 14:38:06 +02:00
nak: Implement vote and ballot
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
3df9065296
commit
5dd7a76c8b
4 changed files with 96 additions and 1 deletions
|
|
@ -1767,6 +1767,23 @@ impl SM75Instr {
|
|||
);
|
||||
}
|
||||
|
||||
fn encode_vote(&mut self, op: &OpVote) {
|
||||
self.set_opcode(0x806);
|
||||
self.set_dst(op.ballot);
|
||||
|
||||
self.set_field(
|
||||
72..74,
|
||||
match op.op {
|
||||
VoteOp::All => 0_u8,
|
||||
VoteOp::Any => 1_u8,
|
||||
VoteOp::Eq => 2_u8,
|
||||
},
|
||||
);
|
||||
|
||||
self.set_pred_dst(81..84, op.vote);
|
||||
self.set_pred_src(87..90, 90, op.pred);
|
||||
}
|
||||
|
||||
pub fn encode(
|
||||
instr: &Instr,
|
||||
sm: u8,
|
||||
|
|
@ -1845,6 +1862,7 @@ impl SM75Instr {
|
|||
Op::S2R(op) => si.encode_s2r(&op),
|
||||
Op::Out(op) => si.encode_out(&op),
|
||||
Op::OutFinal(op) => si.encode_out_final(&op),
|
||||
Op::Vote(op) => si.encode_vote(&op),
|
||||
_ => panic!("Unhandled instruction"),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1337,6 +1337,21 @@ impl<'a> ShaderFromNir<'a> {
|
|||
panic!("Invalid VTG I/O intrinsic");
|
||||
}
|
||||
}
|
||||
nir_intrinsic_ballot => {
|
||||
assert!(srcs[0].bit_size() == 1);
|
||||
let src = self.get_src(&srcs[0]);
|
||||
|
||||
assert!(intrin.def.bit_size() == 32);
|
||||
let dst = b.alloc_ssa(RegFile::GPR, 1);
|
||||
|
||||
b.push_op(OpVote {
|
||||
op: VoteOp::Any,
|
||||
ballot: dst.into(),
|
||||
vote: Dst::None,
|
||||
pred: src,
|
||||
});
|
||||
self.set_dst(&intrin.def, dst);
|
||||
}
|
||||
nir_intrinsic_bar_break_nv => {
|
||||
let idx = &srcs[0].as_def().index;
|
||||
let (bar, _) = self.bar_ref_label.get(idx).unwrap();
|
||||
|
|
@ -2008,6 +2023,28 @@ impl<'a> ShaderFromNir<'a> {
|
|||
b.push_op(OpOutFinal { handle: handle });
|
||||
}
|
||||
}
|
||||
nir_intrinsic_vote_all
|
||||
| nir_intrinsic_vote_any
|
||||
| nir_intrinsic_vote_ieq => {
|
||||
assert!(srcs[0].bit_size() == 1);
|
||||
let src = self.get_src(&srcs[0]);
|
||||
|
||||
assert!(intrin.def.bit_size() == 1);
|
||||
let dst = b.alloc_ssa(RegFile::Pred, 1);
|
||||
|
||||
b.push_op(OpVote {
|
||||
op: match intrin.intrinsic {
|
||||
nir_intrinsic_vote_all => VoteOp::All,
|
||||
nir_intrinsic_vote_any => VoteOp::Any,
|
||||
nir_intrinsic_vote_ieq => VoteOp::Eq,
|
||||
_ => panic!("Unknown vote intrinsic"),
|
||||
},
|
||||
ballot: Dst::None,
|
||||
vote: dst.into(),
|
||||
pred: src,
|
||||
});
|
||||
self.set_dst(&intrin.def, dst);
|
||||
}
|
||||
_ => panic!(
|
||||
"Unsupported intrinsic instruction: {}",
|
||||
intrin.info().name()
|
||||
|
|
|
|||
|
|
@ -3703,6 +3703,44 @@ impl fmt::Display for OpS2R {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum VoteOp {
|
||||
Any,
|
||||
All,
|
||||
Eq,
|
||||
}
|
||||
|
||||
impl fmt::Display for VoteOp {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
VoteOp::Any => write!(f, "ANY"),
|
||||
VoteOp::All => write!(f, "ALL"),
|
||||
VoteOp::Eq => write!(f, "EQ"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(SrcsAsSlice, DstsAsSlice)]
|
||||
pub struct OpVote {
|
||||
pub op: VoteOp,
|
||||
|
||||
pub ballot: Dst,
|
||||
pub vote: Dst,
|
||||
|
||||
#[src_type(Pred)]
|
||||
pub pred: Src,
|
||||
}
|
||||
|
||||
impl fmt::Display for OpVote {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"VOTE.{} {{ {} {} }} {}",
|
||||
self.op, self.ballot, self.vote, self.pred
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(SrcsAsSlice, DstsAsSlice)]
|
||||
pub struct OpUndef {
|
||||
|
|
@ -4136,6 +4174,7 @@ pub enum Op {
|
|||
Nop(OpNop),
|
||||
PixLd(OpPixLd),
|
||||
S2R(OpS2R),
|
||||
Vote(OpVote),
|
||||
Undef(OpUndef),
|
||||
PhiSrcs(OpPhiSrcs),
|
||||
PhiDsts(OpPhiDsts),
|
||||
|
|
@ -4572,7 +4611,7 @@ impl Instr {
|
|||
| Op::Kill(_)
|
||||
| Op::PixLd(_)
|
||||
| Op::S2R(_) => false,
|
||||
Op::Nop(_) => true,
|
||||
Op::Nop(_) | Op::Vote(_) => true,
|
||||
|
||||
// Virtual ops
|
||||
Op::Undef(_)
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ fn legalize_instr(b: &mut impl SSABuilder, instr: &mut Instr) {
|
|||
}
|
||||
Op::Ldc(_) => (), // Nothing to do
|
||||
Op::BMov(_) | Op::Break(_) | Op::BSSy(_) | Op::BSync(_) => (),
|
||||
Op::Vote(_) => (), // Nothing to do
|
||||
Op::Copy(_) => (), // Nothing to do
|
||||
_ => {
|
||||
let src_types = instr.src_types();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue