nak/legalize: Allow pinned uniform vectors in non-uniform blocks

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
This commit is contained in:
Faith Ekstrand 2024-06-12 08:42:28 -05:00 committed by Marge Bot
parent 2279c2dd65
commit c8e25b45fb

View file

@ -970,6 +970,7 @@ fn legalize_instr(
b: &mut impl SSABuilder,
bl: &impl BlockLiveness,
block_uniform: bool,
pinned: &HashSet<SSARef>,
ip: usize,
instr: &mut Instr,
) {
@ -989,7 +990,10 @@ fn legalize_instr(
// we need to insert copies to warp regs which we can collect.
match &mut src.src_ref {
SrcRef::SSA(vec) => {
if vec.is_uniform() && vec.comps() > 1 {
if vec.is_uniform()
&& vec.comps() > 1
&& !pinned.contains(vec)
{
copy_ssa_ref(b, vec, vec.file().unwrap().to_warp());
}
}
@ -1049,6 +1053,7 @@ impl Shader {
let sm = self.info.sm;
for f in &mut self.functions {
let live = SimpleLiveness::for_function(f);
let mut pinned = HashSet::new();
for (bi, b) in f.blocks.iter_mut().enumerate() {
let bl = live.block_live(bi);
@ -1056,8 +1061,14 @@ impl Shader {
let mut instrs = Vec::new();
for (ip, mut instr) in b.instrs.drain(..).enumerate() {
if let Op::Pin(pin) = &instr.op {
if let Dst::SSA(ssa) = &pin.dst {
pinned.insert(*ssa);
}
}
let mut b = SSAInstrBuilder::new(sm, &mut f.ssa_alloc);
legalize_instr(&mut b, bl, bu, ip, &mut instr);
legalize_instr(&mut b, bl, bu, &pinned, ip, &mut instr);
b.push_instr(instr);
instrs.append(&mut b.as_vec());
}