Mesa (main): freedreno/a4xx: fix stencil-textured border colors
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 16 05:31:25 UTC 2021
Module: Mesa
Branch: main
Commit: 14087cb9ea58abe37f156d28fde18cdf82abd242
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=14087cb9ea58abe37f156d28fde18cdf82abd242
Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date: Sun Nov 14 18:39:38 2021 -0500
freedreno/a4xx: fix stencil-textured border colors
These are implemented with unusual sampler formats, so the usual approach
of looking at the format descriptors fails.
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13806>
---
src/gallium/drivers/freedreno/freedreno_texture.c | 26 +++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c
index 0c2edd2f858..c1765b39f8a 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -168,12 +168,30 @@ fd_setup_border_colors(struct fd_texture_stateobj *tex, void *ptr,
const struct util_format_channel_description *chan =
&desc->channel[desc->swizzle[j]];
+ uint8_t native = desc->swizzle[j];
+ /* Special cases:
+ * - X24S8 is implemented with 8_8_8_8_UINT, so the 'native'
+ * location is actually 0 rather than 1
+ * - X32_S8X24_UINT has stencil with a secretly-S8_UINT resource
+ * so again we want 0 rather than 1
+ *
+ * In both cases, there is only one non-void format, so we don't
+ * have to be too careful.
+ *
+ * Note that this only affects a4xx -- a3xx did not support
+ * stencil texturing, and a5xx+ don't use this helper.
+ */
+ if (tex->textures[i]->format == PIPE_FORMAT_X24S8_UINT ||
+ tex->textures[i]->format == PIPE_FORMAT_X32_S8X24_UINT) {
+ native = 0;
+ }
+
if (chan->pure_integer) {
- bcolor32[desc->swizzle[j] + 4] = sampler->border_color.i[j];
- bcolor[desc->swizzle[j] + 8] = sampler->border_color.i[j];
+ bcolor32[native + 4] = sampler->border_color.i[j];
+ bcolor[native + 8] = sampler->border_color.i[j];
} else {
- bcolor32[desc->swizzle[j]] = fui(sampler->border_color.f[j]);
- bcolor[desc->swizzle[j]] =
+ bcolor32[native] = fui(sampler->border_color.f[j]);
+ bcolor[native] =
_mesa_float_to_half(sampler->border_color.f[j]);
}
}
More information about the mesa-commit
mailing list