From dabfc71d36e7d4c29d3699ee15f9c2748a00f3a2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 14 Jun 2019 16:30:29 -0700 Subject: panfrost/midgard: Adjust swizzles for 2D arrays Signed-off-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/midgard/midgard_compile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c index 7d7bda6ee12..6dbfd4ade6e 100644 --- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c +++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c @@ -86,6 +86,7 @@ midgard_block_add_successor(midgard_block *block, midgard_block *successor) #define SWIZZLE_XYXX SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_X, COMPONENT_X) #define SWIZZLE_XYZX SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_Z, COMPONENT_X) #define SWIZZLE_XYZW SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_Z, COMPONENT_W) +#define SWIZZLE_XYXZ SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_X, COMPONENT_Z) #define SWIZZLE_WWWW SWIZZLE(COMPONENT_W, COMPONENT_W, COMPONENT_W, COMPONENT_W) static inline unsigned @@ -1405,6 +1406,15 @@ emit_tex(compiler_context *ctx, nir_tex_instr *instr) ins.alu.mask = expand_writemask(mask_of(nr_comp)); emit_mir_instruction(ctx, ins); + /* To the hardware, z is depth, w is array + * layer. To NIR, z is array layer for a 2D + * array */ + + bool has_array = instr->texture_array_size > 0; + bool is_2d = instr->sampler_dim == GLSL_SAMPLER_DIM_2D; + + if (is_2d && has_array) + position_swizzle = SWIZZLE_XYXZ; } break; -- cgit v1.2.3