freedreno/a6xx: Add format argument to fd6_tex_swiz()
authorKristian H. Kristensen <hoegsberg@chromium.org>
Sat, 9 Feb 2019 00:27:25 +0000 (16:27 -0800)
committerKristian H. Kristensen <hoegsberg@chromium.org>
Mon, 11 Feb 2019 20:26:21 +0000 (12:26 -0800)
We need to allow overriding the format with that of the image or
sampler view, so we can't take it from the resource in fd6_tex_swiz().

Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
src/gallium/drivers/freedreno/a6xx/fd6_format.c
src/gallium/drivers/freedreno/a6xx/fd6_format.h
src/gallium/drivers/freedreno/a6xx/fd6_image.c
src/gallium/drivers/freedreno/a6xx/fd6_texture.c

index dc1a54243a35bb9ee70f86cef9024427a56b0de0..35186f020db72fe925eb79f54754008f825abe62 100644 (file)
@@ -435,11 +435,12 @@ fd6_pipe2swiz(unsigned swiz)
 }
 
 uint32_t
-fd6_tex_swiz(struct pipe_resource *prsc, unsigned swizzle_r, unsigned swizzle_g,
-               unsigned swizzle_b, unsigned swizzle_a)
+fd6_tex_swiz(struct pipe_resource *prsc, enum pipe_format format,
+                        unsigned swizzle_r, unsigned swizzle_g,
+                        unsigned swizzle_b, unsigned swizzle_a)
 {
        const struct util_format_description *desc =
-                       util_format_description(prsc->format);
+                       util_format_description(format);
        unsigned char swiz[4] = {
                        swizzle_r, swizzle_g, swizzle_b, swizzle_a,
        }, rswiz[4], *swizp;
@@ -450,7 +451,7 @@ fd6_tex_swiz(struct pipe_resource *prsc, unsigned swizzle_r, unsigned swizzle_g,
                /* for tiled modes, we don't get SWAP, so manually apply that
                 * extra step of swizzle:
                 */
-               enum a3xx_color_swap swap = fd6_pipe2swap(prsc->format);
+               enum a3xx_color_swap swap = fd6_pipe2swap(format);
                unsigned char swapswiz[][4] = {
                                [WZYX] = { 0, 1, 2, 3 },
                                [WXYZ] = { 2, 1, 0, 3 },
index bc188ca17a850673cb554b421570f5acab1ef075..321794771b3b0300112b81fdaa2b24ddb28af901 100644 (file)
@@ -40,8 +40,9 @@ enum a6xx_tex_fetchsize fd6_pipe2fetchsize(enum pipe_format format);
 enum a6xx_depth_format fd6_pipe2depth(enum pipe_format format);
 enum a6xx_tex_swiz fd6_pipe2swiz(unsigned swiz);
 
-uint32_t fd6_tex_swiz(struct pipe_resource *prsc, unsigned swizzle_r,
-               unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a);
+uint32_t fd6_tex_swiz(struct pipe_resource *prsc, enum pipe_format format,
+                                         unsigned swizzle_r,
+                                         unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a);
 
 static inline enum a6xx_2d_ifmt
 fd6_ifmt(enum a6xx_color_fmt fmt)
index f7419d8d9ac234ce5f0eadf941d6ea74eeced0c0..cc33a00c4cd4107bec1405f7b5c37e364a872978 100644 (file)
@@ -114,7 +114,7 @@ static void emit_image_tex(struct fd_ringbuffer *ring, unsigned slot,
        OUT_RING(ring, CP_LOAD_STATE6_2_EXT_SRC_ADDR_HI(0));
 
        OUT_RING(ring, A6XX_TEX_CONST_0_FMT(img->fmt) |
-               fd6_tex_swiz(img->prsc, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y,
+               fd6_tex_swiz(img->prsc, img->fmt, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y,
                        PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W) |
                COND(img->srgb, A6XX_TEX_CONST_0_SRGB));
        OUT_RING(ring, A6XX_TEX_CONST_1_WIDTH(img->width) |
index af5f49fd3f2854620491f96ddc7b0812b30bf390..0e2d9ee65d84d3eb2c28185f32745d95c7d81f26 100644 (file)
@@ -246,7 +246,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
        so->texconst0 =
                A6XX_TEX_CONST_0_FMT(fd6_pipe2tex(format)) |
                A6XX_TEX_CONST_0_SAMPLES(fd_msaa_samples(prsc->nr_samples)) |
-               fd6_tex_swiz(prsc, cso->swizzle_r, cso->swizzle_g,
+               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