freedreno/a6xx: Fix border color swizzling
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 17 Jun 2022 13:45:18 +0000 (15:45 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 29 Jun 2022 03:00:56 +0000 (03:00 +0000)
commit39c64a4b537a7e919d959369c2c0cdd19447a251
tree64201837a1a038f42ebcb633db037faa23a0bbc6
parent2a928ae32587ee85894cc2fd7591a4555cf4c224
freedreno/a6xx: Fix border color swizzling

From the API's point of view, border color replacement looks like this:

       --------------------
       | API Border Color |
       --------------------
               |
-----------    |    ----------------      ----------
| API fmt |-------->| User Swizzle |----->| Shader |
-----------         ----------------      ----------

From the HW point of view, it looks like this:

                    -------------------
                    | HW Border Color |
                    -------------------
                             |
----------     -----------   |   ---------------      ----------
| HW fmt |-----| HW swap |------>| Tex Swizzle |----->| Shader |
----------     -----------       ---------------      ----------

When the HW fmt + HW swap isn't enough to represent an API format, we
need to prepend our own swizzle to the the user's swizzle, so the tex
swizzle is a "format swizzle" composed with the user swizzle. However,
we don't want this format swizzle to be applied to border colors, so
there's a workaround in freedreno which is meant to undo the format
swizzle so that the HW border color with the format swizzle applied
equals the API border color, and everything is ok. However, on a6xx at
least it was incorrectly undoing the entire tex swizzle. This broke
border color with a user swizzle, because it was now effectively not
getting applied for the border color. It also made it seem like the user
swizzle is required for the workaround, which would have implications
for VK_EXT_border_color_swizzle with turnip, but it's not.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17177>
src/freedreno/ci/freedreno-a630-fails.txt
src/gallium/drivers/freedreno/a6xx/fd6_emit.c