mesa/st: Normalize wrap modes for seamless cubes
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 11 Mar 2023 23:58:34 +0000 (18:58 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 28 Mar 2023 21:30:12 +0000 (21:30 +0000)
commitbf3027c3916ad5be172c22851e7172671709a9bc
treea36a90d2ef72148d6e134deb83fb82b53bbfa3f4
parentf2506780c8a9c2b65336f7556d6ae802ea156e5b
mesa/st: Normalize wrap modes for seamless cubes

The OpenGL specification requires that seamless cube maps ignore the wrap mode,
but some hardware may try to respect the wrap mode even for seamless cubes
contrary to the spec. Since OpenGL maps samplers 1:1 to textures (at least
without bindless texture support...), it's easy to override the wrap mode for
seamless cubes to something that works for the hardware.

I'm not sure if there is value in gating this behaviour behind a CAP. On one
hand, there is a tiny bit of extra CPU overhead added to change samplers. On the
other hand, normalizing wrap modes might improve CSO caching, and normalizing to
a non-BORDER mode avoids the expensive border colour code later in the function.

We will need a different workaround in our Vulkan driver. Potentially, we'll
have to duplicate *every* sampler to have a cubemap version and a non-cubemap
version, selecting a sampler in the shader based on the texture opcode. That
sucks and implementing it would depend on subtle details of how we implement
descriptor sets, so it's not like we would share that code with the GL driver
anyway. In the mean time, let's get this right for GL without the performance
hit of duplication.

Fixes dEQP-GLES3.functional.texture.filtering.cube.* on Asahi, as well as a
smattering of dEQP-GLES31.functional.texture.filtering.cube_array.* fails on
softpipe.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21978>
src/gallium/drivers/softpipe/ci/softpipe-asan-fails.txt
src/gallium/drivers/softpipe/ci/softpipe-fails.txt
src/mesa/state_tracker/st_atom_sampler.c