2 * Copyright © 2014 Broadcom
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:
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
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
24 #include "util/u_math.h"
25 #include "util/macros.h"
26 #include "vc4_context.h"
28 #define dump_VC4_PACKET_LINE_WIDTH dump_float
29 #define dump_VC4_PACKET_POINT_SIZE dump_float
32 dump_float(void *cl
, uint32_t offset
, uint32_t hw_offset
)
34 void *f
= cl
+ offset
;
36 fprintf(stderr
, "0x%08x 0x%08x: %f (0x%08x)\n",
37 offset
, hw_offset
, *(float *)f
, *(uint32_t *)f
);
41 dump_VC4_PACKET_BRANCH_TO_SUB_LIST(void *cl
, uint32_t offset
, uint32_t hw_offset
)
43 uint32_t *addr
= cl
+ offset
;
45 fprintf(stderr
, "0x%08x 0x%08x: addr 0x%08x\n",
46 offset
, hw_offset
, *addr
);
50 dump_VC4_PACKET_FLAT_SHADE_FLAGS(void *cl
, uint32_t offset
, uint32_t hw_offset
)
52 uint32_t *bits
= cl
+ offset
;
54 fprintf(stderr
, "0x%08x 0x%08x: bits 0x%08x\n",
55 offset
, hw_offset
, *bits
);
59 dump_VC4_PACKET_VIEWPORT_OFFSET(void *cl
, uint32_t offset
, uint32_t hw_offset
)
61 uint16_t *o
= cl
+ offset
;
63 fprintf(stderr
, "0x%08x 0x%08x: %f, %f (0x%04x, 0x%04x)\n",
65 o
[0] / 16.0, o
[1] / 16.0,
70 dump_VC4_PACKET_CLIPPER_XY_SCALING(void *cl
, uint32_t offset
, uint32_t hw_offset
)
72 uint32_t *scale
= cl
+ offset
;
74 fprintf(stderr
, "0x%08x 0x%08x: %f, %f (%f, %f, 0x%08x, 0x%08x)\n",
76 uif(scale
[0]) / 16.0, uif(scale
[1]) / 16.0,
77 uif(scale
[0]), uif(scale
[1]),
82 dump_VC4_PACKET_CLIPPER_Z_SCALING(void *cl
, uint32_t offset
, uint32_t hw_offset
)
84 uint32_t *translate
= cl
+ offset
;
85 uint32_t *scale
= cl
+ offset
+ 8;
87 fprintf(stderr
, "0x%08x 0x%08x: %f, %f (0x%08x, 0x%08x)\n",
89 uif(translate
[0]), uif(translate
[1]),
90 translate
[0], translate
[1]);
92 fprintf(stderr
, "0x%08x 0x%08x: %f, %f (0x%08x, 0x%08x)\n",
93 offset
+ 8, hw_offset
+ 8,
94 uif(scale
[0]), uif(scale
[1]),
99 dump_VC4_PACKET_TILE_COORDINATES(void *cl
, uint32_t offset
, uint32_t hw_offset
)
101 uint8_t *tilecoords
= cl
+ offset
;
103 fprintf(stderr
, "0x%08x 0x%08x: %d, %d\n",
104 offset
, hw_offset
, tilecoords
[0], tilecoords
[1]);
108 dump_VC4_PACKET_GEM_HANDLES(void *cl
, uint32_t offset
, uint32_t hw_offset
)
110 uint32_t *handles
= cl
+ offset
;
112 fprintf(stderr
, "0x%08x 0x%08x: handle 0: %d, handle 1: %d\n",
113 offset
, hw_offset
, handles
[0], handles
[1]);
116 #define PACKET_DUMP(name, size) [name] = { #name, size, dump_##name }
117 #define PACKET(name, size) [name] = { #name, size, NULL }
119 static const struct packet_info
{
122 void (*dump_func
)(void *cl
, uint32_t offset
, uint32_t hw_offset
);
124 PACKET(VC4_PACKET_HALT
, 1),
125 PACKET(VC4_PACKET_NOP
, 1),
127 PACKET(VC4_PACKET_FLUSH
, 1),
128 PACKET(VC4_PACKET_FLUSH_ALL
, 1),
129 PACKET(VC4_PACKET_START_TILE_BINNING
, 1),
130 PACKET(VC4_PACKET_INCREMENT_SEMAPHORE
, 1),
131 PACKET(VC4_PACKET_WAIT_ON_SEMAPHORE
, 1),
133 PACKET(VC4_PACKET_BRANCH
, 5),
134 PACKET_DUMP(VC4_PACKET_BRANCH_TO_SUB_LIST
, 5),
136 PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER
, 1),
137 PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF
, 1),
138 PACKET(VC4_PACKET_STORE_FULL_RES_TILE_BUFFER
, 5),
139 PACKET(VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER
, 5),
140 PACKET(VC4_PACKET_STORE_TILE_BUFFER_GENERAL
, 7),
141 PACKET(VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
, 7),
143 PACKET(VC4_PACKET_GL_INDEXED_PRIMITIVE
, 14),
144 PACKET(VC4_PACKET_GL_ARRAY_PRIMITIVE
, 10),
146 PACKET(VC4_PACKET_COMPRESSED_PRIMITIVE
, 48),
147 PACKET(VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE
, 49),
149 PACKET(VC4_PACKET_PRIMITIVE_LIST_FORMAT
, 2),
151 PACKET(VC4_PACKET_GL_SHADER_STATE
, 5),
152 PACKET(VC4_PACKET_NV_SHADER_STATE
, 5),
153 PACKET(VC4_PACKET_VG_SHADER_STATE
, 5),
155 PACKET(VC4_PACKET_CONFIGURATION_BITS
, 4),
156 PACKET_DUMP(VC4_PACKET_FLAT_SHADE_FLAGS
, 5),
157 PACKET_DUMP(VC4_PACKET_POINT_SIZE
, 5),
158 PACKET_DUMP(VC4_PACKET_LINE_WIDTH
, 5),
159 PACKET(VC4_PACKET_RHT_X_BOUNDARY
, 3),
160 PACKET(VC4_PACKET_DEPTH_OFFSET
, 5),
161 PACKET(VC4_PACKET_CLIP_WINDOW
, 9),
162 PACKET_DUMP(VC4_PACKET_VIEWPORT_OFFSET
, 5),
163 PACKET(VC4_PACKET_Z_CLIPPING
, 9),
164 PACKET_DUMP(VC4_PACKET_CLIPPER_XY_SCALING
, 9),
165 PACKET_DUMP(VC4_PACKET_CLIPPER_Z_SCALING
, 9),
167 PACKET(VC4_PACKET_TILE_BINNING_MODE_CONFIG
, 16),
168 PACKET(VC4_PACKET_TILE_RENDERING_MODE_CONFIG
, 11),
169 PACKET(VC4_PACKET_CLEAR_COLORS
, 14),
170 PACKET_DUMP(VC4_PACKET_TILE_COORDINATES
, 3),
172 PACKET_DUMP(VC4_PACKET_GEM_HANDLES
, 9),
176 vc4_dump_cl(void *cl
, uint32_t size
, bool is_render
)
178 uint32_t offset
= 0, hw_offset
= 0;
181 while (offset
< size
) {
182 uint8_t header
= cmds
[offset
];
184 if (header
> ARRAY_SIZE(packet_info
) ||
185 !packet_info
[header
].name
) {
186 fprintf(stderr
, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n",
187 offset
, hw_offset
, header
, header
);
191 const struct packet_info
*p
= packet_info
+ header
;
192 fprintf(stderr
, "0x%08x 0x%08x: 0x%02x %s\n",
194 header
!= VC4_PACKET_GEM_HANDLES
? hw_offset
: 0,
197 if (offset
+ p
->size
<= size
&&
199 p
->dump_func(cmds
, offset
+ 1, hw_offset
+ 1);
201 for (uint32_t i
= 1; i
< p
->size
; i
++) {
202 if (offset
+ i
>= size
) {
203 fprintf(stderr
, "0x%08x 0x%08x: CL overflow!\n",
204 offset
+ i
, hw_offset
+ i
);
207 fprintf(stderr
, "0x%08x 0x%08x: 0x%02x\n",
209 header
!= VC4_PACKET_GEM_HANDLES
? hw_offset
+ i
: 0,
215 case VC4_PACKET_HALT
:
216 case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF
:
223 if (header
!= VC4_PACKET_GEM_HANDLES
)
224 hw_offset
+= p
->size
;