2 * Copyright 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
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:
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 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. */
23 #include "r300_debug.h"
25 static void r300_dump_fs(struct r300_fragment_shader
* fs
)
29 for (i
= 0; i
< fs
->alu_instruction_count
; i
++) {
33 static char* r500_fs_swiz
[] = {
44 static char* r500_fs_op_rgb
[] = {
60 static char* r500_fs_op_alpha
[] = {
79 static char* r500_fs_mask
[] = {
98 static char* r500_fs_tex
[] = {
108 void r500_fs_dump(struct r500_fragment_shader
* fs
)
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 ");
120 case R500_INST_TYPE_OUT
:
121 debug_printf("OUT ");
123 case R500_INST_TYPE_FC
:
126 case R500_INST_TYPE_TEX
:
127 debug_printf("TEX ");
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',
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',
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],
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);
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);
194 case R500_INST_TYPE_FC
:
195 /* XXX don't even bother yet */
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");
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]);
221 inst
= fs
->instructions
[i
].inst3
;
222 debug_printf(" 3: TEX_DXDY 0x%08x\n", inst
);
228 void r300_vs_dump(struct r300_vertex_shader
* vs
)
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
);