pan/midgard: Extend offset_swizzle to non-32-bit

We take a size parameter; use it.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-10-31 14:57:35 -04:00
parent f538981384
commit bf5508f7b9
1 changed files with 4 additions and 3 deletions

View File

@ -72,8 +72,7 @@ struct phys_reg {
unsigned size;
};
/* Shift each component up by reg_offset and shift all components horizontally
* by dst_offset. TODO: vec8+ */
/* Shift up by reg_offset and horizontally by dst_offset. */
static void
offset_swizzle(unsigned *swizzle, unsigned reg_offset, unsigned srcsize, unsigned dst_offset)
@ -83,12 +82,14 @@ offset_swizzle(unsigned *swizzle, unsigned reg_offset, unsigned srcsize, unsigne
signed reg_comp = reg_offset / srcsize;
signed dst_comp = dst_offset / srcsize;
unsigned max_component = (16 / srcsize) - 1;
assert(reg_comp * srcsize == reg_offset);
assert(dst_comp * srcsize == dst_offset);
for (signed c = 0; c < MIR_VEC_COMPONENTS; ++c) {
signed comp = MAX2(c - dst_comp, 0);
out[c] = MIN2(swizzle[comp] + reg_comp, 4 - 1);
out[c] = MIN2(swizzle[comp] + reg_comp, max_component);
}
memcpy(swizzle, out, sizeof(out));