mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 20:18:12 +02:00
pan/bi: Compose swizzles in bi_half() and bi_byte()
At least bi_half() has the decency to assert if the swizzle isn't BI_SWIZZLE_H01 to start with but bi_byte() did an irrelevant assert and then overwrote the swizzle with BI_SWIZZLE_B<lane> regardless of what was there before. In a lot of cases, this doesn't matter but we use both in translating NIR to BI on things that may have already been swizzled so we need to do the composition. Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40720>
This commit is contained in:
parent
342e9ac7e8
commit
77f9cbd0c2
1 changed files with 17 additions and 15 deletions
|
|
@ -341,8 +341,17 @@ bi_passthrough(enum bifrost_packed_src value)
|
|||
static inline bi_index
|
||||
bi_swz_16(bi_index idx, bool x, bool y)
|
||||
{
|
||||
assert(idx.swizzle == BI_SWIZZLE_H01);
|
||||
idx.swizzle = bi_swizzle_from_half(x, y);
|
||||
bool halves[2];
|
||||
switch (idx.swizzle) {
|
||||
case BI_SWIZZLE_H00: halves[0] = 0; halves[1] = 0; break;
|
||||
case BI_SWIZZLE_H01: halves[0] = 0; halves[1] = 1; break;
|
||||
case BI_SWIZZLE_H10: halves[0] = 1; halves[1] = 0; break;
|
||||
case BI_SWIZZLE_H11: halves[0] = 1; halves[1] = 1; break;
|
||||
default: UNREACHABLE("Not a half swizzle");
|
||||
}
|
||||
assert(idx.swizzle == bi_swizzle_from_half(halves[0], halves[1]));
|
||||
|
||||
idx.swizzle = bi_swizzle_from_half(halves[x], halves[y]);
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
|
@ -352,22 +361,15 @@ bi_half(bi_index idx, bool upper)
|
|||
return bi_swz_16(idx, upper, upper);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
bi_valid_lane_for_byte_swizzle(enum bi_swizzle swizzle, unsigned lane)
|
||||
{
|
||||
unsigned channels[4];
|
||||
if (bi_swizzle_to_byte_channels(swizzle, channels)) {
|
||||
return lane == channels[0] || lane == channels[1] ||
|
||||
lane == channels[2] || lane == channels[3];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bi_index
|
||||
bi_byte(bi_index idx, unsigned lane)
|
||||
{
|
||||
assert(bi_valid_lane_for_byte_swizzle(idx.swizzle, lane));
|
||||
idx.swizzle = (enum bi_swizzle)(BI_SWIZZLE_B0 + lane);
|
||||
unsigned bytes[4];
|
||||
bool valid = bi_swizzle_to_byte_channels(idx.swizzle, bytes);
|
||||
assert(valid);
|
||||
|
||||
assert(lane < 4);
|
||||
idx.swizzle = (enum bi_swizzle)(BI_SWIZZLE_B0 + bytes[lane]);
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue