[Mesa-dev] [PATCH 11/18] panfrost/midgard/disasm: Correctly dump bias/LOD

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


Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
 .../drivers/panfrost/midgard/disassemble.c    | 32 +++++++++++--------
 .../drivers/panfrost/midgard/midgard.h        |  5 ++-
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/disassemble.c b/src/gallium/drivers/panfrost/midgard/disassemble.c
index c12b2f24e70..fea37e4c595 100644
--- a/src/gallium/drivers/panfrost/midgard/disassemble.c
+++ b/src/gallium/drivers/panfrost/midgard/disassemble.c
@@ -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
@@ -1075,8 +1081,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");
@@ -1090,11 +1095,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);
@@ -1143,9 +1143,17 @@ 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 /* %X,%X */, ", operand, bias,
+                                texture->bias, texture->bias_int);
         }
 
         printf("\n");
@@ -1158,15 +1166,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 ||
diff --git a/src/gallium/drivers/panfrost/midgard/midgard.h b/src/gallium/drivers/panfrost/midgard/midgard.h
index 354d611e9df..9957ac5e415 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard.h
+++ b/src/gallium/drivers/panfrost/midgard/midgard.h
@@ -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;
-- 
2.20.1



More information about the mesa-dev mailing list