panfrost/midgard: Expand texture to 4-channel swizzle
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 10 Jun 2019 16:39:17 +0000 (09:39 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 11 Jun 2019 15:44:18 +0000 (08:44 -0700)
This eliminates some unknowns, clarifies 3D textures, and will maybe
help with array/shadow textures?

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/midgard/disassemble.c
src/gallium/drivers/panfrost/midgard/midgard.h
src/gallium/drivers/panfrost/midgard/midgard_compile.c

index 3d4a56f490881e177a111d08b8f07dc3271c47b5..9e744f6b2875ccfb926788021e98a99ce86783f0 100644 (file)
@@ -1091,8 +1091,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) {
@@ -1108,15 +1107,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);
index 995eaa9a90a2a89c2cdaf0fc6b25ef7cf528077a..5d38f3f54833b91b84fde8184d5187ca2bf0a6b7 100644 (file)
@@ -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;
 
index 4ea8834de2b4f135786954e4d983384036636635..e7c093e9a29ddfbbe827cedf23513caf1231c612 100644 (file)
@@ -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 */