2 * Copyright 2003 VMware, Inc.
3 * Copyright © 2006 Intel Corporation
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:
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
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
28 * Support for the INTEL_DEBUG environment variable, along with other
29 * miscellaneous debugging code.
32 #include "brw_context.h"
33 #include "intel_debug.h"
35 #include "util/u_atomic.h" /* for p_atomic_cmpxchg */
36 #include "util/debug.h"
38 uint64_t INTEL_DEBUG
= 0;
40 static const struct debug_control debug_control
[] = {
41 { "tex", DEBUG_TEXTURE
},
42 { "state", DEBUG_STATE
},
43 { "blit", DEBUG_BLIT
},
44 { "mip", DEBUG_MIPTREE
},
45 { "fall", DEBUG_PERF
},
46 { "perf", DEBUG_PERF
},
47 { "perfmon", DEBUG_PERFMON
},
48 { "bat", DEBUG_BATCH
},
49 { "pix", DEBUG_PIXEL
},
50 { "buf", DEBUG_BUFMGR
},
54 { "sync", DEBUG_SYNC
},
55 { "prim", DEBUG_PRIMS
},
56 { "vert", DEBUG_VERTS
},
59 { "stats", DEBUG_STATS
},
63 { "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
},
72 { "vec4", DEBUG_VEC4VS
},
73 { "spill_fs", DEBUG_SPILL_FS
},
74 { "spill_vec4", DEBUG_SPILL_VEC4
},
77 { "nocompact", DEBUG_NO_COMPACTION
},
82 intel_debug_flag_for_shader_stage(gl_shader_stage stage
)
85 [MESA_SHADER_VERTEX
] = DEBUG_VS
,
86 [MESA_SHADER_TESS_CTRL
] = 0,
87 [MESA_SHADER_TESS_EVAL
] = 0,
88 [MESA_SHADER_GEOMETRY
] = DEBUG_GS
,
89 [MESA_SHADER_FRAGMENT
] = DEBUG_WM
,
90 [MESA_SHADER_COMPUTE
] = DEBUG_CS
,
92 STATIC_ASSERT(MESA_SHADER_STAGES
== 6);
97 brw_process_intel_debug_variable(void)
99 uint64_t intel_debug
= parse_debug_string(getenv("INTEL_DEBUG"), debug_control
);
100 (void) p_atomic_cmpxchg(&INTEL_DEBUG
, 0, intel_debug
);
104 * Reads an environment variable and interprets its value as a boolean.
106 * Recognizes 0/false/no and 1/true/yes. Other values result in the default value.
109 brw_env_var_as_boolean(const char *var_name
, bool default_value
)
111 const char *str
= getenv(var_name
);
113 return default_value
;
115 if (strcmp(str
, "1") == 0 ||
116 strcasecmp(str
, "true") == 0 ||
117 strcasecmp(str
, "yes") == 0) {
119 } else if (strcmp(str
, "0") == 0 ||
120 strcasecmp(str
, "false") == 0 ||
121 strcasecmp(str
, "no") == 0) {
124 return default_value
;