v3d: Use a short, underscored name for packets in CLIF/CL dumping.
[mesa.git] / src / broadcom / clif / v3dx_dump.c
index b1d16551d7144fbca3dc414f6874edbd9cb2dfbe..b10b1c92a5ac8945c61ecf3d9590c8efc1fedf4f 100644 (file)
  * IN THE SOFTWARE.
  */
 
+#include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
+#include "util/macros.h"
 #include "broadcom/cle/v3d_decoder.h"
 #include "clif_dump.h"
 #include "clif_private.h"
 #include "broadcom/cle/v3dx_pack.h"
 #include "broadcom/common/v3d_macros.h"
 
+static char *
+clif_name(const char *xml_name)
+{
+        char *name = malloc(strlen(xml_name) + 1);
+
+        int j = 0;
+        for (int i = 0; i < strlen(xml_name); i++) {
+                if (xml_name[i] == ' ') {
+                        name[j++] = '_';
+                } else if (xml_name[i] == '(' || xml_name[i] == ')') {
+                        /* skip */
+                } else {
+                        name[j++] = toupper(xml_name[i]);
+                }
+        }
+        name[j++] = 0;
+
+        return name;
+}
+
 bool
 v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
                        const uint8_t *cl, uint32_t *size)
@@ -46,8 +69,10 @@ v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
 
         *size = v3d_group_get_length(inst);
 
-        out(clif, "%s\n", v3d_group_get_name(inst));
-        v3d_print_group(clif->out, inst, 0, cl, "");
+        char *name = clif_name(v3d_group_get_name(inst));
+        out(clif, "%s\n", name);
+        free(name);
+        v3d_print_group(clif, inst, 0, cl);
 
         switch (*cl) {
         case V3DX(GL_SHADER_STATE_opcode): {
@@ -87,10 +112,11 @@ v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
                 cl += *size;
 
                 for (int i = 0; i < values.number_of_16_bit_output_data_specs_following; i++) {
-                        v3d_print_group(clif->out, spec, 0, cl, "");
+                        v3d_print_group(clif, spec, 0, cl);
                         cl += v3d_group_get_length(spec);
                         *size += v3d_group_get_length(spec);
                 }
+                out(clif, "@format ctrllist\n");
                 break;
         }
 #else /* V3D_VERSION < 40 */
@@ -107,13 +133,13 @@ v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
                 cl += *size;
 
                 for (int i = 0; i < values.number_of_16_bit_output_data_specs_following; i++) {
-                        v3d_print_group(clif->out, spec, 0, cl, "");
+                        v3d_print_group(clif, spec, 0, cl);
                         cl += v3d_group_get_length(spec);
                         *size += v3d_group_get_length(spec);
                 }
 
                 for (int i = 0; i < values.number_of_32_bit_output_buffer_address_following; i++) {
-                        v3d_print_group(clif->out, addr, 0, cl, "");
+                        v3d_print_group(clif, addr, 0, cl);
                         cl += v3d_group_get_length(addr);
                         *size += v3d_group_get_length(addr);
                 }
@@ -138,26 +164,3 @@ v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
 
         return true;
 }
-
-void
-v3dX(clif_dump_gl_shader_state_record)(struct clif_dump *clif,
-                                       struct reloc_worklist_entry *reloc,
-                                       void *vaddr)
-{
-        struct v3d_group *state = v3d_spec_find_struct(clif->spec,
-                                                       "GL Shader State Record");
-        struct v3d_group *attr = v3d_spec_find_struct(clif->spec,
-                                                      "GL Shader State Attribute Record");
-        assert(state);
-        assert(attr);
-
-        out(clif, "GL Shader State Record at 0x%08x\n", reloc->addr);
-        v3d_print_group(clif->out, state, 0, vaddr, "");
-        vaddr += v3d_group_get_length(state);
-
-        for (int i = 0; i < reloc->shader_state.num_attrs; i++) {
-                out(clif, "  Attribute %d\n", i);
-                v3d_print_group(clif->out, attr, 0, vaddr, "");
-                vaddr += v3d_group_get_length(attr);
-        }
-}