v3d: Pass the whole clif_dump structure to v3d_print_group().
[mesa.git] / src / gallium / drivers / vc4 / vc4_cl_dump.c
index a55c04fc144538954ecc98d10e34c059d9fd67b7..c5be426d132a667a2fce226f64d2deef8e85bbe0 100644 (file)
  */
 
 #include "util/u_math.h"
+#include "util/u_prim.h"
 #include "util/macros.h"
-#include "vc4_context.h"
+#include "vc4_cl_dump.h"
+#include "kernel/vc4_packet.h"
 
-#define PACKET(name, size) [name] = { #name, size }
-
-static const struct packet_info {
-        const char *name;
-        uint8_t size;
-} packet_info[] = {
-        PACKET(VC4_PACKET_HALT, 1),
-        PACKET(VC4_PACKET_NOP, 1),
-
-        PACKET(VC4_PACKET_FLUSH, 1),
-        PACKET(VC4_PACKET_FLUSH_ALL, 1),
-        PACKET(VC4_PACKET_START_TILE_BINNING, 1),
-        PACKET(VC4_PACKET_INCREMENT_SEMAPHORE, 1),
-        PACKET(VC4_PACKET_WAIT_ON_SEMAPHORE, 1),
-
-        PACKET(VC4_PACKET_BRANCH, 5),
-        PACKET(VC4_PACKET_BRANCH_TO_SUB_LIST, 5),
-
-        PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER, 1),
-        PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF, 1),
-        PACKET(VC4_PACKET_STORE_FULL_RES_TILE_BUFFER, 5),
-        PACKET(VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER, 5),
-        PACKET(VC4_PACKET_STORE_TILE_BUFFER_GENERAL, 7),
-        PACKET(VC4_PACKET_LOAD_TILE_BUFFER_GENERAL, 7),
-
-        PACKET(VC4_PACKET_GL_INDEXED_PRIMITIVE, 14),
-        PACKET(VC4_PACKET_GL_ARRAY_PRIMITIVE, 10),
-
-        PACKET(VC4_PACKET_COMPRESSED_PRIMITIVE, 48),
-        PACKET(VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE, 49),
-
-        PACKET(VC4_PACKET_PRIMITIVE_LIST_FORMAT, 2),
-
-        PACKET(VC4_PACKET_GL_SHADER_STATE, 5),
-        PACKET(VC4_PACKET_NV_SHADER_STATE, 5),
-        PACKET(VC4_PACKET_VG_SHADER_STATE, 5),
-
-        PACKET(VC4_PACKET_CONFIGURATION_BITS, 4),
-        PACKET(VC4_PACKET_FLAT_SHADE_FLAGS, 5),
-        PACKET(VC4_PACKET_POINT_SIZE, 5),
-        PACKET(VC4_PACKET_LINE_WIDTH, 5),
-        PACKET(VC4_PACKET_RHT_X_BOUNDARY, 3),
-        PACKET(VC4_PACKET_DEPTH_OFFSET, 5),
-        PACKET(VC4_PACKET_CLIP_WINDOW, 9),
-        PACKET(VC4_PACKET_VIEWPORT_OFFSET, 5),
-        PACKET(VC4_PACKET_Z_CLIPPING, 9),
-        PACKET(VC4_PACKET_CLIPPER_XY_SCALING, 9),
-        PACKET(VC4_PACKET_CLIPPER_Z_SCALING, 9),
-
-        PACKET(VC4_PACKET_TILE_BINNING_MODE_CONFIG, 16),
-        PACKET(VC4_PACKET_TILE_RENDERING_MODE_CONFIG, 11),
-        PACKET(VC4_PACKET_CLEAR_COLORS, 14),
-        PACKET(VC4_PACKET_TILE_COORDINATES, 3),
-
-        PACKET(VC4_PACKET_GEM_HANDLES, 9),
-};
+#include "broadcom/cle/v3d_decoder.h"
+#include "broadcom/clif/clif_dump.h"
 
 void
 vc4_dump_cl(void *cl, uint32_t size, bool is_render)
 {
+        struct v3d_device_info devinfo = {
+                /* While the driver supports V3D 2.1 and 2.6, we haven't split
+                 * off a 2.6 XML yet (there are a couple of fields different
+                 * in render target formatting)
+                 */
+                .ver = 21,
+        };
+        struct v3d_spec *spec = v3d_spec_load(&devinfo);
+
+        struct clif_dump *clif = clif_dump_init(&devinfo, stderr, NULL, NULL);
+
         uint32_t offset = 0, hw_offset = 0;
-        uint8_t *cmds = cl;
+        uint8_t *p = cl;
 
         while (offset < size) {
-                uint8_t header = cmds[offset];
+                struct v3d_group *inst = v3d_spec_find_instruction(spec, p);
+                uint8_t header = *p;
+                uint32_t length;
 
-                if (header > ARRAY_SIZE(packet_info) ||
-                    !packet_info[header].name) {
+                if (inst == NULL) {
                         fprintf(stderr, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n",
                                 offset, hw_offset, header, header);
                         return;
                 }
 
-                const struct packet_info *p = packet_info + header;
+                length = v3d_group_get_length(inst);
+
                 fprintf(stderr, "0x%08x 0x%08x: 0x%02x %s\n",
-                        offset,
-                        header != VC4_PACKET_GEM_HANDLES ? hw_offset : 0,
-                        header, p->name);
+                        offset, hw_offset, header, v3d_group_get_name(inst));
 
-                for (uint32_t i = 1; i < p->size; i++) {
-                        if (offset + i >= size) {
-                                fprintf(stderr, "0x%08x 0x%08x: CL overflow!\n",
-                                        offset + i, hw_offset + i);
-                                return;
-                        }
-                        fprintf(stderr, "0x%08x 0x%08x: 0x%02x\n",
-                                offset + i,
-                                header != VC4_PACKET_GEM_HANDLES ? hw_offset + i : 0,
-                                cmds[offset + i]);
-                }
+                v3d_print_group(clif, inst, offset, p, "");
 
                 switch (header) {
                 case VC4_PACKET_HALT:
@@ -124,9 +73,12 @@ vc4_dump_cl(void *cl, uint32_t size, bool is_render)
                         break;
                 }
 
-                offset += p->size;
+                offset += length;
                 if (header != VC4_PACKET_GEM_HANDLES)
-                        hw_offset += p->size;
+                        hw_offset += length;
+                p += length;
         }
+
+        clif_dump_destroy(clif);
 }