2 * Copyright © 2016-2018 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
25 #include "broadcom/cle/v3d_decoder.h"
26 #include "clif_dump.h"
27 #include "clif_private.h"
29 #define __gen_user_data void
30 #define __gen_address_type uint32_t
31 #define __gen_address_offset(reloc) (*reloc)
32 #define __gen_emit_reloc(cl, reloc)
33 #define __gen_unpack_address(cl, s, e) (__gen_unpack_uint(cl, s, e) << (31 - (e - s)))
34 #include "broadcom/cle/v3dx_pack.h"
35 #include "broadcom/common/v3d_macros.h"
38 v3dX(clif_dump_packet
)(struct clif_dump
*clif
, uint32_t offset
,
39 const uint8_t *cl
, uint32_t *size
)
41 struct v3d_group
*inst
= v3d_spec_find_instruction(clif
->spec
, cl
);
43 out(clif
, "0x%08x: Unknown packet %d!\n", offset
, *cl
);
47 *size
= v3d_group_get_length(inst
);
49 out(clif
, "%s\n", v3d_group_get_name(inst
));
50 v3d_print_group(clif
->out
, inst
, 0, cl
, "");
53 case V3D33_GL_SHADER_STATE_opcode
: {
54 struct V3D33_GL_SHADER_STATE values
;
55 V3D33_GL_SHADER_STATE_unpack(cl
, &values
);
57 struct reloc_worklist_entry
*reloc
=
58 clif_dump_add_address_to_worklist(clif
,
59 reloc_gl_shader_state
,
62 reloc
->shader_state
.num_attrs
=
63 values
.number_of_attribute_arrays
;
68 case V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_opcode
: {
69 struct V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED values
;
70 V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_unpack(cl
, &values
);
72 if (values
.last_tile_of_frame
)
77 case V3D33_TRANSFORM_FEEDBACK_ENABLE_opcode
: {
78 struct V3D33_TRANSFORM_FEEDBACK_ENABLE values
;
79 V3D33_TRANSFORM_FEEDBACK_ENABLE_unpack(cl
, &values
);
80 struct v3d_group
*spec
= v3d_spec_find_struct(clif
->spec
,
81 "Transform Feedback Output Data Spec");
82 struct v3d_group
*addr
= v3d_spec_find_struct(clif
->spec
,
83 "Transform Feedback Output Address");
89 for (int i
= 0; i
< values
.number_of_16_bit_output_data_specs_following
; i
++) {
90 v3d_print_group(clif
->out
, spec
, 0, cl
, "");
91 cl
+= v3d_group_get_length(spec
);
92 *size
+= v3d_group_get_length(spec
);
95 for (int i
= 0; i
< values
.number_of_32_bit_output_buffer_address_following
; i
++) {
96 v3d_print_group(clif
->out
, addr
, 0, cl
, "");
97 cl
+= v3d_group_get_length(addr
);
98 *size
+= v3d_group_get_length(addr
);
103 case V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_opcode
: {
104 struct V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST values
;
105 V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_unpack(cl
, &values
);
106 struct reloc_worklist_entry
*reloc
=
107 clif_dump_add_address_to_worklist(clif
,
108 reloc_generic_tile_list
,
110 reloc
->generic_tile_list
.end
= values
.end
;
114 case V3D33_HALT_opcode
:
122 v3dX(clif_dump_gl_shader_state_record
)(struct clif_dump
*clif
,
123 struct reloc_worklist_entry
*reloc
,
126 struct v3d_group
*state
= v3d_spec_find_struct(clif
->spec
,
127 "GL Shader State Record");
128 struct v3d_group
*attr
= v3d_spec_find_struct(clif
->spec
,
129 "GL Shader State Attribute Record");
133 out(clif
, "GL Shader State Record at 0x%08x\n", reloc
->addr
);
134 v3d_print_group(clif
->out
, state
, 0, vaddr
, "");
135 vaddr
+= v3d_group_get_length(state
);
137 for (int i
= 0; i
< reloc
->shader_state
.num_attrs
; i
++) {
138 out(clif
, " Attribute %d\n", i
);
139 v3d_print_group(clif
->out
, attr
, 0, vaddr
, "");
140 vaddr
+= v3d_group_get_length(attr
);