mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 18:10:11 +01:00
nak: Handle modifiers in dedup_srcs() in opt_lop()
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
1b6962eb7e
commit
66c9c40f68
1 changed files with 24 additions and 8 deletions
|
|
@ -72,14 +72,30 @@ impl LopPass {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dedup_srcs(&self, op: &mut LogicOp, srcs: &[Src; 3]) {
|
fn dedup_srcs(&self, op: &mut LogicOp, srcs: &[Src; 3]) {
|
||||||
if srcs[0].src_ref == srcs[1].src_ref {
|
for i in 0..2 {
|
||||||
*op = LogicOp::new_lut(&|x, _, z| op.eval(x, x, z))
|
for j in (i + 1)..3 {
|
||||||
|
if srcs[i].src_ref == srcs[j].src_ref {
|
||||||
|
*op = LogicOp::new_lut(&|x, y, z| {
|
||||||
|
let dup = [x, y, z][i];
|
||||||
|
let si = match srcs[i].src_mod {
|
||||||
|
SrcMod::None => dup,
|
||||||
|
SrcMod::BNot => !dup,
|
||||||
|
_ => panic!("Not a bitwise modifer"),
|
||||||
|
};
|
||||||
|
let sj = match srcs[j].src_mod {
|
||||||
|
SrcMod::None => dup,
|
||||||
|
SrcMod::BNot => !dup,
|
||||||
|
_ => panic!("Not a bitwise modifer"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut s = [x, y, z];
|
||||||
|
s[i] = si;
|
||||||
|
s[j] = sj;
|
||||||
|
|
||||||
|
op.eval(s[0], s[1], s[2])
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if srcs[0].src_ref == srcs[2].src_ref {
|
|
||||||
*op = LogicOp::new_lut(&|x, y, _| op.eval(x, y, x))
|
|
||||||
}
|
}
|
||||||
if srcs[1].src_ref == srcs[2].src_ref {
|
|
||||||
*op = LogicOp::new_lut(&|x, y, _| op.eval(x, y, y))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue