ca1b9a3152810feb7749e3b971bba0480eda6819
[mesa.git] / src / gallium / drivers / vc4 / vc4_cl_dump.c
1 /*
2 * Copyright © 2014 Broadcom
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "util/u_math.h"
25 #include "util/u_prim.h"
26 #include "util/macros.h"
27 #include "vc4_cl_dump.h"
28 #include "kernel/vc4_packet.h"
29
30 #include "broadcom/cle/v3d_decoder.h"
31
32 void
33 vc4_dump_cl(void *cl, uint32_t size, bool is_render)
34 {
35 struct v3d_device_info devinfo = {
36 /* While the driver supports V3D 2.1 and 2.6, we haven't split
37 * off a 2.6 XML yet (there are a couple of fields different
38 * in render target formatting)
39 */
40 .ver = 21,
41 };
42 struct v3d_spec *spec = v3d_spec_load(&devinfo);
43
44 uint32_t offset = 0, hw_offset = 0;
45 uint8_t *p = cl;
46
47 while (offset < size) {
48 struct v3d_group *inst = v3d_spec_find_instruction(spec, p);
49 uint8_t header = *p;
50 uint32_t length;
51
52 if (inst == NULL) {
53 fprintf(stderr, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n",
54 offset, hw_offset, header, header);
55 return;
56 }
57
58 length = v3d_group_get_length(inst);
59
60 fprintf(stderr, "0x%08x 0x%08x: 0x%02x %s\n",
61 offset, hw_offset, header, v3d_group_get_name(inst));
62
63 v3d_print_group(stderr, inst, offset, p, "");
64
65 switch (header) {
66 case VC4_PACKET_HALT:
67 case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF:
68 return;
69 default:
70 break;
71 }
72
73 offset += length;
74 if (header != VC4_PACKET_GEM_HANDLES)
75 hw_offset += length;
76 p += length;
77 }
78 }
79