mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-26 00:20:37 +02:00
panfrost/midgard: Share swizzle compose
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
f6fde45d5c
commit
a0a34946d8
2 changed files with 30 additions and 8 deletions
|
|
@ -265,4 +265,33 @@ vector_alu_from_unsigned(unsigned u)
|
|||
return s;
|
||||
}
|
||||
|
||||
/* Composes two swizzles */
|
||||
static inline unsigned
|
||||
pan_compose_swizzle(unsigned left, unsigned right)
|
||||
{
|
||||
unsigned out = 0;
|
||||
|
||||
for (unsigned c = 0; c < 4; ++c) {
|
||||
unsigned s = (left >> (2*c)) & 0x3;
|
||||
unsigned q = (right >> (2*s)) & 0x3;
|
||||
|
||||
out |= (q << (2*c));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Applies a swizzle to an ALU source */
|
||||
|
||||
static inline unsigned
|
||||
vector_alu_apply_swizzle(unsigned src, unsigned swizzle)
|
||||
{
|
||||
midgard_vector_alu_src s =
|
||||
vector_alu_from_unsigned(src);
|
||||
|
||||
s.swizzle = pan_compose_swizzle(s.swizzle, swizzle);
|
||||
|
||||
return vector_alu_srco_unsigned(s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -92,14 +92,7 @@ static unsigned
|
|||
compose_swizzle(unsigned swizzle, unsigned mask,
|
||||
struct phys_reg reg, struct phys_reg dst)
|
||||
{
|
||||
unsigned out = 0;
|
||||
|
||||
for (unsigned c = 0; c < 4; ++c) {
|
||||
unsigned s = (swizzle >> (2*c)) & 0x3;
|
||||
unsigned q = (reg.swizzle >> (2*s)) & 0x3;
|
||||
|
||||
out |= (q << (2*c));
|
||||
}
|
||||
unsigned out = pan_compose_swizzle(swizzle, reg.swizzle);
|
||||
|
||||
/* Based on the register mask, we need to adjust over. E.g if we're
|
||||
* writing to yz, a base swizzle of xy__ becomes _xy_. Save the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue