mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 23:20:14 +01:00
nak: Implement Foldable for OpPrmt
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30275>
This commit is contained in:
parent
cac3ff011b
commit
ebc1c052ab
2 changed files with 35 additions and 1 deletions
|
|
@ -565,3 +565,14 @@ fn test_op_iadd3x() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_op_prmt() {
|
||||
let op = OpPrmt {
|
||||
dst: Dst::None,
|
||||
srcs: [0.into(), 0.into()],
|
||||
sel: 0.into(),
|
||||
mode: PrmtMode::Index,
|
||||
};
|
||||
test_foldable_op(op);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4078,7 +4078,7 @@ impl fmt::Display for PrmtMode {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(SrcsAsSlice, DstsAsSlice)]
|
||||
#[derive(Clone, SrcsAsSlice, DstsAsSlice)]
|
||||
/// Permutes `srcs` into `dst` using `selection`.
|
||||
pub struct OpPrmt {
|
||||
#[dst_type(GPR)]
|
||||
|
|
@ -4128,6 +4128,29 @@ impl OpPrmt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Foldable for OpPrmt {
|
||||
fn fold(&self, _sm: &dyn ShaderModel, f: &mut OpFoldData<'_>) {
|
||||
let srcs = [
|
||||
f.get_u32_src(self, &self.srcs[0]),
|
||||
f.get_u32_src(self, &self.srcs[1]),
|
||||
];
|
||||
let sel = f.get_u32_src(self, &self.sel);
|
||||
|
||||
assert!(self.mode == PrmtMode::Index);
|
||||
let sel = PrmtSel(sel as u16);
|
||||
|
||||
let mut dst = 0_u32;
|
||||
for b in 0..4 {
|
||||
let sel_byte = sel.get(b);
|
||||
let src = srcs[sel_byte.src()];
|
||||
let sb = sel_byte.fold_u32(src);
|
||||
dst |= u32::from(sb) << (b * 8);
|
||||
}
|
||||
|
||||
f.set_u32_dst(self, &self.dst, dst);
|
||||
}
|
||||
}
|
||||
|
||||
impl DisplayOp for OpPrmt {
|
||||
fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue