[Mesa-dev] [PATCH 01/18] panfrost/midgard: Expand texture to 4-channel swizzle

Alyssa Rosenzweig alyssa.rosenzweig at collabora.com
Mon Jun 10 22:01:29 UTC 2019


This eliminates some unknowns, clarifies 3D textures, and will maybe
help with array/shadow textures?

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
 .../drivers/panfrost/midgard/disassemble.c       |  7 ++-----
 src/gallium/drivers/panfrost/midgard/midgard.h   |  8 ++------
 .../drivers/panfrost/midgard/midgard_compile.c   | 16 +++-------------
 3 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/disassemble.c b/src/gallium/drivers/panfrost/midgard/disassemble.c
index d1031ef41d2..52272967ea0 100644
--- a/src/gallium/drivers/panfrost/midgard/disassemble.c
+++ b/src/gallium/drivers/panfrost/midgard/disassemble.c
@@ -1095,8 +1095,7 @@ print_texture_word(uint32_t *word, unsigned tabs)
         printf(", ");
 
         print_texture_reg(/*texture->in_reg_full*/true, texture->in_reg_select, texture->in_reg_upper);
-        printf(".%c%c, ", "xyzw"[texture->in_reg_swizzle_left],
-               "xyzw"[texture->in_reg_swizzle_right]);
+        print_swizzle_vec4(texture->in_reg_swizzle, false, false);
 
         /* TODO: can offsets be full words? */
         if (texture->has_offset) {
@@ -1112,15 +1111,13 @@ print_texture_word(uint32_t *word, unsigned tabs)
         /* While not zero in general, for these simple instructions the
          * following unknowns are zero, so we don't include them */
 
-        if (texture->unknown1 ||
-                        texture->unknown2 ||
+        if (texture->unknown2 ||
                         texture->unknown3 ||
                         texture->unknown4 ||
                         texture->unknownA ||
                         texture->unknownB ||
                         texture->unknown8 ||
                         texture->unknown9) {
-                printf("// unknown1 = 0x%x\n", texture->unknown1);
                 printf("// unknown2 = 0x%x\n", texture->unknown2);
                 printf("// unknown3 = 0x%x\n", texture->unknown3);
                 printf("// unknown4 = 0x%x\n", texture->unknown4);
diff --git a/src/gallium/drivers/panfrost/midgard/midgard.h b/src/gallium/drivers/panfrost/midgard/midgard.h
index 995eaa9a90a..5d38f3f5483 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard.h
+++ b/src/gallium/drivers/panfrost/midgard/midgard.h
@@ -505,13 +505,9 @@ __attribute__((__packed__))
 
         unsigned in_reg_select : 1;
         unsigned in_reg_upper  : 1;
+        unsigned in_reg_swizzle : 8;
 
-        unsigned in_reg_swizzle_left : 2;
-        unsigned in_reg_swizzle_right : 2;
-
-        unsigned unknown1 : 2;
-
-        unsigned unknown8  : 4;
+        unsigned unknown8  : 2;
 
         unsigned out_full  : 1;
 
diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index 4ea8834de2b..e7c093e9a29 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -1372,12 +1372,13 @@ emit_tex(compiler_context *ctx, nir_tex_instr *instr)
                         .texture_handle = texture_index,
                         .sampler_handle = sampler_index,
 
-                        /* TODO: Don't force xyzw */
-                        .swizzle = SWIZZLE(COMPONENT_X, COMPONENT_Y, COMPONENT_Z, COMPONENT_W),
+                        /* TODO: Regalloc it in */
+                        .swizzle = SWIZZLE_XYZW,
                         .mask = 0xF,
 
                         /* TODO: half */
                         //.in_reg_full = 1,
+                        .in_reg_swizzle = SWIZZLE_XYZW,
                         .out_full = 1,
 
                         .filter = 1,
@@ -1394,17 +1395,6 @@ emit_tex(compiler_context *ctx, nir_tex_instr *instr)
         ins.texture.in_reg_select = in_reg;
         ins.texture.out_reg_select = out_reg;
 
-        /* TODO: Dynamic swizzle input selection, half-swizzles? */
-        if (instr->sampler_dim == GLSL_SAMPLER_DIM_3D) {
-                ins.texture.in_reg_swizzle_right = COMPONENT_X;
-                ins.texture.in_reg_swizzle_left = COMPONENT_Y;
-                //ins.texture.in_reg_swizzle_third = COMPONENT_Z;
-        } else {
-                ins.texture.in_reg_swizzle_left = COMPONENT_X;
-                ins.texture.in_reg_swizzle_right = COMPONENT_Y;
-                //ins.texture.in_reg_swizzle_third = COMPONENT_X;
-        }
-
         emit_mir_instruction(ctx, ins);
 
         /* Simultaneously alias the destination and emit a move for it. The move will be eliminated if possible */
-- 
2.20.1



More information about the mesa-dev mailing list