1 /*
2 * Copyright 2009 Nicolai Haehnle <[email protected]>
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "r300_context.h"
7
8 #include "util/u_debug.h"
9
10 #include <stdio.h>
11
12 static const struct debug_named_value r300_debug_options[] = {
13 { "info", DBG_INFO, "Print hardware info (printed by default on debug builds"},
14 { "fp", DBG_FP, "Log fragment program compilation" },
15 { "vp", DBG_VP, "Log vertex program compilation" },
16 { "draw", DBG_DRAW, "Log draw calls" },
17 { "swtcl", DBG_SWTCL, "Log SWTCL-specific info" },
18 { "rsblock", DBG_RS_BLOCK, "Log rasterizer registers" },
19 { "psc", DBG_PSC, "Log vertex stream registers" },
20 { "tex", DBG_TEX, "Log basic info about textures" },
21 { "texalloc", DBG_TEXALLOC, "Log texture mipmap tree info" },
22 { "rs", DBG_RS, "Log rasterizer" },
23 { "fb", DBG_FB, "Log framebuffer" },
24 { "cbzb", DBG_CBZB, "Log fast color clear info" },
25 { "hyperz", DBG_HYPERZ, "Log HyperZ info" },
26 { "scissor", DBG_SCISSOR, "Log scissor info" },
27 { "msaa", DBG_MSAA, "Log MSAA resources"},
28 { "anisohq", DBG_ANISOHQ, "Use high quality anisotropic filtering" },
29 { "notiling", DBG_NO_TILING, "Disable tiling" },
30 { "noimmd", DBG_NO_IMMD, "Disable immediate mode" },
31 { "noopt", DBG_NO_OPT, "Disable shader optimizations" },
32 { "nocbzb", DBG_NO_CBZB, "Disable fast color clear" },
33 { "nozmask", DBG_NO_ZMASK, "Disable zbuffer compression" },
34 { "nohiz", DBG_NO_HIZ, "Disable hierarchical zbuffer" },
35 { "nocmask", DBG_NO_CMASK, "Disable AA compression and fast AA clear" },
36 { "notcl", DBG_NO_TCL, "Disable hardware accelerated Transform/Clip/Lighting" },
37
38 /* must be last */
39 DEBUG_NAMED_VALUE_END
40 };
41
r300_init_debug(struct r300_screen * screen)42 void r300_init_debug(struct r300_screen * screen)
43 {
44 screen->debug = debug_get_flags_option("RADEON_DEBUG", r300_debug_options, 0);
45 }
46
r500_dump_rs_block(struct r300_rs_block * rs)47 void r500_dump_rs_block(struct r300_rs_block *rs)
48 {
49 unsigned count, ip, it_count, ic_count, i, j;
50 unsigned tex_ptr;
51 unsigned col_ptr, col_fmt;
52
53 count = rs->inst_count & 0xf;
54 count++;
55
56 it_count = rs->count & 0x7f;
57 ic_count = (rs->count >> 7) & 0xf;
58
59 fprintf(stderr, "RS Block: %d texcoords (linear), %d colors (perspective)\n",
60 it_count, ic_count);
61 fprintf(stderr, "%d instructions\n", count);
62
63 for (i = 0; i < count; i++) {
64 if (rs->inst[i] & 0x10) {
65 ip = rs->inst[i] & 0xf;
66 fprintf(stderr, "texture: ip %d to psf %d\n",
67 ip, (rs->inst[i] >> 5) & 0x7f);
68
69 tex_ptr = rs->ip[ip] & 0xffffff;
70 fprintf(stderr, " : ");
71
72 j = 3;
73 do {
74 if ((tex_ptr & 0x3f) == 63) {
75 fprintf(stderr, "1.0");
76 } else if ((tex_ptr & 0x3f) == 62) {
77 fprintf(stderr, "0.0");
78 } else {
79 fprintf(stderr, "[%d]", tex_ptr & 0x3f);
80 }
81 } while (j-- && fprintf(stderr, "/"));
82 fprintf(stderr, "\n");
83 }
84
85 if (rs->inst[i] & 0x10000) {
86 ip = (rs->inst[i] >> 12) & 0xf;
87 fprintf(stderr, "color: ip %d to psf %d\n",
88 ip, (rs->inst[i] >> 18) & 0x7f);
89
90 col_ptr = (rs->ip[ip] >> 24) & 0x7;
91 col_fmt = (rs->ip[ip] >> 27) & 0xf;
92 fprintf(stderr, " : offset %d ", col_ptr);
93
94 switch (col_fmt) {
95 case 0:
96 fprintf(stderr, "(R/G/B/A)");
97 break;
98 case 1:
99 fprintf(stderr, "(R/G/B/0)");
100 break;
101 case 2:
102 fprintf(stderr, "(R/G/B/1)");
103 break;
104 case 4:
105 fprintf(stderr, "(0/0/0/A)");
106 break;
107 case 5:
108 fprintf(stderr, "(0/0/0/0)");
109 break;
110 case 6:
111 fprintf(stderr, "(0/0/0/1)");
112 break;
113 case 8:
114 fprintf(stderr, "(1/1/1/A)");
115 break;
116 case 9:
117 fprintf(stderr, "(1/1/1/0)");
118 break;
119 case 10:
120 fprintf(stderr, "(1/1/1/1)");
121 break;
122 }
123 fprintf(stderr, "\n");
124 }
125 }
126 }
127