r300-gallium: vs: Add negation, SUB.
[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 void r500_fs_dump(struct r500_fragment_shader* fs)
34 {
35 int i;
36 uint32_t inst;
37
38 for (i = 0; i < fs->instruction_count; i++) {
39 inst = fs->instructions[i].inst0;
40 debug_printf("%d: 0: CMN_INST 0x%08x:", i, inst);
41 switch (inst & 0x3) {
42 case R500_INST_TYPE_ALU:
43 debug_printf("ALU ");
44 break;
45 case R500_INST_TYPE_OUT:
46 debug_printf("OUT ");
47 break;
48 case R500_INST_TYPE_FC:
49 debug_printf("FC ");
50 break;
51 case R500_INST_TYPE_TEX:
52 debug_printf("TEX ");
53 break;
54 }
55 debug_printf("%s %s %s %s ",
56 inst & R500_INST_TEX_SEM_WAIT ? "TEX_WAIT" : "",
57 inst & R500_INST_LAST ? "LAST" : "",
58 inst & R500_INST_NOP ? "NOP" : "",
59 inst & R500_INST_ALU_WAIT ? "ALU_WAIT" : "");
60 debug_printf("wmask: %s omask: %s\n",
61 r500_fs_mask[(inst >> 11) & 0xf],
62 r500_fs_mask[(inst >> 15) & 0xf]);
63 switch (inst & 0x3) {
64 case R500_INST_TYPE_ALU:
65 case R500_INST_TYPE_OUT:
66 inst = fs->instructions[i].inst1;
67 debug_printf(" 1: RGB_ADDR 0x%08x:", inst);
68 debug_printf("Addr0: %d%c, Addr1: %d%c, "
69 "Addr2: %d%c, srcp:%d\n",
70 inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
71 (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
72 (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
73 (inst >> 30));
74
75 inst = fs->instructions[i].inst2;
76 debug_printf(" 2: ALPHA_ADDR 0x%08x:", inst);
77 debug_printf("Addr0: %d%c, Addr1: %d%c, "
78 "Addr2: %d%c, srcp:%d\n",
79 inst & 0xff, (inst & (1 << 8)) ? 'c' : 't',
80 (inst >> 10) & 0xff, (inst & (1 << 18)) ? 'c' : 't',
81 (inst >> 20) & 0xff, (inst & (1 << 28)) ? 'c' : 't',
82 (inst >> 30));
83
84 inst = fs->instructions[i].inst3;
85 debug_printf(" 3: RGB_INST 0x%08x:", inst);
86 debug_printf("rgb_A_src:%d %s/%s/%s %d "
87 "rgb_B_src:%d %s/%s/%s %d\n",
88 inst & 0x3, r500_fs_swiz[(inst >> 2) & 0x7],
89 r500_fs_swiz[(inst >> 5) & 0x7],
90 r500_fs_swiz[(inst >> 8) & 0x7],
91 (inst >> 11) & 0x3, (inst >> 13) & 0x3,
92 r500_fs_swiz[(inst >> 15) & 0x7],
93 r500_fs_swiz[(inst >> 18) & 0x7],
94 r500_fs_swiz[(inst >> 21) & 0x7],
95 (inst >> 24) & 0x3);
96
97 inst = fs->instructions[i].inst4;
98 debug_printf(" 4: ALPHA_INST 0x%08x:", inst);
99 debug_printf("%s dest:%d%s alp_A_src:%d %s %d "
100 "alp_B_src:%d %s %d w:%d\n",
101 r500_fs_op_alpha[inst & 0xf], (inst >> 4) & 0x7f,
102 inst & (1<<11) ? "(rel)":"", (inst >> 12) & 0x3,
103 r500_fs_swiz[(inst >> 14) & 0x7], (inst >> 17) & 0x3,
104 (inst >> 19) & 0x3, r500_fs_swiz[(inst >> 21) & 0x7],
105 (inst >> 24) & 0x3, (inst >> 31) & 0x1);
106
107 inst = fs->instructions[i].inst5;
108 debug_printf(" 5: RGBA_INST 0x%08x:", inst);
109 debug_printf("%s dest:%d%s rgb_C_src:%d %s/%s/%s %d "
110 "alp_C_src:%d %s %d\n",
111 r500_fs_op_rgb[inst & 0xf], (inst >> 4) & 0x7f,
112 inst & (1 << 11) ? "(rel)":"", (inst >> 12) & 0x3,
113 r500_fs_swiz[(inst >> 14) & 0x7],
114 r500_fs_swiz[(inst >> 17) & 0x7],
115 r500_fs_swiz[(inst >> 20) & 0x7],
116 (inst >> 23) & 0x3, (inst >> 25) & 0x3,
117 r500_fs_swiz[(inst >> 27) & 0x7], (inst >> 30) & 0x3);
118 break;
119 case R500_INST_TYPE_FC:
120 /* XXX don't even bother yet */
121 break;
122 case R500_INST_TYPE_TEX:
123 inst = fs->instructions[i].inst1;
124 debug_printf(" 1: TEX_INST 0x%08x: id: %d "
125 "op:%s, %s, %s %s\n",
126 inst, (inst >> 16) & 0xf,
127 r500_fs_tex[(inst >> 22) & 0x7],
128 (inst & (1 << 25)) ? "ACQ" : "",
129 (inst & (1 << 26)) ? "IGNUNC" : "",
130 (inst & (1 << 27)) ? "UNSCALED" : "SCALED");
131
132 inst = fs->instructions[i].inst2;
133 debug_printf(" 2: TEX_ADDR 0x%08x: "
134 "src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n",
135 inst, inst & 0x7f, inst & (1 << 7) ? "(rel)" : "",
136 r500_fs_swiz[(inst >> 8) & 0x3],
137 r500_fs_swiz[(inst >> 10) & 0x3],
138 r500_fs_swiz[(inst >> 12) & 0x3],
139 r500_fs_swiz[(inst >> 14) & 0x3],
140 (inst >> 16) & 0x7f, inst & (1 << 23) ? "(rel)" : "",
141 r500_fs_swiz[(inst >> 24) & 0x3],
142 r500_fs_swiz[(inst >> 26) & 0x3],
143 r500_fs_swiz[(inst >> 28) & 0x3],
144 r500_fs_swiz[(inst >> 30) & 0x3]);
145
146 inst = fs->instructions[i].inst3;
147 debug_printf(" 3: TEX_DXDY 0x%08x\n", inst);
148 break;
149 }
150 }
151 }
152
153 static void r300_vs_op_dump(uint32_t op)
154 {
155 if (op & 0x80) {
156 if (op & 0x1) {
157 debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n");
158 } else {
159 debug_printf(" PVS_MACRO_OP_2CLK_MADD\n");
160 }
161 } else if (op & 0x40) {
162 debug_printf("%s\n", r300_vs_me_ops[op & 0x1f]);
163 } else {
164 debug_printf("%s\n", r300_vs_ve_ops[op & 0x1f]);
165 }
166 }
167
168 void r300_vs_src_dump(uint32_t src)
169 {
170 debug_printf(" %s%s/%s%s/%s%s/%s%s\n",
171 src & (1 << 25) ? "-" : " ",
172 r300_vs_swiz_debug[(src >> 13) & 0x7],
173 src & (1 << 26) ? "-" : " ",
174 r300_vs_swiz_debug[(src >> 16) & 0x7],
175 src & (1 << 27) ? "-" : " ",
176 r300_vs_swiz_debug[(src >> 19) & 0x7],
177 src & (1 << 28) ? "-" : " ",
178 r300_vs_swiz_debug[(src >> 22) & 0x7]);
179 }
180
181 void r300_vs_dump(struct r300_vertex_shader* vs)
182 {
183 int i;
184
185 for (i = 0; i < vs->instruction_count; i++) {
186 debug_printf("%d: op: 0x%08x", i, vs->instructions[i].inst0);
187 r300_vs_op_dump(vs->instructions[i].inst0);
188 debug_printf(" src0: 0x%08x", vs->instructions[i].inst1);
189 r300_vs_src_dump(vs->instructions[i].inst1);
190 debug_printf(" src1: 0x%08x", vs->instructions[i].inst2);
191 r300_vs_src_dump(vs->instructions[i].inst2);
192 debug_printf(" src2: 0x%08x", vs->instructions[i].inst3);
193 r300_vs_src_dump(vs->instructions[i].inst3);
194 }
195 }