pan/midgard: Identify and disassemble indirect texture/sampler
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 19 Aug 2019 15:10:28 +0000 (08:10 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 21 Aug 2019 17:41:15 +0000 (10:41 -0700)
A pair of special flags can turn the texture/sampler handle fields into
register selects. This means code like:

   texture(uTextures[hr28.w], ...)

can be compiled to something like:

   texture ..., fsampler[hr28.w], texture[hr28.w]

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

index eba9cb1505dcbe80cccc6e10d3ad351bdca86a78..be26a9c3686929333069810a0d85c2c30cf1b11a 100644 (file)
@@ -1208,8 +1208,6 @@ print_texture_word(uint32_t *word, unsigned tabs)
         /* Specific format in question */
         print_texture_format(texture->format);
 
-        assert(texture->zero == 0);
-
         /* Instruction "modifiers" parallel the ALU instructions. */
 
         if (texture->shadow)
@@ -1230,11 +1228,25 @@ print_texture_word(uint32_t *word, unsigned tabs)
         print_mask_4(texture->mask);
         printf(", ");
 
-        printf("texture%d, ", texture->texture_handle);
+        if (texture->texture_register) {
+                printf("texture[");
+                print_texture_reg_select(texture->texture_handle);
+                printf("], ");
+        } else {
+                printf("texture%d, ", texture->texture_handle);
+        }
 
         /* Print the type, GL style */
-        printf("%c", sampler_type_name(texture->sampler_type));
-        printf("sampler%d", texture->sampler_handle);
+        printf("%csampler", sampler_type_name(texture->sampler_type));
+
+        if (texture->sampler_register) {
+                printf("[");
+                print_texture_reg_select(texture->sampler_handle);
+                printf("]");
+        } else {
+                printf("%d", texture->sampler_handle);
+        }
+
         print_swizzle_vec4(texture->swizzle, false, false);
         printf(", ");
 
index 753da1c064ed756db957ff924941e0e4908eb869..f1235ec513039201b51b0f7f4497517f7b8e4f0c 100644 (file)
@@ -628,7 +628,13 @@ __attribute__((__packed__))
         unsigned last  : 1;
 
         enum mali_texture_type format : 2;
-        unsigned zero : 2;
+
+        /* Are sampler_handle/texture_handler respectively set by registers? If
+         * true, the lower 8-bits of the respective field is a register word.
+         * If false, they are an immediate */
+
+        unsigned sampler_register : 1;
+        unsigned texture_register : 1;
 
         /* Is a register used to specify the
          * LOD/bias/offset? If set, use the `bias` field as
@@ -693,6 +699,10 @@ __attribute__((__packed__))
         unsigned bias : 8;
         signed bias_int  : 8;
 
+        /* If sampler/texture_register is set, the bottom 8-bits are
+         * midgard_tex_register_select and the top 8-bits are zero. If they are
+         * clear, they are immediate texture indices */
+
         unsigned sampler_handle : 16;
         unsigned texture_handle : 16;
 }