aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/r600_dump.c
blob: 29a89605e227c3e891c6bf5b83b88583d9e7df49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* -*- mesa-c++  -*-
 *
 * Copyright (c) 2018 Collabora LTD
 *
 * Author: Gert Wollny <gert.wollny@collabora.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * on the rights to use, copy, modify, merge, publish, distribute, sub
 * license, and/or sell copies of the Software, and to permit persons to whom
 * the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "r600_dump.h"
#include "r600_shader.h"

void print_shader_info(FILE *f , int id, struct r600_shader *shader)
{

#define PRINT_INT_MEMBER(NAME) \
   if (shader-> NAME) fprintf(f, "  shader->"  #NAME  "=%d;\n", shader-> NAME)
#define PRINT_UINT_MEMBER(NAME) \
   if (shader-> NAME) fprintf(f, "  shader->"  #NAME  "=%u;\n", (unsigned)shader-> NAME)

#define PRINT_INT_ARRAY_ELM(NAME, ELM) \
   if (shader->NAME[i].ELM) fprintf(f, "  shader->"  #NAME "[%d]." #ELM "=%d;\n", i, (int)shader->NAME[i].ELM)
#define PRINT_UINT_ARRAY_ELM(NAME, ELM) \
   if (shader->NAME[i].ELM) fprintf(f, "  shader->"  #NAME "[%d]." #ELM" =%u;\n", i, (unsigned)shader->NAME[i].ELM)

   fprintf(f, "#include \"gallium/drivers/r600/r600_shader.h\"\n");
   fprintf(f, "void shader_%d_fill_data(struct r600_shader *shader)\n{\n", id);
   fprintf(f, "  memset(shader, 0, sizeof(struct r600_shader));\n");

   PRINT_UINT_MEMBER(processor_type);
   PRINT_UINT_MEMBER(ninput);
   PRINT_UINT_MEMBER(noutput);
   PRINT_UINT_MEMBER(nhwatomic);
   PRINT_UINT_MEMBER(nlds);
   PRINT_UINT_MEMBER(nsys_inputs);

   for (unsigned i = 0; i < shader->ninput; ++i) {
      PRINT_UINT_ARRAY_ELM(input, name);
      PRINT_UINT_ARRAY_ELM(input, gpr);
      PRINT_UINT_ARRAY_ELM(input, done);
      PRINT_INT_ARRAY_ELM(input, sid);
      PRINT_INT_ARRAY_ELM(input, spi_sid);
      PRINT_UINT_ARRAY_ELM(input, interpolate);
      PRINT_UINT_ARRAY_ELM(input, ij_index);
      PRINT_UINT_ARRAY_ELM(input, interpolate_location); //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
      PRINT_UINT_ARRAY_ELM(input, lds_pos); /* for evergreen */
      PRINT_UINT_ARRAY_ELM(input, back_color_input);
      PRINT_UINT_ARRAY_ELM(input, write_mask);
      PRINT_INT_ARRAY_ELM(input, ring_offset);
   }

   for (unsigned i = 0; i < shader->noutput; ++i) {
      PRINT_UINT_ARRAY_ELM(output, name);
      PRINT_UINT_ARRAY_ELM(output, gpr);
      PRINT_UINT_ARRAY_ELM(output, done);
      PRINT_INT_ARRAY_ELM(output, sid);
      PRINT_INT_ARRAY_ELM(output, spi_sid);
      PRINT_UINT_ARRAY_ELM(output, interpolate);
      PRINT_UINT_ARRAY_ELM(output, ij_index);
      PRINT_UINT_ARRAY_ELM(output, interpolate_location); //  TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE
      PRINT_UINT_ARRAY_ELM(output, lds_pos); /* for evergreen */
      PRINT_UINT_ARRAY_ELM(output, back_color_input);
      PRINT_UINT_ARRAY_ELM(output, write_mask);
      PRINT_INT_ARRAY_ELM(output, ring_offset);
   }

   for (unsigned i = 0; i < shader->nhwatomic; ++i) {
      PRINT_UINT_ARRAY_ELM(atomics, start);
      PRINT_UINT_ARRAY_ELM(atomics, end);
      PRINT_UINT_ARRAY_ELM(atomics, buffer_id);
      PRINT_UINT_ARRAY_ELM(atomics, hw_idx);
      PRINT_UINT_ARRAY_ELM(atomics, array_id);
   }

   PRINT_UINT_MEMBER(nhwatomic_ranges);
   PRINT_UINT_MEMBER(uses_kill);
   PRINT_UINT_MEMBER(fs_write_all);
   PRINT_UINT_MEMBER(two_side);
   PRINT_UINT_MEMBER(needs_scratch_space);
   /* Number of color outputs in the TGSI shader,
    * sometimes it could be higher than nr_cbufs (bug?).
    * Also with writes_all property on eg+ it will be set to max CB number */
   PRINT_UINT_MEMBER(nr_ps_max_color_exports);
   /* Real number of ps color exports compiled in the bytecode */
   PRINT_UINT_MEMBER(nr_ps_color_exports);
   PRINT_UINT_MEMBER(ps_color_export_mask);
   PRINT_UINT_MEMBER(ps_export_highest);
   /* bit n is set if the shader writes gl_ClipDistance[n] */
   PRINT_UINT_MEMBER(cc_dist_mask);
   PRINT_UINT_MEMBER(clip_dist_write);
   PRINT_UINT_MEMBER(cull_dist_write);
   PRINT_UINT_MEMBER(vs_position_window_space);
   /* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */
   PRINT_UINT_MEMBER(vs_out_misc_write);
   PRINT_UINT_MEMBER(vs_out_point_size);
   PRINT_UINT_MEMBER(vs_out_layer);
   PRINT_UINT_MEMBER(vs_out_viewport);
   PRINT_UINT_MEMBER(vs_out_edgeflag);
   PRINT_UINT_MEMBER(has_txq_cube_array_z_comp);
   PRINT_UINT_MEMBER(uses_tex_buffers);
   PRINT_UINT_MEMBER(gs_prim_id_input);
   PRINT_UINT_MEMBER(gs_tri_strip_adj_fix);
   PRINT_UINT_MEMBER(ps_conservative_z);

   /* Size in bytes of a data item in the ring(s) (single vertex data).
      Stages with only one ring items 123 will be set to 0. */

   PRINT_UINT_MEMBER(ring_item_sizes[0]);
   PRINT_UINT_MEMBER(ring_item_sizes[1]);
   PRINT_UINT_MEMBER(ring_item_sizes[2]);
   PRINT_UINT_MEMBER(ring_item_sizes[3]);

   PRINT_UINT_MEMBER(indirect_files);
   PRINT_UINT_MEMBER(max_arrays);
   PRINT_UINT_MEMBER(num_arrays);
   PRINT_UINT_MEMBER(vs_as_es);
   PRINT_UINT_MEMBER(vs_as_ls);
   PRINT_UINT_MEMBER(vs_as_gs_a);
   PRINT_UINT_MEMBER(tes_as_es);
   PRINT_UINT_MEMBER(tcs_prim_mode);
   PRINT_UINT_MEMBER(ps_prim_id_input);

   if (shader->num_arrays > 0) {
      fprintf(stderr, "  shader->arrays = new r600_shader_array[%d];\n", shader->num_arrays);
      for (unsigned i = 0; i  < shader->num_arrays; ++i) {
         PRINT_UINT_ARRAY_ELM(arrays, gpr_start);
         PRINT_UINT_ARRAY_ELM(arrays, gpr_count);
         PRINT_UINT_ARRAY_ELM(arrays, comp_mask);
      }
   }

   PRINT_UINT_MEMBER(uses_doubles);
   PRINT_UINT_MEMBER(uses_atomics);
   PRINT_UINT_MEMBER(uses_images);
   PRINT_UINT_MEMBER(uses_helper_invocation);
   PRINT_UINT_MEMBER(atomic_base);
   PRINT_UINT_MEMBER(rat_base);
   PRINT_UINT_MEMBER(image_size_const_offset);

   fprintf(f, "}\n");
}

void print_pipe_info(FILE *f, struct tgsi_shader_info *shader)
{
   PRINT_UINT_MEMBER(shader_buffers_load);
   PRINT_UINT_MEMBER(shader_buffers_store);
   PRINT_UINT_MEMBER(shader_buffers_atomic);
   PRINT_UINT_MEMBER(writes_memory);
   PRINT_UINT_MEMBER(file_mask[TGSI_FILE_HW_ATOMIC]);
   PRINT_UINT_MEMBER(file_count[TGSI_FILE_HW_ATOMIC]);
}