freedreno/a6xx: Add format argument to fd6_tex_swiz()
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>
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) |
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user