pan/decode: Fix awkward syntax
[mesa.git] / src / panfrost / lib / decode.c
index 78b0a542ae53c4fc91c946452e7372a36e2ad4f4..cbc4cd1093462b89e4cf3501494f4b21ccc60fda 100644 (file)
@@ -487,14 +487,6 @@ pandecode_shared_memory(const struct mali_shared_memory *desc, bool is_compute)
         MEMORY_PROP(desc, scratchpad);
         MEMORY_PROP(desc, shared_memory);
         MEMORY_PROP(desc, unknown1);
-
-        if (desc->scratchpad) {
-                struct pandecode_mapped_memory *smem =
-                        pandecode_find_mapped_gpu_mem_containing(desc->scratchpad);
-
-                pandecode_msg("scratchpad size %u\n", smem->length);
-        }
-
 }
 
 static struct pandecode_fbd
@@ -1218,13 +1210,12 @@ pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no)
  */
 
 static int
-pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_postfix *v, bool varying, char *suffix)
+pandecode_attribute_meta(int count, mali_ptr attribute, bool varying, char *suffix)
 {
         const char *prefix = varying ? "Varying" : "Attribute";
-        mali_ptr p = varying ? v->varying_meta : v->attribute_meta;
 
-        for (int i = 0; i < count; ++i, p += MALI_ATTRIBUTE_LENGTH)
-                DUMP_ADDR(prefix, ATTRIBUTE, p, 1);
+        for (int i = 0; i < count; ++i, attribute += MALI_ATTRIBUTE_LENGTH)
+                DUMP_ADDR(prefix, ATTRIBUTE, attribute, 1);
 
         return count;
 }
@@ -1248,21 +1239,17 @@ pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bo
         /* Decode invocation_count. See the comment before the definition of
          * invocation_count for an explanation.
          */
+        struct MALI_INVOCATION invocation;
+        struct mali_invocation_packed invocation_packed = p->invocation;
+        MALI_INVOCATION_unpack((const uint8_t *) &invocation_packed, &invocation);
 
-        unsigned size_y_shift = bits(p->invocation_shifts, 0, 5);
-        unsigned size_z_shift = bits(p->invocation_shifts, 5, 10);
-        unsigned workgroups_x_shift = bits(p->invocation_shifts, 10, 16);
-        unsigned workgroups_y_shift = bits(p->invocation_shifts, 16, 22);
-        unsigned workgroups_z_shift = bits(p->invocation_shifts, 22, 28);
-        unsigned workgroups_x_shift_2 = bits(p->invocation_shifts, 28, 32);
-
-        unsigned size_x = bits(p->invocation_count, 0, size_y_shift) + 1;
-        unsigned size_y = bits(p->invocation_count, size_y_shift, size_z_shift) + 1;
-        unsigned size_z = bits(p->invocation_count, size_z_shift, workgroups_x_shift) + 1;
+        unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1;
+        unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1;
+        unsigned size_z = bits(invocation.invocations, invocation.size_z_shift, invocation.workgroups_x_shift) + 1;
 
-        unsigned groups_x = bits(p->invocation_count, workgroups_x_shift, workgroups_y_shift) + 1;
-        unsigned groups_y = bits(p->invocation_count, workgroups_y_shift, workgroups_z_shift) + 1;
-        unsigned groups_z = bits(p->invocation_count, workgroups_z_shift, 32) + 1;
+        unsigned groups_x = bits(invocation.invocations, invocation.workgroups_x_shift, invocation.workgroups_y_shift) + 1;
+        unsigned groups_y = bits(invocation.invocations, invocation.workgroups_y_shift, invocation.workgroups_z_shift) + 1;
+        unsigned groups_z = bits(invocation.invocations, invocation.workgroups_z_shift, 32) + 1;
 
         /* Even though we have this decoded, we want to ensure that the
          * representation is "unique" so we don't lose anything by printing only
@@ -1272,30 +1259,17 @@ pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bo
          * decode and pack it ourselves! If it is bit exact with what we
          * decoded, we're good to go. */
 
-        struct mali_vertex_tiler_prefix ref;
+        struct mali_invocation_packed ref;
         panfrost_pack_work_groups_compute(&ref, groups_x, groups_y, groups_z, size_x, size_y, size_z, graphics);
 
-        bool canonical =
-                (p->invocation_count == ref.invocation_count) &&
-                (p->invocation_shifts == ref.invocation_shifts);
-
-        if (!canonical) {
+        if (memcmp(&ref, &invocation_packed, sizeof(ref))) {
                 pandecode_msg("XXX: non-canonical workgroups packing\n");
-                pandecode_msg("expected: %X, %X",
-                                ref.invocation_count,
-                                ref.invocation_shifts);
-
-                pandecode_prop("invocation_count = 0x%" PRIx32, p->invocation_count);
-                pandecode_prop("size_y_shift = %d", size_y_shift);
-                pandecode_prop("size_z_shift = %d", size_z_shift);
-                pandecode_prop("workgroups_x_shift = %d", workgroups_x_shift);
-                pandecode_prop("workgroups_y_shift = %d", workgroups_y_shift);
-                pandecode_prop("workgroups_z_shift = %d", workgroups_z_shift);
-                pandecode_prop("workgroups_x_shift_2 = %d", workgroups_x_shift_2);
+                MALI_INVOCATION_print(pandecode_dump_stream, &invocation, 1 * 2);
         }
 
         /* Regardless, print the decode */
-        pandecode_msg("size (%d, %d, %d), count (%d, %d, %d)\n",
+        fprintf(pandecode_dump_stream,
+                        "Invocation (%d, %d, %d) x (%d, %d, %d)\n",
                         size_x, size_y, size_z,
                         groups_x, groups_y, groups_z);
 
@@ -1365,8 +1339,7 @@ shader_type_for_job(unsigned type)
         case MALI_JOB_TYPE_VERTEX:  return "VERTEX";
         case MALI_JOB_TYPE_TILER:   return "FRAGMENT";
         case MALI_JOB_TYPE_COMPUTE: return "COMPUTE";
-        default:
-                               return "UNKNOWN";
+        default: return "UNKNOWN";
         }
 }
 
@@ -1412,26 +1385,18 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
                                 MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX);
         }
 
-        /* Print shader-db stats. Skip COMPUTE jobs since they are used for
-         * driver-internal purposes with the blob and interfere */
-
-        bool should_shaderdb = type != MALI_JOB_TYPE_COMPUTE;
-
-        if (should_shaderdb) {
-                unsigned nr_threads =
-                        (stats.work_count <= 4) ? 4 :
-                        (stats.work_count <= 8) ? 2 :
-                        1;
-
-                pandecode_log_cont("shader%d - MESA_SHADER_%s shader: "
-                        "%u inst, %u bundles, %u quadwords, "
-                        "%u registers, %u threads, 0 loops, 0:0 spills:fills\n\n\n",
-                        shader_id++,
-                        shader_type_for_job(type),
-                        stats.instruction_count, stats.bundle_count, stats.quadword_count,
-                        stats.work_count, nr_threads);
-        }
+        unsigned nr_threads =
+                (stats.work_count <= 4) ? 4 :
+                (stats.work_count <= 8) ? 2 :
+                1;
 
+        pandecode_log_cont("shader%d - MESA_SHADER_%s shader: "
+                "%u inst, %u bundles, %u quadwords, "
+                "%u registers, %u threads, 0 loops, 0:0 spills:fills\n\n\n",
+                shader_id++,
+                shader_type_for_job(type),
+                stats.instruction_count, stats.bundle_count, stats.quadword_count,
+                stats.work_count, nr_threads);
 
         return stats;
 }
@@ -1779,7 +1744,7 @@ pandecode_vertex_tiler_postfix_pre(
         unsigned max_attr_index = 0;
 
         if (p->attribute_meta)
-                max_attr_index = pandecode_attribute_meta(job_no, attribute_count, p, false, suffix);
+                max_attr_index = pandecode_attribute_meta(attribute_count, p->attribute_meta, false, suffix);
 
         if (p->attributes) {
                 attr_mem = pandecode_find_mapped_gpu_mem_containing(p->attributes);
@@ -1791,7 +1756,7 @@ pandecode_vertex_tiler_postfix_pre(
          * since the GPU will write to it itself */
 
         if (p->varying_meta) {
-                varying_count = pandecode_attribute_meta(job_no, varying_count, p, true, suffix);
+                varying_count = pandecode_attribute_meta(varying_count, p->varying_meta, true, suffix);
         }
 
         if (p->varyings) {
@@ -1986,30 +1951,6 @@ pandecode_primitive_size(union midgard_primitive_size u, bool constant)
         pandecode_log("},\n");
 }
 
-static void
-pandecode_tiler_only_bfr(const struct bifrost_tiler_only *t, int job_no)
-{
-        pandecode_log_cont("{\n");
-        pandecode_indent++;
-
-        /* TODO: gl_PointSize on Bifrost */
-        pandecode_primitive_size(t->primitive_size, true);
-
-        if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5
-            || t->zero6) {
-                pandecode_msg("XXX: tiler only zero tripped\n");
-                pandecode_prop("zero1 = 0x%" PRIx64, t->zero1);
-                pandecode_prop("zero2 = 0x%" PRIx64, t->zero2);
-                pandecode_prop("zero3 = 0x%" PRIx64, t->zero3);
-                pandecode_prop("zero4 = 0x%" PRIx64, t->zero4);
-                pandecode_prop("zero5 = 0x%" PRIx64, t->zero5);
-                pandecode_prop("zero6 = 0x%" PRIx64, t->zero6);
-        }
-
-        pandecode_indent--;
-        pandecode_log("},\n");
-}
-
 static int
 pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h,
                                 const struct pandecode_mapped_memory *mem,
@@ -2039,15 +1980,26 @@ pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
         struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload);
 
         pandecode_vertex_tiler_postfix_pre(&t->postfix, job_no, h->job_type, "", true, gpu_id);
-        pandecode_tiler_meta(t->tiler.tiler_meta, job_no);
+        pandecode_tiler_meta(t->tiler_meta, job_no);
 
         pandecode_log("struct bifrost_payload_tiler payload_%"PRIx64"_%d = {\n", payload, job_no);
         pandecode_indent++;
 
         pandecode_vertex_tiler_prefix(&t->prefix, job_no, false);
 
-        pandecode_log(".tiler = ");
-        pandecode_tiler_only_bfr(&t->tiler, job_no);
+        /* TODO: gl_PointSize on Bifrost */
+        pandecode_primitive_size(t->primitive_size, true);
+
+        if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5
+            || t->zero6) {
+                pandecode_msg("XXX: tiler only zero tripped\n");
+                pandecode_prop("zero1 = 0x%" PRIx64, t->zero1);
+                pandecode_prop("zero2 = 0x%" PRIx64, t->zero2);
+                pandecode_prop("zero3 = 0x%" PRIx64, t->zero3);
+                pandecode_prop("zero4 = 0x%" PRIx64, t->zero4);
+                pandecode_prop("zero5 = 0x%" PRIx64, t->zero5);
+                pandecode_prop("zero6 = 0x%" PRIx64, t->zero6);
+        }
 
         pandecode_vertex_tiler_postfix(&t->postfix, job_no, true);