diff options
author | Rob Clark <robdclark@gmail.com> | 2019-03-06 10:04:21 -0500 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2019-03-07 15:33:42 -0500 |
commit | f5d80ff2db36736636aede2040c716d7fb437286 (patch) | |
tree | a371f862d16da85199a3507390670a406ed7c56b /src/gallium/drivers/freedreno/a6xx/fd6_format.c | |
parent | 8dc47490c8384ebab1be3d582e8e4ba93187f6fa (diff) |
freedreno/a6xx: refactor fd6_tex_swiz()
We need a version of fd6_tex_swiz() that just returns the composed
swizzle without building part of the TEX_CONST_0 state. So just
refactor the existing function to build more of the TEX_CONST_0 state,
and leave fd6_tex_swiz() simply composing swizzles.
The small IBO state change (to use LINEAR for smaller sizes/levels) is
to match the state in fd6_tex_const_0(). It seems like maybe tiled
actually works at the smaller sizes but not if minification is in play,
so best just to make images match what we do for textures.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Diffstat (limited to 'src/gallium/drivers/freedreno/a6xx/fd6_format.c')
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_format.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_format.c b/src/gallium/drivers/freedreno/a6xx/fd6_format.c index 2016d31501e..5ba641d50a5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_format.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_format.c @@ -434,16 +434,13 @@ fd6_pipe2swiz(unsigned swiz) } } -uint32_t -fd6_tex_swiz(struct pipe_resource *prsc, enum pipe_format format, +void +fd6_tex_swiz(enum pipe_format format, unsigned char *swiz, unsigned swizzle_r, unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a) { const struct util_format_description *desc = util_format_description(format); - - uint32_t swap = fd6_pipe2swap(format); - unsigned char swiz[4]; const unsigned char uswiz[4] = { swizzle_r, swizzle_g, swizzle_b, swizzle_a }; @@ -456,25 +453,54 @@ fd6_tex_swiz(struct pipe_resource *prsc, enum pipe_format format, PIPE_SWIZZLE_X, PIPE_SWIZZLE_X, PIPE_SWIZZLE_X, PIPE_SWIZZLE_X }; util_format_compose_swizzles(stencil_swiz, uswiz, swiz); - } else if (swap != WZYX) { + } else if (fd6_pipe2swap(format) != 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)); + memcpy(swiz, uswiz, sizeof(uswiz)); } else { /* 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); } +} + +/* Compute the TEX_CONST_0 value for texture state, including SWIZ/SWAP/etc: */ +uint32_t +fd6_tex_const_0(struct pipe_resource *prsc, + unsigned level, enum pipe_format format, + unsigned swizzle_r, unsigned swizzle_g, + unsigned swizzle_b, unsigned swizzle_a) +{ + struct fd_resource *rsc = fd_resource(prsc); + uint32_t swap, texconst0 = 0; + unsigned char swiz[4]; + + if (util_format_is_srgb(format)) { + texconst0 |= A6XX_TEX_CONST_0_SRGB; + } - swap = fd_resource(prsc)->tile_mode ? WZYX : fd6_pipe2swap(format); + if (rsc->tile_mode && !fd_resource_level_linear(prsc, level)) { + texconst0 |= A6XX_TEX_CONST_0_TILE_MODE(rsc->tile_mode); + swap = WZYX; + } else { + swap = fd6_pipe2swap(format); + } - return + fd6_tex_swiz(format, swiz, + swizzle_r, swizzle_g, + swizzle_b, swizzle_a); + + texconst0 |= + A6XX_TEX_CONST_0_FMT(fd6_pipe2tex(format)) | + A6XX_TEX_CONST_0_SAMPLES(fd_msaa_samples(prsc->nr_samples)) | 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])); + + return texconst0; } |