[Mesa-dev] [PATCH 7/8] panfrost/midgard: Adjust swizzles for 2D arrays
Alyssa Rosenzweig
alyssa.rosenzweig at collabora.com
Fri Jun 14 23:37:15 UTC 2019
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
src/gallium/drivers/panfrost/midgard/midgard_compile.c | 10 ++++++++++
1 file changed, 10 insertions(+)
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;
--
2.20.1
More information about the mesa-dev
mailing list