summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorKristian H. Kristensen <[email protected]>2019-02-11 15:09:21 -0800
committerKristian H. Kristensen <[email protected]>2019-02-13 11:03:29 -0800
commit182e5c011f225709c12e192012b2e4cc228ba735 (patch)
treeda89ce2cbe0272ec5324b5cea968125b21434ce8 /src/gallium/drivers
parent61094629cb53aa71f58b96bdac9bad13d9273d43 (diff)
freedreno/a6xx: Clean up mixed use of swap and swizzle for texture state
Signed-off-by: Kristian H. Kristensen <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_format.c50
-rw-r--r--src/gallium/drivers/freedreno/a6xx/fd6_texture.c17
2 files changed, 28 insertions, 39 deletions
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_format.c b/src/gallium/drivers/freedreno/a6xx/fd6_format.c
index 35186f020db..6f2ee6ab68a 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_format.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_format.c
@@ -441,32 +441,38 @@ fd6_tex_swiz(struct pipe_resource *prsc, enum pipe_format format,
{
const struct util_format_description *desc =
util_format_description(format);
- unsigned char swiz[4] = {
- swizzle_r, swizzle_g, swizzle_b, swizzle_a,
- }, rswiz[4], *swizp;
- util_format_compose_swizzles(desc->swizzle, swiz, rswiz);
+ uint32_t swap = fd6_pipe2swap(format);
+ unsigned char swiz[4];
+ char uswiz[4] = { swizzle_r, swizzle_g, swizzle_b, swizzle_a };
- if (fd_resource(prsc)->tile_mode) {
- /* for tiled modes, we don't get SWAP, so manually apply that
- * extra step of swizzle:
- */
- enum a3xx_color_swap swap = fd6_pipe2swap(format);
- unsigned char swapswiz[][4] = {
- [WZYX] = { 0, 1, 2, 3 },
- [WXYZ] = { 2, 1, 0, 3 },
- [ZYXW] = { 3, 0, 1, 2 },
- [XYZW] = { 3, 2, 1, 0 },
+ /* Gallium expects stencil sampler to return (s,s,s,s), so massage
+ * the swizzle to do so.
+ */
+ if ((format == PIPE_FORMAT_X24S8_UINT)) {
+ char stencil_swiz[4] = {
+ PIPE_SWIZZLE_X, PIPE_SWIZZLE_X, PIPE_SWIZZLE_X, PIPE_SWIZZLE_X
};
-
- util_format_compose_swizzles(swapswiz[swap], rswiz, swiz);
- swizp = swiz;
+ util_format_compose_swizzles(stencil_swiz, uswiz, swiz);
+ } else if (swap != WZYX) {
+ /* Formats with a non-pass-through swap are permutations of RGBA
+ * formats. We program the permutation using the swap and don't
+ * need to compose the format swizzle with the user swizzle.
+ */
+ memcpy(swiz, uswiz, sizeof(swiz));
} else {
- swizp = rswiz;
+ /* Otherwise, it's an unswapped RGBA format or a format like L8 where
+ * we need the XXX1 swizzle from the gallium format description.
+ */
+ util_format_compose_swizzles(desc->swizzle, uswiz, swiz);
}
- return A6XX_TEX_CONST_0_SWIZ_X(fd6_pipe2swiz(swizp[0])) |
- A6XX_TEX_CONST_0_SWIZ_Y(fd6_pipe2swiz(swizp[1])) |
- A6XX_TEX_CONST_0_SWIZ_Z(fd6_pipe2swiz(swizp[2])) |
- A6XX_TEX_CONST_0_SWIZ_W(fd6_pipe2swiz(swizp[3]));
+ swap = fd_resource(prsc)->tile_mode ? WZYX : fd6_pipe2swap(format);
+
+ return
+ A6XX_TEX_CONST_0_SWAP(swap) |
+ A6XX_TEX_CONST_0_SWIZ_X(fd6_pipe2swiz(swiz[0])) |
+ A6XX_TEX_CONST_0_SWIZ_Y(fd6_pipe2swiz(swiz[1])) |
+ A6XX_TEX_CONST_0_SWIZ_Z(fd6_pipe2swiz(swiz[2])) |
+ A6XX_TEX_CONST_0_SWIZ_W(fd6_pipe2swiz(swiz[3]));
}
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
index 0e2d9ee65d8..cc86525ec63 100644
--- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
+++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c
@@ -249,23 +249,6 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
fd6_tex_swiz(prsc, cso->format, cso->swizzle_r, cso->swizzle_g,
cso->swizzle_b, cso->swizzle_a);
- /* NOTE: since we sample z24s8 using 8888_UINT format, the swizzle
- * we get isn't quite right. Use SWAP(XYZW) as a cheap and cheerful
- * way to re-arrange things so stencil component is where the swiz
- * expects.
- *
- * Note that gallium expects stencil sampler to return (s,s,s,s)
- * which isn't quite true. To make that happen we'd have to massage
- * the swizzle. But in practice only the .x component is used.
- *
- * Skip this in the tile case because tiled formats are not swapped
- * and we have already applied the inverse swap in fd6_tex_swiz()
- * to componsate for that.
- */
- if ((format == PIPE_FORMAT_X24S8_UINT) && !rsc->tile_mode) {
- so->texconst0 |= A6XX_TEX_CONST_0_SWAP(XYZW);
- }
-
if (util_format_is_srgb(format)) {
if (use_astc_srgb_workaround(pctx, format))
so->astc_srgb = true;