Translator: a 4:2:2 row's fetches are named, not indexed
Clippy's indexing_slicing (denied in the tree) refused lower::texture::chroma::row's slices of its fetched bytes and its store into the texels' array (merge check job m3-max-88057). The six fetches are now three pairs of named texels, and the two texels are made by one closure. The instructions are emitted in the same order as before, so the module is unchanged.
This commit is contained in:
1 parent
88d60a299c
commit
cc13a21eb9
1 file changed
+26
-21
@@ -380,23 +380,29 @@ pub(crate) fn row(
|
||||
let left = fb.binary(BinOp::ISub, floor, one)?;
|
||||
let up = fb.binary(BinOp::IAdd, b, one)?;
|
||||
let right = fb.glsl(GlslOp::UMin, &[up, im.last_pair])?;
|
||||
// The six texels: the left pair's two, `b`'s, then the right pair's.
|
||||
let (mut firsts, mut seconds) = (Vec::with_capacity(6), Vec::with_capacity(6));
|
||||
for pair in [left, b, right] {
|
||||
let twice = fb.binary(BinOp::ShiftLeftLogical, pair, one)?;
|
||||
// The six texels, each its first and second bytes: the left pair's two, `b`'s, then the
|
||||
// right pair's.
|
||||
let bytes = |fb: &mut FunctionBuilder<'_>, column: SValue| -> BResult<(SValue, SValue)> {
|
||||
let site = fb.composite_construct(uv2, &[column, y])?;
|
||||
let t = fb.fetch(im.img, site, ops)?;
|
||||
Ok((
|
||||
fb.composite_extract(t, &[0])?,
|
||||
fb.composite_extract(t, &[1])?,
|
||||
))
|
||||
};
|
||||
let pair = |fb: &mut FunctionBuilder<'_>, p: SValue| -> BResult<[(SValue, SValue); 2]> {
|
||||
let twice = fb.binary(BinOp::ShiftLeftLogical, p, one)?;
|
||||
let odd = fb.binary(BinOp::BitwiseOr, twice, one)?;
|
||||
for column in [twice, odd] {
|
||||
let site = fb.composite_construct(uv2, &[column, y])?;
|
||||
let t = fb.fetch(im.img, site, ops)?;
|
||||
firsts.push(fb.composite_extract(t, &[0])?);
|
||||
seconds.push(fb.composite_extract(t, &[1])?);
|
||||
}
|
||||
}
|
||||
Ok([bytes(fb, twice)?, bytes(fb, odd)?])
|
||||
};
|
||||
let [l0, l1] = pair(fb, left)?;
|
||||
let [b0, b1] = pair(fb, b)?;
|
||||
let [r0, r1] = pair(fb, right)?;
|
||||
// Each texel's first and second bytes' codes, four lanes a conversion: the first four
|
||||
// texels' firsts and seconds, then the right pair's firsts and seconds.
|
||||
let first = codes(fb, &firsts[..4])?;
|
||||
let second = codes(fb, &seconds[..4])?;
|
||||
let edge = codes(fb, &[firsts[4], firsts[5], seconds[4], seconds[5]])?;
|
||||
let first = codes(fb, &[l0.0, l1.0, b0.0, b1.0])?;
|
||||
let second = codes(fb, &[l0.1, l1.1, b0.1, b1.1])?;
|
||||
let edge = codes(fb, &[r0.0, r1.0, r0.1, r1.1])?;
|
||||
// `GBGR422`'s texels are `(Y, C)`, `BGRG422`'s `(C, Y)`.
|
||||
let bt = fb.module().ty(SType::Bool)?;
|
||||
let bv4 = fb.module().ty(SType::Vector { elem: bt, len: 4 })?;
|
||||
@@ -440,14 +446,13 @@ pub(crate) fn row(
|
||||
let side = fb.composite_construct(uv4, &[cr_side0, cb_side0, cr_side1, cb_side1])?;
|
||||
let m = mixed(fb, own, side, 4)?;
|
||||
let opaque = ku(fb, 255)?;
|
||||
let mut texels = [zero; 2];
|
||||
for (k, l) in [luma0, luma1].into_iter().enumerate() {
|
||||
let red = lane(fb, m, 2 * k as u32)?;
|
||||
let blue = lane(fb, m, 2 * k as u32 + 1)?;
|
||||
let texel = |fb: &mut FunctionBuilder<'_>, k: u32, l: SValue| -> BResult<SValue> {
|
||||
let red = lane(fb, m, 2 * k)?;
|
||||
let blue = lane(fb, m, 2 * k + 1)?;
|
||||
let codes = fb.composite_construct(uv4, &[red, l, blue, opaque])?;
|
||||
texels[k] = super::words::unorm_values(fb, codes, [8; 4])?;
|
||||
}
|
||||
Ok(texels)
|
||||
super::words::unorm_values(fb, codes, [8; 4])
|
||||
};
|
||||
Ok([texel(fb, 0, luma0)?, texel(fb, 1, luma1)?])
|
||||
}
|
||||
|
||||
/// A sampled read's texel `native` (the device's fetch, a `vec4` of `f32`) at `at` (a `uvec2`)
|
||||
|
||||
Reference in new issue
Block a user