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