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 PACKET(name, size) [name] = { #name, size }
30 static const struct packet_info
{
34 PACKET(VC4_PACKET_HALT
, 1),
35 PACKET(VC4_PACKET_NOP
, 1),
37 PACKET(VC4_PACKET_FLUSH
, 1),
38 PACKET(VC4_PACKET_FLUSH_ALL
, 1),
39 PACKET(VC4_PACKET_START_TILE_BINNING
, 1),
40 PACKET(VC4_PACKET_INCREMENT_SEMAPHORE
, 1),
41 PACKET(VC4_PACKET_WAIT_ON_SEMAPHORE
, 1),
43 PACKET(VC4_PACKET_BRANCH
, 5),
44 PACKET(VC4_PACKET_BRANCH_TO_SUB_LIST
, 5),
46 PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER
, 1),
47 PACKET(VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF
, 1),
48 PACKET(VC4_PACKET_STORE_FULL_RES_TILE_BUFFER
, 5),
49 PACKET(VC4_PACKET_LOAD_FULL_RES_TILE_BUFFER
, 5),
50 PACKET(VC4_PACKET_STORE_TILE_BUFFER_GENERAL
, 7),
51 PACKET(VC4_PACKET_LOAD_TILE_BUFFER_GENERAL
, 7),
53 PACKET(VC4_PACKET_GL_INDEXED_PRIMITIVE
, 14),
54 PACKET(VC4_PACKET_GL_ARRAY_PRIMITIVE
, 10),
56 PACKET(VC4_PACKET_COMPRESSED_PRIMITIVE
, 48),
57 PACKET(VC4_PACKET_CLIPPED_COMPRESSED_PRIMITIVE
, 49),
59 PACKET(VC4_PACKET_PRIMITIVE_LIST_FORMAT
, 2),
61 PACKET(VC4_PACKET_GL_SHADER_STATE
, 5),
62 PACKET(VC4_PACKET_NV_SHADER_STATE
, 5),
63 PACKET(VC4_PACKET_VG_SHADER_STATE
, 5),
65 PACKET(VC4_PACKET_CONFIGURATION_BITS
, 4),
66 PACKET(VC4_PACKET_FLAT_SHADE_FLAGS
, 5),
67 PACKET(VC4_PACKET_POINT_SIZE
, 5),
68 PACKET(VC4_PACKET_LINE_WIDTH
, 5),
69 PACKET(VC4_PACKET_RHT_X_BOUNDARY
, 3),
70 PACKET(VC4_PACKET_DEPTH_OFFSET
, 5),
71 PACKET(VC4_PACKET_CLIP_WINDOW
, 9),
72 PACKET(VC4_PACKET_VIEWPORT_OFFSET
, 5),
73 PACKET(VC4_PACKET_Z_CLIPPING
, 9),
74 PACKET(VC4_PACKET_CLIPPER_XY_SCALING
, 9),
75 PACKET(VC4_PACKET_CLIPPER_Z_SCALING
, 9),
77 PACKET(VC4_PACKET_TILE_BINNING_MODE_CONFIG
, 16),
78 PACKET(VC4_PACKET_TILE_RENDERING_MODE_CONFIG
, 11),
79 PACKET(VC4_PACKET_CLEAR_COLORS
, 14),
80 PACKET(VC4_PACKET_TILE_COORDINATES
, 3),
82 PACKET(VC4_PACKET_GEM_HANDLES
, 9),
86 vc4_dump_cl(struct vc4_cl
*cl
, bool is_render
)
88 uint32_t offset
= 0, hw_offset
= 0;
89 uint8_t *cmds
= cl
->base
;
91 while (offset
< cl
->end
- cl
->base
) {
92 uint8_t header
= cmds
[offset
];
94 if (header
> ARRAY_SIZE(packet_info
) ||
95 !packet_info
[header
].name
) {
96 fprintf(stderr
, "0x%08x 0x%08x: Unknown packet 0x%02x (%d)!\n",
97 offset
, hw_offset
, header
, header
);
101 const struct packet_info
*p
= packet_info
+ header
;
102 fprintf(stderr
, "0x%08x 0x%08x: 0x%02x %s\n",
104 header
!= VC4_PACKET_GEM_HANDLES
? hw_offset
: 0,
107 for (uint32_t i
= 1; i
< p
->size
; i
++) {
108 if (offset
+ i
>= cl
->end
- cl
->base
) {
109 fprintf(stderr
, "0x%08x 0x%08x: CL overflow!\n",
110 offset
+ i
, hw_offset
+ i
);
113 fprintf(stderr
, "0x%08x 0x%08x: 0x%02x\n",
115 header
!= VC4_PACKET_GEM_HANDLES
? hw_offset
+ i
: 0,
120 case VC4_PACKET_HALT
:
121 case VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF
:
128 if (header
!= VC4_PACKET_GEM_HANDLES
)
129 hw_offset
+= p
->size
;