2
* Copyright 2009 Nicolai Hähnle <nhaehnle@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 "radeon_compiler.h"
24
#include "radeon_code.h"
25
#include "../r300_reg.h"
29
static char* r300_vs_ve_ops[] = {
36
" VE_DISTANCE_FACTOR",
40
"VE_SET_GREATER_THAN_EQUAL",
47
" VE_PRED_SET_EQ_PUSH",
48
" VE_PRED_SET_GT_PUSH",
49
" VE_PRED_SET_GTE_PUSH",
50
" VE_PRED_SET_NEQ_PUSH",
58
" VE_SET_GREATER_THAN",
66
static char* r300_vs_me_ops[] = {
79
" ME_EXP_BASE2_FULL_DX",
80
" ME_LOG_BASE2_FULL_DX",
81
" ME_POWER_FUNC_FF_CLAMP_B",
82
"ME_POWER_FUNC_FF_CLAMP_B1",
83
"ME_POWER_FUNC_FF_CLAMP_01",
89
" ME_RECIP_SQRT_IEEE",
97
" ME_PRED_SET_RESTORE",
103
/* XXX refactor to avoid clashing symbols */
104
static char* r300_vs_src_debug[] = {
111
static char* r300_vs_dst_debug[] = {
122
static char* r300_vs_swiz_debug[] = {
134
static void r300_vs_op_dump(uint32_t op)
136
fprintf(stderr, " dst: %d%s op: ",
137
(op >> 13) & 0x7f, r300_vs_dst_debug[(op >> 8) & 0x7]);
138
if ((op >> PVS_DST_PRED_ENABLE_SHIFT) & 0x1) {
139
fprintf(stderr, "PRED %u",
140
(op >> PVS_DST_PRED_SENSE_SHIFT) & 0x1);
144
fprintf(stderr, "PVS_MACRO_OP_2CLK_M2X_ADD\n");
146
fprintf(stderr, " PVS_MACRO_OP_2CLK_MADD\n");
148
} else if (op & 0x40) {
149
fprintf(stderr, "%s\n", r300_vs_me_ops[op & 0x1f]);
151
fprintf(stderr, "%s\n", r300_vs_ve_ops[op & 0x1f]);
155
static void r300_vs_src_dump(uint32_t src)
157
fprintf(stderr, " reg: %d%s swiz: %s%s/%s%s/%s%s/%s%s\n",
158
(src >> 5) & 0xff, r300_vs_src_debug[src & 0x3],
159
src & (1 << 25) ? "-" : " ",
160
r300_vs_swiz_debug[(src >> 13) & 0x7],
161
src & (1 << 26) ? "-" : " ",
162
r300_vs_swiz_debug[(src >> 16) & 0x7],
163
src & (1 << 27) ? "-" : " ",
164
r300_vs_swiz_debug[(src >> 19) & 0x7],
165
src & (1 << 28) ? "-" : " ",
166
r300_vs_swiz_debug[(src >> 22) & 0x7]);
169
void r300_vertex_program_dump(struct radeon_compiler *compiler, void *user)
171
struct r300_vertex_program_compiler *c = (struct r300_vertex_program_compiler*)compiler;
172
struct r300_vertex_program_code * vs = c->code;
173
unsigned instrcount = vs->length / 4;
176
fprintf(stderr, "Final vertex program code:\n");
178
for(i = 0; i < instrcount; i++) {
179
unsigned offset = i*4;
182
fprintf(stderr, "%d: op: 0x%08x", i, vs->body.d[offset]);
183
r300_vs_op_dump(vs->body.d[offset]);
185
for(src = 0; src < 3; ++src) {
186
fprintf(stderr, " src%i: 0x%08x", src, vs->body.d[offset+1+src]);
187
r300_vs_src_dump(vs->body.d[offset+1+src]);
191
fprintf(stderr, "Flow Control Ops: 0x%08x\n",vs->fc_ops);
192
for(i = 0; i < vs->num_fc_ops; i++) {
193
switch((vs->fc_ops >> (i * 2)) & 0x3 ) {
194
case 0: fprintf(stderr, "NOP"); break;
195
case 1: fprintf(stderr, "JUMP"); break;
196
case 2: fprintf(stderr, "LOOP"); break;
197
case 3: fprintf(stderr, "JSR"); break;
199
if (c->Base.is_r500) {
200
fprintf(stderr,": uw-> 0x%08x lw-> 0x%08x\n",
201
vs->fc_op_addrs.r500[i].uw,
202
vs->fc_op_addrs.r500[i].lw);
204
fprintf(stderr,": 0x%08x\n", vs->fc_op_addrs.r300[i]);