• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016-2018 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 <string.h>
25 #include "broadcom/cle/v3d_decoder.h"
26 #include "clif_dump.h"
27 #include "clif_private.h"
28 
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"
36 
37 bool
v3dX(clif_dump_packet)38 v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
39                        const uint8_t *cl, uint32_t *size)
40 {
41         struct v3d_group *inst = v3d_spec_find_instruction(clif->spec, cl);
42         if (!inst) {
43                 out(clif, "0x%08x: Unknown packet %d!\n", offset, *cl);
44                 return false;
45         }
46 
47         *size = v3d_group_get_length(inst);
48 
49         out(clif, "%s\n", v3d_group_get_name(inst));
50         v3d_print_group(clif->out, inst, 0, cl, "");
51 
52         switch (*cl) {
53         case V3DX(GL_SHADER_STATE_opcode): {
54                 struct V3DX(GL_SHADER_STATE) values;
55                 V3DX(GL_SHADER_STATE_unpack)(cl, &values);
56 
57                 struct reloc_worklist_entry *reloc =
58                         clif_dump_add_address_to_worklist(clif,
59                                                           reloc_gl_shader_state,
60                                                           values.address);
61                 if (reloc) {
62                         reloc->shader_state.num_attrs =
63                                 values.number_of_attribute_arrays;
64                 }
65                 return true;
66         }
67 
68 #if V3D_VERSION < 40
69         case V3DX(STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_opcode): {
70                 struct V3DX(STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED) values;
71                 V3DX(STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_unpack)(cl, &values);
72 
73                 if (values.last_tile_of_frame)
74                         return false;
75                 break;
76         }
77 #endif /* V3D_VERSION < 40 */
78 
79 #if V3D_VERSION > 40
80         case V3DX(TRANSFORM_FEEDBACK_SPECS_opcode): {
81                 struct V3DX(TRANSFORM_FEEDBACK_SPECS) values;
82                 V3DX(TRANSFORM_FEEDBACK_SPECS_unpack)(cl, &values);
83                 struct v3d_group *spec = v3d_spec_find_struct(clif->spec,
84                                                               "Transform Feedback Output Data Spec");
85                 assert(spec);
86 
87                 cl += *size;
88 
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);
93                 }
94                 break;
95         }
96 #else /* V3D_VERSION < 40 */
97         case V3DX(TRANSFORM_FEEDBACK_ENABLE_opcode): {
98                 struct V3DX(TRANSFORM_FEEDBACK_ENABLE) values;
99                 V3DX(TRANSFORM_FEEDBACK_ENABLE_unpack)(cl, &values);
100                 struct v3d_group *spec = v3d_spec_find_struct(clif->spec,
101                                                               "Transform Feedback Output Data Spec");
102                 struct v3d_group *addr = v3d_spec_find_struct(clif->spec,
103                                                               "Transform Feedback Output Address");
104                 assert(spec);
105                 assert(addr);
106 
107                 cl += *size;
108 
109                 for (int i = 0; i < values.number_of_16_bit_output_data_specs_following; i++) {
110                         v3d_print_group(clif->out, spec, 0, cl, "");
111                         cl += v3d_group_get_length(spec);
112                         *size += v3d_group_get_length(spec);
113                 }
114 
115                 for (int i = 0; i < values.number_of_32_bit_output_buffer_address_following; i++) {
116                         v3d_print_group(clif->out, addr, 0, cl, "");
117                         cl += v3d_group_get_length(addr);
118                         *size += v3d_group_get_length(addr);
119                 }
120                 break;
121         }
122 #endif /* V3D_VERSION < 40 */
123 
124         case V3DX(START_ADDRESS_OF_GENERIC_TILE_LIST_opcode): {
125                 struct V3DX(START_ADDRESS_OF_GENERIC_TILE_LIST) values;
126                 V3DX(START_ADDRESS_OF_GENERIC_TILE_LIST_unpack)(cl, &values);
127                 struct reloc_worklist_entry *reloc =
128                         clif_dump_add_address_to_worklist(clif,
129                                                           reloc_generic_tile_list,
130                                                           values.start);
131                 reloc->generic_tile_list.end = values.end;
132                 break;
133         }
134 
135         case V3DX(HALT_opcode):
136                 return false;
137         }
138 
139         return true;
140 }
141 
142 void
v3dX(clif_dump_gl_shader_state_record)143 v3dX(clif_dump_gl_shader_state_record)(struct clif_dump *clif,
144                                        struct reloc_worklist_entry *reloc,
145                                        void *vaddr)
146 {
147         struct v3d_group *state = v3d_spec_find_struct(clif->spec,
148                                                        "GL Shader State Record");
149         struct v3d_group *attr = v3d_spec_find_struct(clif->spec,
150                                                       "GL Shader State Attribute Record");
151         assert(state);
152         assert(attr);
153 
154         out(clif, "GL Shader State Record at 0x%08x\n", reloc->addr);
155         v3d_print_group(clif->out, state, 0, vaddr, "");
156         vaddr += v3d_group_get_length(state);
157 
158         for (int i = 0; i < reloc->shader_state.num_attrs; i++) {
159                 out(clif, "  Attribute %d\n", i);
160                 v3d_print_group(clif->out, attr, 0, vaddr, "");
161                 vaddr += v3d_group_get_length(attr);
162         }
163 }
164