panfrost/midgard/disasm: Correctly dump bias/LOD
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 10 Jun 2019 19:12:49 +0000 (12:12 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 11 Jun 2019 15:44:19 +0000 (08:44 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/midgard/disassemble.c
src/gallium/drivers/panfrost/midgard/midgard.h

index 7543df3fcf5b14b4e2c13a843b2060b5c4329e2a..d1bc6ad0e3afafb111e8e220f4ab49a88ecffbc0 100644 (file)
@@ -1058,6 +1058,12 @@ print_texture_op(unsigned op)
         }
 }
 
+static bool
+texture_op_takes_bias(unsigned op)
+{
+        return op == TEXTURE_OP_NORMAL;
+}
+
 #undef DEFINE_CASE
 
 static void
@@ -1071,8 +1077,7 @@ print_texture_word(uint32_t *word, unsigned tabs)
         /* Specific format in question */
         print_texture_format(texture->format);
 
-        /* Instruction "modifiers" parallel the ALU instructions. First group
-         * are modifiers that act alone */
+        /* Instruction "modifiers" parallel the ALU instructions. */
 
         if (!texture->filter)
                 printf(".raw");
@@ -1086,11 +1091,6 @@ print_texture_word(uint32_t *word, unsigned tabs)
         if (texture->last)
                 printf(".last");
 
-        /* Second set are modifiers which take an extra argument each */
-
-        if (texture->bias)
-                printf(".bias");
-
         printf(" ");
 
         print_texture_reg(texture->out_full, texture->out_reg_select, texture->out_upper);
@@ -1139,9 +1139,16 @@ print_texture_word(uint32_t *word, unsigned tabs)
 
         if (texture->lod_register) {
                 /* TODO: Decode */
-                printf("lod/bias/grad reg 0x%X, ", texture->bias);
-        } else if (texture->bias) {
-                printf("%f /* %d */, ", texture->bias / 256.0f, texture->bias);
+                printf("lod/bias/grad reg 0x%X (%X), ", texture->bias, texture->bias_int);
+        } else if (texture->bias || texture->bias_int) {
+                int bias_int = texture->bias_int;
+                float bias_frac = texture->bias / 256.0f;
+                float bias = bias_int + bias_frac;
+
+                bool is_bias = texture_op_takes_bias(texture->op);
+                char operand = is_bias ? '+' : '=';
+
+                printf("lod %c %f, ", operand, bias);
         }
 
         printf("\n");
@@ -1154,15 +1161,13 @@ print_texture_word(uint32_t *word, unsigned tabs)
                         texture->unknown4 ||
                         texture->unknownA ||
                         texture->unknownB ||
-                        texture->unknown8 ||
-                        texture->unknown9) {
+                        texture->unknown8) {
                 printf("// unknown2 = 0x%x\n", texture->unknown2);
                 printf("// unknown3 = 0x%x\n", texture->unknown3);
                 printf("// unknown4 = 0x%x\n", texture->unknown4);
                 printf("// unknownA = 0x%x\n", texture->unknownA);
                 printf("// unknownB = 0x%x\n", texture->unknownB);
                 printf("// unknown8 = 0x%x\n", texture->unknown8);
-                printf("// unknown9 = 0x%x\n", texture->unknown9);
         }
 
         if (texture->offset_unknown4 ||
index 354d611e9df239db4e9f748802b428638bb6e3a1..9957ac5e41518c44aa089a2e9ac404f5fcd6a7ad 100644 (file)
@@ -577,9 +577,8 @@ __attribute__((__packed__))
          * fragment/vertex shader respectively. Compute as int(2^8 * biasf).
          *
          * For texel fetch, this is the LOD as is. */
-        unsigned bias  : 8;
-
-        unsigned unknown9  : 8;
+        unsigned bias : 8;
+        unsigned bias_int  : 8;
 
         unsigned texture_handle : 16;
         unsigned sampler_handle : 16;