freedreno/a6xx: Add fd_resource_swap() helper
authorKristian H. Kristensen <hoegsberg@google.com>
Thu, 28 Nov 2019 00:06:59 +0000 (16:06 -0800)
committerKristian H. Kristensen <hoegsberg@google.com>
Thu, 19 Dec 2019 17:56:05 +0000 (09:56 -0800)
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2848>

src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
src/gallium/drivers/freedreno/a6xx/fd6_format.c
src/gallium/drivers/freedreno/a6xx/fd6_format.h
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c

index 58b564f8f4bf06d3df8b2b715c004c2546be62b1..8357e71fc76396dcdeb4e4d05f35840b0e3438ee 100644 (file)
@@ -390,8 +390,8 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring,
        /* Linear levels of a tiled resource are always WZYX, so look at
         * rsc->tile_mode to determine the swap.
         */
-       sswap = src->layout.tile_mode ? WZYX : fd6_pipe2swap(info->src.format);
-       dswap = dst->layout.tile_mode ? WZYX : fd6_pipe2swap(info->dst.format);
+       sswap = fd6_resource_swap(src, info->src.format);
+       dswap = fd6_resource_swap(dst, info->dst.format);
 
        if (util_format_is_compressed(info->src.format)) {
                debug_assert(info->src.format == info->dst.format);
index e703de8e12b594ccf482713ba2f0a744d8a4cd4d..d09bdc776b28506cfa38e3e4129b35b625631f17 100644 (file)
@@ -487,7 +487,7 @@ fd6_tex_const_0(struct pipe_resource *prsc,
        return
                A6XX_TEX_CONST_0_FMT(fd6_pipe2tex(format)) |
                A6XX_TEX_CONST_0_SAMPLES(fd_msaa_samples(prsc->nr_samples)) |
-               A6XX_TEX_CONST_0_SWAP(rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(format)) |
+               A6XX_TEX_CONST_0_SWAP(fd6_resource_swap(rsc, format)) |
                A6XX_TEX_CONST_0_TILE_MODE(fd_resource_tile_mode(prsc, level)) |
                COND(util_format_is_srgb(format), A6XX_TEX_CONST_0_SRGB) |
                A6XX_TEX_CONST_0_SWIZ_X(fd6_pipe2swiz(swiz[0])) |
index 8da5f08be5062ee58b8d4cbba28f7b4d2a98c4ab..90b06197ef586506e179526bbdda26f615d0741c 100644 (file)
@@ -118,4 +118,11 @@ fd6_ifmt(enum a6xx_color_fmt fmt)
                return 0;
        }
 }
+
+static inline uint32_t
+fd6_resource_swap(struct fd_resource *rsc, enum pipe_format format)
+{
+       return rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(format);
+}
+
 #endif /* FD6_UTIL_H_ */
index a97f4742828663c01643867a446c0a867fe6903c..dfff3ecc51216cfdf3b2c091d0298772853f4160 100644 (file)
@@ -113,7 +113,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb,
                                psurf->u.tex.first_layer);
 
                stride = slice->pitch * rsc->layout.cpp * pfb->samples;
-               swap = rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(pformat);
+               swap = fd6_resource_swap(rsc, pformat);
 
                tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level);
 
@@ -961,7 +961,7 @@ emit_blit(struct fd_batch *batch,
        enum a6xx_color_fmt format = fd6_pipe2color(pfmt);
        uint32_t stride = slice->pitch * rsc->layout.cpp;
        uint32_t size = slice->size0;
-       enum a3xx_color_swap swap = rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(pfmt);
+       enum a3xx_color_swap swap = fd6_resource_swap(rsc, pfmt);
        enum a3xx_msaa_samples samples =
                        fd_msaa_samples(rsc->base.nr_samples);
        uint32_t tile_mode = fd_resource_tile_mode(&rsc->base, psurf->u.tex.level);