v3d/tex: don't configure tmu config 1 if not needed
[mesa.git] / src / broadcom / common / v3d_debug.c
1 /*
2 * Copyright 2003 VMware, Inc.
3 * Copyright © 2006 Intel Corporation
4 * Copyright © 2017 Broadcom
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
24 */
25
26 /**
27 * \file v3d_debug.c
28 *
29 * Support for the V3D_DEBUG environment variable, along with other
30 * miscellaneous debugging code.
31 */
32
33 #include <stdlib.h>
34
35 #include "common/v3d_debug.h"
36 #include "util/macros.h"
37 #include "util/debug.h"
38 #include "c11/threads.h"
39
40 uint32_t V3D_DEBUG = 0;
41
42 static const struct debug_control debug_control[] = {
43 { "cl", V3D_DEBUG_CL},
44 { "clif", V3D_DEBUG_CLIF},
45 { "qpu", V3D_DEBUG_QPU},
46 { "vir", V3D_DEBUG_VIR},
47 { "nir", V3D_DEBUG_NIR},
48 { "tgsi", V3D_DEBUG_TGSI},
49 { "shaderdb", V3D_DEBUG_SHADERDB},
50 { "surface", V3D_DEBUG_SURFACE},
51 { "perf", V3D_DEBUG_PERF},
52 { "norast", V3D_DEBUG_NORAST},
53 { "fs", V3D_DEBUG_FS},
54 { "gs", V3D_DEBUG_GS},
55 { "vs", V3D_DEBUG_VS},
56 { "cs", V3D_DEBUG_CS},
57 { "always_flush", V3D_DEBUG_ALWAYS_FLUSH},
58 { "precompile", V3D_DEBUG_PRECOMPILE},
59 { NULL, 0 }
60 };
61
62 uint32_t
63 v3d_debug_flag_for_shader_stage(gl_shader_stage stage)
64 {
65 uint32_t flags[] = {
66 [MESA_SHADER_VERTEX] = V3D_DEBUG_VS,
67 [MESA_SHADER_TESS_CTRL] = 0,
68 [MESA_SHADER_TESS_EVAL] = 0,
69 [MESA_SHADER_GEOMETRY] = V3D_DEBUG_GS,
70 [MESA_SHADER_FRAGMENT] = V3D_DEBUG_FS,
71 [MESA_SHADER_COMPUTE] = V3D_DEBUG_CS,
72 };
73 STATIC_ASSERT(MESA_SHADER_STAGES == 6);
74 return flags[stage];
75 }
76
77 static void
78 v3d_process_debug_variable_once(void)
79 {
80 V3D_DEBUG = parse_debug_string(getenv("V3D_DEBUG"), debug_control);
81
82 if (V3D_DEBUG & V3D_DEBUG_SHADERDB)
83 V3D_DEBUG |= V3D_DEBUG_NORAST;
84 }
85
86 void
87 v3d_process_debug_variable(void)
88 {
89 static once_flag v3d_process_debug_variable_flag = ONCE_FLAG_INIT;
90
91 call_once(&v3d_process_debug_variable_flag,
92 v3d_process_debug_variable_once);
93 }