Merge remote branch 'origin/master' into radeon-rewrite
[mesa.git] / src / gallium / drivers / r300 / r300_debug.c
1 /*
2 * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #include "r300_debug.h"
24
25 static void r300_dump_fs(struct r300_fragment_shader* fs)
26 {
27 int i;
28
29 for (i = 0; i < fs->alu_instruction_count; i++) {
30 }
31 }
32
33 static char* r500_fs_swiz[] = {
34 " R",
35 " G",
36 " B",
37 " A",
38 " 0",
39 ".5",
40 " 1",
41 " U",
42 };
43
44 static char* r500_fs_op_rgb[] = {
45 "MAD",
46 "DP3",
47 "DP4",
48 "D2A",
49 "MIN",
50 "MAX",
51 "---",
52 "CND",
53 "CMP",
54 "FRC",
55 "SOP",
56 "MDH",
57 "MDV",
58 };
59
60 static char* r500_fs_op_alpha[] = {
61 "MAD",
62 " DP",
63 "MIN",
64 "MAX",
65 "---",
66 "CND",
67 "CMP",
68 "FRC",
69 "EX2",
70 "LN2",
71 "RCP",
72 "RSQ",
73 "SIN",
74 "COS",
75 "MDH",
76 "MDV",
77 };
78
79 static char* r500_fs_mask[] = {
80 "NONE",
81 "R ",
82 " G ",
83 "RG ",
84 " B ",
85 "R B ",
86 " GB ",
87 "RGB ",
88 " A",
89 "R A",
90 " G A",
91 "RG A",
92 " BA",
93 "R BA",
94 " GBA",
95 "RGBA",
96 };
97
98 static char* r500_fs_tex[] = {
99 " NOP",
100 " LD",
101 "TEXKILL",
102 " PROJ",
103 "LODBIAS",
104 " LOD",
105 " DXDY",
106 };
107
108 void r500_fs_dump(struct r500_fragment_shader* fs)
109 {
110 int i;
111 uint32_t inst;
112
113 for (i = 0; i < fs->instruction_count; i++) {
114 inst = fs->instructions[i].inst0;
115 debug_printf("%d: 0: CMN_INST 0x%08x:", i, inst);
116 switch (inst & 0x3) {
117 case R500_INST_TYPE_ALU:
118 debug_printf("ALU ");
119 break;
120 case R500_INST_TYPE_OUT:
121 debug_printf("OUT ");
122 break;
123 case R500_INST_TYPE_FC:
124 debug_printf("FC ");
125 break;
126 case R500_INST_TYPE_TEX:
127 debug_printf("TEX ");
128 break;
129 }
130 debug_printf("%s %s %s %s ",
131 inst & R500_INST_TEX_SEM_WAIT ? "TEX_WAIT" : "",
132 inst & R500_INST_LAST ? "LAST" : "",
133 inst & R500_INST_NOP ? "NOP" : "",
134 inst & R500_INST_ALU_WAIT ? "ALU_WAIT" : "");
135 debug_printf("wmask: %s omask: %s\n",
136 r500_fs_mask[(inst >> 11) & 0xf],
137 r500_fs_mask[(inst >> 15) & 0xf]);
138 switch (inst & 0x3) {
139 case R500_INST_TYPE_ALU:
140 case R500_INST_TYPE_OUT:
141 inst = fs->instructions[i].inst1;
142 debug_printf(" 1: RGB_ADDR 0x%08x:", inst);
143 debug_printf("Addr0: %d%c, Addr1: %d%c, "
144 "Addr2: %d%c, srcp:%d\n",
145 inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
146 (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
147 (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
148 (inst >> 30));
149
150 inst = fs->instructions[i].inst2;
151 debug_printf(" 2: ALPHA_ADDR 0x%08x:", inst);
152 debug_printf("Addr0: %d%c, Addr1: %d%c, "
153 "Addr2: %d%c, srcp:%d\n",
154 inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
155 (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
156 (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
157 (inst >> 30));
158
159 inst = fs->instructions[i].inst3;
160 debug_printf(" 3: RGB_INST 0x%08x:", inst);
161 debug_printf("rgb_A_src:%d %s/%s/%s %d "
162 "rgb_B_src:%d %s/%s/%s %d\n",
163 inst & 0x3, r500_fs_swiz[(inst >> 2) & 0x7],
164 r500_fs_swiz[(inst >> 5) & 0x7],
165 r500_fs_swiz[(inst >> 8) & 0x7],
166 (inst >> 11) & 0x3, (inst >> 13) & 0x3,
167 r500_fs_swiz[(inst >> 15) & 0x7],
168 r500_fs_swiz[(inst >> 18) & 0x7],
169 r500_fs_swiz[(inst >> 21) & 0x7],
170 (inst >> 24) & 0x3);
171
172 inst = fs->instructions[i].inst4;
173 debug_printf(" 4: ALPHA_INST 0x%08x:", inst);
174 debug_printf("%s dest:%d%s alp_A_src:%d %s %d "
175 "alp_B_src:%d %s %d w:%d\n",
176 r500_fs_op_alpha[inst & 0xf], (inst >> 4) & 0x7f,
177 inst & (1<<11) ? "(rel)":"", (inst >> 12) & 0x3,
178 r500_fs_swiz[(inst >> 14) & 0x7], (inst >> 17) & 0x3,
179 (inst >> 19) & 0x3, r500_fs_swiz[(inst >> 21) & 0x7],
180 (inst >> 24) & 0x3, (inst >> 31) & 0x1);
181
182 inst = fs->instructions[i].inst5;
183 debug_printf(" 5: RGBA_INST 0x%08x:", inst);
184 debug_printf("%s dest:%d%s rgb_C_src:%d %s/%s/%s %d "
185 "alp_C_src:%d %s %d\n",
186 r500_fs_op_rgb[inst & 0xf], (inst >> 4) & 0x7f,
187 inst & (1 << 11) ? "(rel)":"", (inst >> 12) & 0x3,
188 r500_fs_swiz[(inst >> 14) & 0x7],
189 r500_fs_swiz[(inst >> 17) & 0x7],
190 r500_fs_swiz[(inst >> 20) & 0x7],
191 (inst >> 23) & 0x3, (inst >> 25) & 0x3,
192 r500_fs_swiz[(inst >> 27) & 0x7], (inst >> 30) & 0x3);
193 break;
194 case R500_INST_TYPE_FC:
195 /* XXX don't even bother yet */
196 break;
197 case R500_INST_TYPE_TEX:
198 inst = fs->instructions[i].inst1;
199 debug_printf(" 1: TEX_INST 0x%08x: id: %d "
200 "op:%s, %s, %s %s\n",
201 inst, (inst >> 16) & 0xf,
202 r500_fs_tex[(inst >> 22) & 0x7],
203 (inst & (1 << 25)) ? "ACQ" : "",
204 (inst & (1 << 26)) ? "IGNUNC" : "",
205 (inst & (1 << 27)) ? "UNSCALED" : "SCALED");
206
207 inst = fs->instructions[i].inst2;
208 debug_printf(" 2: TEX_ADDR 0x%08x: "
209 "src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n",
210 inst, inst & 0x7f, inst & (1 << 7) ? "(rel)" : "",
211 r500_fs_swiz[(inst >> 8) & 0x3],
212 r500_fs_swiz[(inst >> 10) & 0x3],
213 r500_fs_swiz[(inst >> 12) & 0x3],
214 r500_fs_swiz[(inst >> 14) & 0x3],
215 (inst >> 16) & 0x7f, inst & (1 << 23) ? "(rel)" : "",
216 r500_fs_swiz[(inst >> 24) & 0x3],
217 r500_fs_swiz[(inst >> 26) & 0x3],
218 r500_fs_swiz[(inst >> 28) & 0x3],
219 r500_fs_swiz[(inst >> 30) & 0x3]);
220
221 inst = fs->instructions[i].inst3;
222 debug_printf(" 3: TEX_DXDY 0x%08x\n", inst);
223 break;
224 }
225 }
226 }
227
228 void r300_vs_dump(struct r300_vertex_shader* vs)
229 {
230 int i;
231
232 for (i = 0; i < vs->instruction_count; i++) {
233 debug_printf("inst0: 0x%x\n", vs->instructions[i].inst0);
234 debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1);
235 debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2);
236 debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3);
237 }
238 }