Skip to content

panfrost: improve swizzle inversion

Eric Smith requested to merge ericsmith/mesa:pan_invert_swizzle_fix into main
panfrost: improve swizzle inversion

panfrost_invert_swizzle produces a (one-sided) inverse, that is a
function g such that g(f(x)) = x. However, it is actually used in
some cases where we want a two-sided inverse, where we also have
f(g(x)) = x. An example is its use to pre-swizzle border color
values so that a later pass will un-swizzle them. If the swizzle
is not one-to-one this two sided inverse does not exist. However,
we can do better than the original code, e.g. for an RRR1 swizzle
inverse produced was originally B000, which when applied on the wrong
side results in BBB1 as output, whereas R000 would produce the
desired RRR1 output. Using the first valid component we see, rather
than the last one, is thus usually better.

The "correct" solution is to re-write all the code that uses
an inverse to handle non-unique inverses. But frankly these uses only
crop up in fairly niche cases like tests, and it's probably not worth
spending a lot of effort to deal with these edge cases when this
patch fixes most of them.

Fixes some failing piglit ext_framebuffer_multisample tests.
Edited by Eric Smith

Merge request reports

Loading