freedreno: a2xx: fix non-etc1 cubemaps
authorJonathan Marek <jonathan@marek.ca>
Thu, 1 Aug 2019 18:36:41 +0000 (14:36 -0400)
committerJonathan Marek <jonathan@marek.ca>
Fri, 2 Aug 2019 15:58:22 +0000 (15:58 +0000)
Not sure how this happened, but apparently all cubemaps need swapped XY.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Rob Clark <robdclark@chromium.org>
src/gallium/drivers/freedreno/a2xx/fd2_program.c
src/gallium/drivers/freedreno/a2xx/fd2_texture.c
src/gallium/drivers/freedreno/a2xx/fd2_texture.h
src/gallium/drivers/freedreno/a2xx/ir2_nir.c
src/gallium/drivers/freedreno/a2xx/ir2_private.h

index f09b740..50c0f67 100644 (file)
@@ -210,10 +210,6 @@ patch_fetches(struct fd_context *ctx, struct ir2_shader_info *info,
                assert(instr->opc == TEX_FETCH);
                instr->tex.const_idx = fd2_get_const_idx(ctx, tex, fi->tex.samp_id);
                instr->tex.src_swiz = fi->tex.src_swiz;
-               if (fd2_texture_swap_xy(tex, fi->tex.samp_id)) {
-                       unsigned x = instr->tex.src_swiz;
-                       instr->tex.src_swiz = (x & 0x30) | (x & 3) << 2 | (x >> 2 & 3);
-               }
        }
 }
 
index 16bdf6c..3e3add7 100644 (file)
@@ -238,13 +238,6 @@ fd2_get_const_idx(struct fd_context *ctx, struct fd_texture_stateobj *tex,
        return samp_id + ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers;
 }
 
-/* for reasons unknown, it appears ETC1 cubemap needs swapped xy coordinates */
-bool fd2_texture_swap_xy(struct fd_texture_stateobj *tex, unsigned samp_id)
-{
-       return tex->textures[samp_id]->format == PIPE_FORMAT_ETC1_RGB8 &&
-               tex->textures[samp_id]->texture->target == PIPE_TEXTURE_CUBE;
-}
-
 void
 fd2_texture_init(struct pipe_context *pctx)
 {
index 045be08..b7ade85 100644 (file)
@@ -60,8 +60,6 @@ fd2_pipe_sampler_view(struct pipe_sampler_view *pview)
 unsigned fd2_get_const_idx(struct fd_context *ctx,
                struct fd_texture_stateobj *tex, unsigned samp_id);
 
-bool fd2_texture_swap_xy(struct fd_texture_stateobj *tex, unsigned samp_id);
-
 void fd2_texture_init(struct pipe_context *pctx);
 
 #endif /* FD2_TEXTURE_H_ */
index eefd597..95047d9 100644 (file)
@@ -716,7 +716,7 @@ emit_tex(struct ir2_context *ctx, nir_tex_instr * tex)
 
        instr = ir2_instr_create_fetch(ctx, &tex->dest, TEX_FETCH);
        instr->src[0] = src_coord;
-       instr->src[0].swizzle = is_cube ? IR2_SWIZZLE_XYW : 0;
+       instr->src[0].swizzle = is_cube ? IR2_SWIZZLE_YXW : 0;
        instr->fetch.tex.is_cube = is_cube;
        instr->fetch.tex.is_rect = is_rect;
        instr->fetch.tex.samp_id = tex->sampler_index;
index 57c35ae..5f71731 100644 (file)
@@ -207,7 +207,7 @@ enum {
 
        IR2_SWIZZLE_ZW = 2 << 0 | 2 << 2,
 
-       IR2_SWIZZLE_XYW = 0 << 0 | 0 << 2 | 1 << 4,
+       IR2_SWIZZLE_YXW = 1 << 0 | 3 << 2 | 1 << 4,
 
        IR2_SWIZZLE_XXXX = 0 << 0 | 3 << 2 | 2 << 4 | 1 << 6,
        IR2_SWIZZLE_YYYY = 1 << 0 | 0 << 2 | 3 << 4 | 2 << 6,