• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2003 VMware, Inc.
3  * Copyright © 2006 Intel Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 /**
26  * \file gen_debug.c
27  *
28  * Support for the INTEL_DEBUG environment variable, along with other
29  * miscellaneous debugging code.
30  */
31 
32 #include <stdlib.h>
33 
34 #include "common/gen_debug.h"
35 #include "util/macros.h"
36 #include "util/debug.h"
37 #include "c11/threads.h"
38 
39 uint64_t INTEL_DEBUG = 0;
40 
41 static const struct debug_control debug_control[] = {
42    { "tex",         DEBUG_TEXTURE},
43    { "state",       DEBUG_STATE},
44    { "blit",        DEBUG_BLIT},
45    { "mip",         DEBUG_MIPTREE},
46    { "fall",        DEBUG_PERF},
47    { "perf",        DEBUG_PERF},
48    { "perfmon",     DEBUG_PERFMON},
49    { "bat",         DEBUG_BATCH},
50    { "pix",         DEBUG_PIXEL},
51    { "buf",         DEBUG_BUFMGR},
52    { "fbo",         DEBUG_FBO},
53    { "fs",          DEBUG_WM },
54    { "gs",          DEBUG_GS},
55    { "sync",        DEBUG_SYNC},
56    { "prim",        DEBUG_PRIMS },
57    { "vert",        DEBUG_VERTS },
58    { "dri",         DEBUG_DRI },
59    { "sf",          DEBUG_SF },
60    { "submit",      DEBUG_SUBMIT },
61    { "wm",          DEBUG_WM },
62    { "urb",         DEBUG_URB },
63    { "vs",          DEBUG_VS },
64    { "clip",        DEBUG_CLIP },
65    { "shader_time", DEBUG_SHADER_TIME },
66    { "no16",        DEBUG_NO16 },
67    { "blorp",       DEBUG_BLORP },
68    { "nodualobj",   DEBUG_NO_DUAL_OBJECT_GS },
69    { "optimizer",   DEBUG_OPTIMIZER },
70    { "ann",         DEBUG_ANNOTATION },
71    { "no8",         DEBUG_NO8 },
72    { "no-oaconfig", DEBUG_NO_OACONFIG },
73    { "spill_fs",    DEBUG_SPILL_FS },
74    { "spill_vec4",  DEBUG_SPILL_VEC4 },
75    { "cs",          DEBUG_CS },
76    { "hex",         DEBUG_HEX },
77    { "nocompact",   DEBUG_NO_COMPACTION },
78    { "hs",          DEBUG_TCS },
79    { "tcs",         DEBUG_TCS },
80    { "ds",          DEBUG_TES },
81    { "tes",         DEBUG_TES },
82    { "l3",          DEBUG_L3 },
83    { "do32",        DEBUG_DO32 },
84    { "norbc",       DEBUG_NO_RBC },
85    { "nohiz",       DEBUG_NO_HIZ },
86    { "color",       DEBUG_COLOR },
87    { "reemit",      DEBUG_REEMIT },
88    { NULL,    0 }
89 };
90 
91 uint64_t
intel_debug_flag_for_shader_stage(gl_shader_stage stage)92 intel_debug_flag_for_shader_stage(gl_shader_stage stage)
93 {
94    uint64_t flags[] = {
95       [MESA_SHADER_VERTEX] = DEBUG_VS,
96       [MESA_SHADER_TESS_CTRL] = DEBUG_TCS,
97       [MESA_SHADER_TESS_EVAL] = DEBUG_TES,
98       [MESA_SHADER_GEOMETRY] = DEBUG_GS,
99       [MESA_SHADER_FRAGMENT] = DEBUG_WM,
100       [MESA_SHADER_COMPUTE] = DEBUG_CS,
101    };
102    STATIC_ASSERT(MESA_SHADER_STAGES == 6);
103    return flags[stage];
104 }
105 
106 static void
brw_process_intel_debug_variable_once(void)107 brw_process_intel_debug_variable_once(void)
108 {
109    INTEL_DEBUG = parse_debug_string(getenv("INTEL_DEBUG"), debug_control);
110 }
111 
112 void
brw_process_intel_debug_variable(void)113 brw_process_intel_debug_variable(void)
114 {
115    static once_flag process_intel_debug_variable_flag = ONCE_FLAG_INIT;
116 
117    call_once(&process_intel_debug_variable_flag,
118              brw_process_intel_debug_variable_once);
119 }
120