• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2009 Nicolai Haehnle <nhaehnle@gmail.com>
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     { "ieeemath", DBG_IEEEMATH, "Force IEEE versions of VS math opcodes where applicable and also IEEE handling of multiply by zero (R5xx only)" },
38     { "ffmath", DBG_FFMATH, "Force FF versions of VS math opcodes where applicable and 0*anything=0 rules in FS" },
39 
40     /* must be last */
41     DEBUG_NAMED_VALUE_END
42 };
43 
r300_init_debug(struct r300_screen * screen)44 void r300_init_debug(struct r300_screen * screen)
45 {
46     screen->debug = debug_get_flags_option("RADEON_DEBUG", r300_debug_options, 0);
47 }
48 
r500_dump_rs_block(struct r300_rs_block * rs)49 void r500_dump_rs_block(struct r300_rs_block *rs)
50 {
51     unsigned count, ip, it_count, ic_count, i, j;
52     unsigned tex_ptr;
53     unsigned col_ptr, col_fmt;
54 
55     count = rs->inst_count & 0xf;
56     count++;
57 
58     it_count = rs->count & 0x7f;
59     ic_count = (rs->count >> 7) & 0xf;
60 
61     fprintf(stderr, "RS Block: %d texcoords (linear), %d colors (perspective)\n",
62         it_count, ic_count);
63     fprintf(stderr, "%d instructions\n", count);
64 
65     for (i = 0; i < count; i++) {
66         if (rs->inst[i] & 0x10) {
67             ip = rs->inst[i] & 0xf;
68             fprintf(stderr, "texture: ip %d to psf %d\n",
69                 ip, (rs->inst[i] >> 5) & 0x7f);
70 
71             tex_ptr = rs->ip[ip] & 0xffffff;
72             fprintf(stderr, "       : ");
73 
74             j = 3;
75             do {
76                 if ((tex_ptr & 0x3f) == 63) {
77                     fprintf(stderr, "1.0");
78                 } else if ((tex_ptr & 0x3f) == 62) {
79                     fprintf(stderr, "0.0");
80                 } else {
81                     fprintf(stderr, "[%d]", tex_ptr & 0x3f);
82                 }
83             } while (j-- && fprintf(stderr, "/"));
84             fprintf(stderr, "\n");
85         }
86 
87         if (rs->inst[i] & 0x10000) {
88             ip = (rs->inst[i] >> 12) & 0xf;
89             fprintf(stderr, "color: ip %d to psf %d\n",
90                 ip, (rs->inst[i] >> 18) & 0x7f);
91 
92             col_ptr = (rs->ip[ip] >> 24) & 0x7;
93             col_fmt = (rs->ip[ip] >> 27) & 0xf;
94             fprintf(stderr, "     : offset %d ", col_ptr);
95 
96             switch (col_fmt) {
97                 case 0:
98                     fprintf(stderr, "(R/G/B/A)");
99                     break;
100                 case 1:
101                     fprintf(stderr, "(R/G/B/0)");
102                     break;
103                 case 2:
104                     fprintf(stderr, "(R/G/B/1)");
105                     break;
106                 case 4:
107                     fprintf(stderr, "(0/0/0/A)");
108                     break;
109                 case 5:
110                     fprintf(stderr, "(0/0/0/0)");
111                     break;
112                 case 6:
113                     fprintf(stderr, "(0/0/0/1)");
114                     break;
115                 case 8:
116                     fprintf(stderr, "(1/1/1/A)");
117                     break;
118                 case 9:
119                     fprintf(stderr, "(1/1/1/0)");
120                     break;
121                 case 10:
122                     fprintf(stderr, "(1/1/1/1)");
123                     break;
124             }
125             fprintf(stderr, "\n");
126         }
127     }
128 }
129