3 * Copyright (c) 2018 Collabora LTD
5 * Author: Gert Wollny <gert.wollny@collabora.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * on the rights to use, copy, modify, merge, publish, distribute, sub
11 * license, and/or sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "r600_dump.h"
28 #include "r600_shader.h"
30 void print_shader_info(FILE *f
, int id
, struct r600_shader
*shader
)
33 #define PRINT_INT_MEMBER(NAME) \
34 if (shader-> NAME) fprintf(f, " shader->" #NAME "=%d;\n", shader-> NAME)
35 #define PRINT_UINT_MEMBER(NAME) \
36 if (shader-> NAME) fprintf(f, " shader->" #NAME "=%u;\n", (unsigned)shader-> NAME)
38 #define PRINT_INT_ARRAY_ELM(NAME, ELM) \
39 if (shader->NAME[i].ELM) fprintf(f, " shader->" #NAME "[%d]." #ELM "=%d;\n", i, (int)shader->NAME[i].ELM)
40 #define PRINT_UINT_ARRAY_ELM(NAME, ELM) \
41 if (shader->NAME[i].ELM) fprintf(f, " shader->" #NAME "[%d]." #ELM" =%u;\n", i, (unsigned)shader->NAME[i].ELM)
43 fprintf(f
, "#include \"gallium/drivers/r600/r600_shader.h\"\n");
44 fprintf(f
, "void shader_%d_fill_data(struct r600_shader *shader)\n{\n", id
);
45 fprintf(f
, " memset(shader, 0, sizeof(struct r600_shader));\n");
47 PRINT_UINT_MEMBER(processor_type
);
48 PRINT_UINT_MEMBER(ninput
);
49 PRINT_UINT_MEMBER(noutput
);
50 PRINT_UINT_MEMBER(nhwatomic
);
51 PRINT_UINT_MEMBER(nlds
);
52 PRINT_UINT_MEMBER(nsys_inputs
);
54 for (unsigned i
= 0; i
< shader
->ninput
; ++i
) {
55 PRINT_UINT_ARRAY_ELM(input
, name
);
56 PRINT_UINT_ARRAY_ELM(input
, gpr
);
57 PRINT_UINT_ARRAY_ELM(input
, done
);
58 PRINT_INT_ARRAY_ELM(input
, sid
);
59 PRINT_INT_ARRAY_ELM(input
, spi_sid
);
60 PRINT_UINT_ARRAY_ELM(input
, interpolate
);
61 PRINT_UINT_ARRAY_ELM(input
, ij_index
);
62 PRINT_UINT_ARRAY_ELM(input
, interpolate_location
); // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
63 PRINT_UINT_ARRAY_ELM(input
, lds_pos
); /* for evergreen */
64 PRINT_UINT_ARRAY_ELM(input
, back_color_input
);
65 PRINT_UINT_ARRAY_ELM(input
, write_mask
);
66 PRINT_INT_ARRAY_ELM(input
, ring_offset
);
69 for (unsigned i
= 0; i
< shader
->noutput
; ++i
) {
70 PRINT_UINT_ARRAY_ELM(output
, name
);
71 PRINT_UINT_ARRAY_ELM(output
, gpr
);
72 PRINT_UINT_ARRAY_ELM(output
, done
);
73 PRINT_INT_ARRAY_ELM(output
, sid
);
74 PRINT_INT_ARRAY_ELM(output
, spi_sid
);
75 PRINT_UINT_ARRAY_ELM(output
, interpolate
);
76 PRINT_UINT_ARRAY_ELM(output
, ij_index
);
77 PRINT_UINT_ARRAY_ELM(output
, interpolate_location
); // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
78 PRINT_UINT_ARRAY_ELM(output
, lds_pos
); /* for evergreen */
79 PRINT_UINT_ARRAY_ELM(output
, back_color_input
);
80 PRINT_UINT_ARRAY_ELM(output
, write_mask
);
81 PRINT_INT_ARRAY_ELM(output
, ring_offset
);
84 for (unsigned i
= 0; i
< shader
->nhwatomic
; ++i
) {
85 PRINT_UINT_ARRAY_ELM(atomics
, start
);
86 PRINT_UINT_ARRAY_ELM(atomics
, end
);
87 PRINT_UINT_ARRAY_ELM(atomics
, buffer_id
);
88 PRINT_UINT_ARRAY_ELM(atomics
, hw_idx
);
89 PRINT_UINT_ARRAY_ELM(atomics
, array_id
);
92 PRINT_UINT_MEMBER(nhwatomic_ranges
);
93 PRINT_UINT_MEMBER(uses_kill
);
94 PRINT_UINT_MEMBER(fs_write_all
);
95 PRINT_UINT_MEMBER(two_side
);
96 PRINT_UINT_MEMBER(needs_scratch_space
);
97 /* Number of color outputs in the TGSI shader,
98 * sometimes it could be higher than nr_cbufs (bug?).
99 * Also with writes_all property on eg+ it will be set to max CB number */
100 PRINT_UINT_MEMBER(nr_ps_max_color_exports
);
101 /* Real number of ps color exports compiled in the bytecode */
102 PRINT_UINT_MEMBER(nr_ps_color_exports
);
103 PRINT_UINT_MEMBER(ps_color_export_mask
);
104 PRINT_UINT_MEMBER(ps_export_highest
);
105 /* bit n is set if the shader writes gl_ClipDistance[n] */
106 PRINT_UINT_MEMBER(cc_dist_mask
);
107 PRINT_UINT_MEMBER(clip_dist_write
);
108 PRINT_UINT_MEMBER(cull_dist_write
);
109 PRINT_UINT_MEMBER(vs_position_window_space
);
110 /* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
111 PRINT_UINT_MEMBER(vs_out_misc_write
);
112 PRINT_UINT_MEMBER(vs_out_point_size
);
113 PRINT_UINT_MEMBER(vs_out_layer
);
114 PRINT_UINT_MEMBER(vs_out_viewport
);
115 PRINT_UINT_MEMBER(vs_out_edgeflag
);
116 PRINT_UINT_MEMBER(has_txq_cube_array_z_comp
);
117 PRINT_UINT_MEMBER(uses_tex_buffers
);
118 PRINT_UINT_MEMBER(gs_prim_id_input
);
119 PRINT_UINT_MEMBER(gs_tri_strip_adj_fix
);
120 PRINT_UINT_MEMBER(ps_conservative_z
);
122 /* Size in bytes of a data item in the ring(s) (single vertex data).
123 Stages with only one ring items 123 will be set to 0. */
125 PRINT_UINT_MEMBER(ring_item_sizes
[0]);
126 PRINT_UINT_MEMBER(ring_item_sizes
[1]);
127 PRINT_UINT_MEMBER(ring_item_sizes
[2]);
128 PRINT_UINT_MEMBER(ring_item_sizes
[3]);
130 PRINT_UINT_MEMBER(indirect_files
);
131 PRINT_UINT_MEMBER(max_arrays
);
132 PRINT_UINT_MEMBER(num_arrays
);
133 PRINT_UINT_MEMBER(vs_as_es
);
134 PRINT_UINT_MEMBER(vs_as_ls
);
135 PRINT_UINT_MEMBER(vs_as_gs_a
);
136 PRINT_UINT_MEMBER(tes_as_es
);
137 PRINT_UINT_MEMBER(tcs_prim_mode
);
138 PRINT_UINT_MEMBER(ps_prim_id_input
);
140 if (shader
->num_arrays
> 0) {
141 fprintf(stderr
, " shader->arrays = new r600_shader_array[%d];\n", shader
->num_arrays
);
142 for (unsigned i
= 0; i
< shader
->num_arrays
; ++i
) {
143 PRINT_UINT_ARRAY_ELM(arrays
, gpr_start
);
144 PRINT_UINT_ARRAY_ELM(arrays
, gpr_count
);
145 PRINT_UINT_ARRAY_ELM(arrays
, comp_mask
);
149 PRINT_UINT_MEMBER(uses_doubles
);
150 PRINT_UINT_MEMBER(uses_atomics
);
151 PRINT_UINT_MEMBER(uses_images
);
152 PRINT_UINT_MEMBER(uses_helper_invocation
);
153 PRINT_UINT_MEMBER(atomic_base
);
154 PRINT_UINT_MEMBER(rat_base
);
155 PRINT_UINT_MEMBER(image_size_const_offset
);
160 void print_pipe_info(FILE *f
, struct tgsi_shader_info
*shader
)
162 PRINT_UINT_MEMBER(shader_buffers_load
);
163 PRINT_UINT_MEMBER(shader_buffers_store
);
164 PRINT_UINT_MEMBER(shader_buffers_atomic
);
165 PRINT_UINT_MEMBER(writes_memory
);
166 PRINT_UINT_MEMBER(file_mask
[TGSI_FILE_HW_ATOMIC
]);
167 PRINT_UINT_MEMBER(file_count
[TGSI_FILE_HW_ATOMIC
]);