r300g: remove fake occlusion queries (debug option)
[mesa.git] / src / gallium / drivers / r300 / r300_debug.c
1 /*
2 * Copyright 2009 Nicolai Haehnle <nhaehnle@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_context.h"
24
25 #include "util/u_debug.h"
26
27 #include <stdio.h>
28
29 static const struct debug_named_value debug_options[] = {
30 { "info", DBG_INFO, "Print hardware info"},
31 { "fp", DBG_FP, "Log fragment program compilation" },
32 { "vp", DBG_VP, "Log vertex program compilation" },
33 { "pstat", DBG_P_STAT, "Log vertex/fragment program stats" },
34 { "draw", DBG_DRAW, "Log draw calls" },
35 { "swtcl", DBG_SWTCL, "Log SWTCL-specific info" },
36 { "rsblock", DBG_RS_BLOCK, "Log rasterizer registers" },
37 { "psc", DBG_PSC, "Log vertex stream registers" },
38 { "tex", DBG_TEX, "Log basic info about textures" },
39 { "texalloc", DBG_TEXALLOC, "Log texture mipmap tree info" },
40 { "rs", DBG_RS, "Log rasterizer" },
41 { "fb", DBG_FB, "Log framebuffer" },
42 { "cbzb", DBG_CBZB, "Log fast color clear info" },
43 { "hyperz", DBG_HYPERZ, "Log HyperZ info" },
44 { "upload", DBG_UPLOAD, "Log user buffer upload info" },
45 { "scissor", DBG_SCISSOR, "Log scissor info" },
46 { "anisohq", DBG_ANISOHQ, "Use high quality anisotropic filtering" },
47 { "notiling", DBG_NO_TILING, "Disable tiling" },
48 { "noimmd", DBG_NO_IMMD, "Disable immediate mode" },
49 { "noopt", DBG_NO_OPT, "Disable shader optimizations" },
50 { "nocbzb", DBG_NO_CBZB, "Disable fast color clear" },
51 { "nozmask", DBG_NO_ZMASK, "Disable zbuffer compression" },
52 { "nohiz", DBG_NO_HIZ, "Disable hierarchical zbuffer" },
53
54 /* must be last */
55 DEBUG_NAMED_VALUE_END
56 };
57
58 void r300_init_debug(struct r300_screen * screen)
59 {
60 screen->debug = debug_get_flags_option("RADEON_DEBUG", debug_options, 0);
61 }
62
63 void r500_dump_rs_block(struct r300_rs_block *rs)
64 {
65 unsigned count, ip, it_count, ic_count, i, j;
66 unsigned tex_ptr;
67 unsigned col_ptr, col_fmt;
68
69 count = rs->inst_count & 0xf;
70 count++;
71
72 it_count = rs->count & 0x7f;
73 ic_count = (rs->count >> 7) & 0xf;
74
75 fprintf(stderr, "RS Block: %d texcoords (linear), %d colors (perspective)\n",
76 it_count, ic_count);
77 fprintf(stderr, "%d instructions\n", count);
78
79 for (i = 0; i < count; i++) {
80 if (rs->inst[i] & 0x10) {
81 ip = rs->inst[i] & 0xf;
82 fprintf(stderr, "texture: ip %d to psf %d\n",
83 ip, (rs->inst[i] >> 5) & 0x7f);
84
85 tex_ptr = rs->ip[ip] & 0xffffff;
86 fprintf(stderr, " : ");
87
88 j = 3;
89 do {
90 if ((tex_ptr & 0x3f) == 63) {
91 fprintf(stderr, "1.0");
92 } else if ((tex_ptr & 0x3f) == 62) {
93 fprintf(stderr, "0.0");
94 } else {
95 fprintf(stderr, "[%d]", tex_ptr & 0x3f);
96 }
97 } while (j-- && fprintf(stderr, "/"));
98 fprintf(stderr, "\n");
99 }
100
101 if (rs->inst[i] & 0x10000) {
102 ip = (rs->inst[i] >> 12) & 0xf;
103 fprintf(stderr, "color: ip %d to psf %d\n",
104 ip, (rs->inst[i] >> 18) & 0x7f);
105
106 col_ptr = (rs->ip[ip] >> 24) & 0x7;
107 col_fmt = (rs->ip[ip] >> 27) & 0xf;
108 fprintf(stderr, " : offset %d ", col_ptr);
109
110 switch (col_fmt) {
111 case 0:
112 fprintf(stderr, "(R/G/B/A)");
113 break;
114 case 1:
115 fprintf(stderr, "(R/G/B/0)");
116 break;
117 case 2:
118 fprintf(stderr, "(R/G/B/1)");
119 break;
120 case 4:
121 fprintf(stderr, "(0/0/0/A)");
122 break;
123 case 5:
124 fprintf(stderr, "(0/0/0/0)");
125 break;
126 case 6:
127 fprintf(stderr, "(0/0/0/1)");
128 break;
129 case 8:
130 fprintf(stderr, "(1/1/1/A)");
131 break;
132 case 9:
133 fprintf(stderr, "(1/1/1/0)");
134 break;
135 case 10:
136 fprintf(stderr, "(1/1/1/1)");
137 break;
138 }
139 fprintf(stderr, "\n");
140 }
141 }
142 }