nak: relayout opt_uniform_instrs

I'm touching this code in the next commit, so this makes it easier to
review.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36465>
This commit is contained in:
Karol Herbst
2025-07-30 14:57:23 +02:00
committed by Marge Bot
parent 96f2348bdf
commit b79e55bed7
+40 -41
View File
@@ -52,51 +52,50 @@ impl Shader<'_> {
let mut r2ur = Default::default();
let mut propagated_r2ur = false;
self.map_instrs(|mut instr, alloc| {
if matches!(
&instr.op,
match &instr.op {
Op::Redux(_)
| Op::PhiDsts(_)
| Op::PhiSrcs(_)
| Op::Pin(_)
| Op::Unpin(_)
| Op::Vote(_)
) {
MappedInstrs::One(instr)
} else if instr.is_uniform() {
let mut b = InstrBuilder::new(sm);
if should_lower_to_warp(sm, &instr, &r2ur) {
propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur);
instr.for_each_ssa_def_mut(|ssa| {
let w = alloc.alloc(ssa.file().to_warp());
r2ur.insert(*ssa, w);
b.push_op(OpR2UR {
dst: (*ssa).into(),
src: w.into(),
});
*ssa = w;
});
let mut v = b.into_vec();
v.insert(0, instr);
MappedInstrs::Many(v)
} else {
// We may have non-uniform sources
instr.for_each_ssa_use_mut(|ssa| {
let file = ssa.file();
if !file.is_uniform() {
let u = alloc.alloc(file.to_uniform().unwrap());
| Op::PhiDsts(_)
| Op::PhiSrcs(_)
| Op::Pin(_)
| Op::Unpin(_)
| Op::Vote(_) => MappedInstrs::One(instr),
_ if instr.is_uniform() => {
let mut b = InstrBuilder::new(sm);
if should_lower_to_warp(sm, &instr, &r2ur) {
propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur);
instr.for_each_ssa_def_mut(|ssa| {
let w = alloc.alloc(ssa.file().to_warp());
r2ur.insert(*ssa, w);
b.push_op(OpR2UR {
dst: u.into(),
src: (*ssa).into(),
dst: (*ssa).into(),
src: w.into(),
});
*ssa = u;
}
});
b.push_instr(instr);
b.into_mapped_instrs()
*ssa = w;
});
let mut v = b.into_vec();
v.insert(0, instr);
MappedInstrs::Many(v)
} else {
// We may have non-uniform sources
instr.for_each_ssa_use_mut(|ssa| {
let file = ssa.file();
if !file.is_uniform() {
let u = alloc.alloc(file.to_uniform().unwrap());
b.push_op(OpR2UR {
dst: u.into(),
src: (*ssa).into(),
});
*ssa = u;
}
});
b.push_instr(instr);
b.into_mapped_instrs()
}
}
_ => {
propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur);
MappedInstrs::One(instr)
}
} else {
propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur);
MappedInstrs::One(instr)
}
});