pan/decode: Include address in union mali_attr
[mesa.git] / src / panfrost / pandecode / decode.c
index 9918ba622621e5df7e6b2d26993b50d097eb702c..148be10fdc47bd5a95397825821d8e3c00bc2c82 100644 (file)
@@ -449,22 +449,6 @@ pandecode_wrap_mode(enum mali_wrap_mode op)
 }
 #undef DEFINE_CASE
 
-#define DEFINE_CASE(name) case MALI_TEX_## name: return "MALI_TEX_" #name
-static char *
-pandecode_texture_type(enum mali_texture_type type)
-{
-        switch (type) {
-                DEFINE_CASE(1D);
-                DEFINE_CASE(2D);
-                DEFINE_CASE(3D);
-                DEFINE_CASE(CUBE);
-
-        default:
-                unreachable("Unknown case");
-        }
-}
-#undef DEFINE_CASE
-
 #define DEFINE_CASE(name) case MALI_MFBD_BLOCK_## name: return "MALI_MFBD_BLOCK_" #name
 static char *
 pandecode_mfbd_block_format(enum mali_mfbd_block_format fmt)
@@ -1245,35 +1229,23 @@ pandecode_attributes(const struct pandecode_mapped_memory *mem,
 
         union mali_attr *attr = pandecode_fetch_gpu_mem(mem, addr, sizeof(union mali_attr) * count);
 
-        char base[128];
-        snprintf(base, sizeof(base), "%s_data_%d%s", prefix, job_no, suffix);
+        pandecode_log("union mali_attr %s_%d[] = {\n", prefix, job_no);
+        pandecode_indent++;
 
         for (int i = 0; i < count; ++i) {
+                pandecode_log("{\n");
+                pandecode_indent++;
+
                 enum mali_attr_mode mode = attr[i].elements & 7;
 
                 if (mode == MALI_ATTR_UNUSED)
-                        continue;
+                        pandecode_msg("XXX: unused attribute record\n");
 
                 mali_ptr raw_elements = attr[i].elements & ~7;
-
-                /* TODO: Do we maybe want to dump the attribute values
-                 * themselves given the specified format? Or is that too hard?
-                 * */
-
                 char *a = pointer_as_memory_reference(raw_elements);
-                pandecode_log("mali_ptr %s_%d_p = %s;\n", base, i, a);
+                pandecode_prop("elements = (%s) | %s", a, pandecode_attr_mode(mode));
                 free(a);
-        }
-
-        pandecode_log("union mali_attr %s_%d[] = {\n", prefix, job_no);
-        pandecode_indent++;
-
-        for (int i = 0; i < count; ++i) {
-                pandecode_log("{\n");
-                pandecode_indent++;
 
-                unsigned mode = attr[i].elements & 7;
-                pandecode_prop("elements = (%s_%d_p) | %s", base, i, pandecode_attr_mode(mode));
                 pandecode_prop("shift = %d", attr[i].shift);
                 pandecode_prop("extra_flags = %d", attr[i].extra_flags);
                 pandecode_prop("stride = 0x%" PRIx32, attr[i].stride);
@@ -1771,8 +1743,40 @@ pandecode_texture(mali_ptr u,
 
         /* See the definiton of enum mali_texture_type */
 
-        unsigned dimension =
-                (f.type == MALI_TEX_CUBE) ? 2 : f.type;
+        bool is_cube = f.type == MALI_TEX_CUBE;
+        unsigned dimension = is_cube ? 2 : f.type;
+
+        pandecode_make_indent();
+
+        /* TODO: Are there others? */
+        bool is_zs = f.format == MALI_Z32_UNORM;
+
+        /* Recall Z/S switched the meaning of linear/tiled .. */
+        if (is_zs && f.layout == MALI_TEXTURE_LINEAR)
+                pandecode_msg("XXX: depth/stencil cannot be tiled\n");
+
+        /* Print the layout. Default is linear; a modifier can denote AFBC or
+         * u-interleaved/tiled modes */
+
+        if (f.layout == MALI_TEXTURE_AFBC)
+                pandecode_log_cont("afbc");
+        else if (f.layout == MALI_TEXTURE_TILED)
+                pandecode_log_cont(is_zs ? "linear" : "tiled");
+        else if (f.layout == MALI_TEXTURE_LINEAR)
+                pandecode_log_cont("linear");
+        else
+                pandecode_msg("XXX: invalid texture layout 0x%X\n", f.layout);
+
+        pandecode_swizzle(t->swizzle, f.format);
+        pandecode_log_cont(" ");
+
+        /* Distinguish cube/2D with modifier */
+
+        if (is_cube)
+                pandecode_log_cont("cube ");
+
+        pandecode_format_short(f.format, f.srgb);
+        pandecode_swizzle(f.swizzle, f.format);
 
         /* All four width/height/depth/array_size dimensions are present
          * regardless of the type of texture, but it is an error to have
@@ -1787,7 +1791,7 @@ pandecode_texture(mali_ptr u,
 
         /* Print only the dimensions that are actually there */
 
-        pandecode_log("dim: %d", t->width + 1);
+        pandecode_log_cont(": %d", t->width + 1);
 
         if (dimension >= 2)
                 pandecode_log_cont("x%u", t->height + 1);
@@ -1803,17 +1807,6 @@ pandecode_texture(mali_ptr u,
 
         pandecode_log_cont("\n");
 
-        pandecode_log(".format = {\n");
-        pandecode_indent++;
-
-        pandecode_log(".format = ");
-        pandecode_format_short(f.format, f.srgb);
-        pandecode_swizzle(f.swizzle, f.format);
-        pandecode_log_cont(",\n");
-
-        pandecode_prop("type = %s", pandecode_texture_type(f.type));
-        pandecode_prop("layout = %" PRId32, f.layout);
-
         if (f.unknown1 | f.zero) {
                 pandecode_msg("XXX: texture format zero tripped\n");
                 pandecode_prop("unknown1 = %" PRId32, f.unknown1);
@@ -1825,9 +1818,6 @@ pandecode_texture(mali_ptr u,
                 pandecode_prop("unknown2 = %" PRId32, f.unknown1);
         }
 
-        pandecode_indent--;
-        pandecode_log("},\n");
-
         if (t->swizzle_zero) {
                 pandecode_msg("XXX: swizzle zero tripped\n");
                 pandecode_prop("swizzle_zero = %d", t->swizzle_zero);