summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>2023-03-11 18:58:34 -0500
committerMarge Bot <emma+marge@anholt.net>2023-03-28 21:30:12 +0000
commitbf3027c3916ad5be172c22851e7172671709a9bc (patch)
treea36a90d2ef72148d6e134deb83fb82b53bbfa3f4 /src/mesa
parentf2506780c8a9c2b65336f7556d6ae802ea156e5b (diff)
downloadmesa-bf3027c3916ad5be172c22851e7172671709a9bc.tar.gz
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>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index e0d3215a944..826c42dfa5f 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -80,6 +80,20 @@ st_convert_sampler(const struct st_context *st,
if (texobj->Target == GL_TEXTURE_RECTANGLE_ARB && !st->lower_rect_tex)
sampler->unnormalized_coords = 1;
+ /*
+ * The spec says that "texture wrap modes are ignored" for seamless cube
+ * maps, so normalize the CSO. This works around Apple hardware which honours
+ * REPEAT modes even for seamless cube maps.
+ */
+ if ((texobj->Target == GL_TEXTURE_CUBE_MAP ||
+ texobj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) &&
+ sampler->seamless_cube_map) {
+
+ sampler->wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler->wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ sampler->wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+ }
+
sampler->lod_bias += tex_unit_lod_bias;
/* Check that only wrap modes using the border color have the first bit