Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/broadcom/common/v3d_debug.c
4560 views
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
{ "ra", V3D_DEBUG_RA},
60
{ "dump_spirv", V3D_DEBUG_DUMP_SPIRV},
61
{ NULL, 0 }
62
};
63
64
uint32_t
65
v3d_debug_flag_for_shader_stage(gl_shader_stage stage)
66
{
67
uint32_t flags[] = {
68
[MESA_SHADER_VERTEX] = V3D_DEBUG_VS,
69
[MESA_SHADER_TESS_CTRL] = 0,
70
[MESA_SHADER_TESS_EVAL] = 0,
71
[MESA_SHADER_GEOMETRY] = V3D_DEBUG_GS,
72
[MESA_SHADER_FRAGMENT] = V3D_DEBUG_FS,
73
[MESA_SHADER_COMPUTE] = V3D_DEBUG_CS,
74
};
75
STATIC_ASSERT(MESA_SHADER_STAGES == 6);
76
return flags[stage];
77
}
78
79
static void
80
v3d_process_debug_variable_once(void)
81
{
82
V3D_DEBUG = parse_debug_string(getenv("V3D_DEBUG"), debug_control);
83
84
if (V3D_DEBUG & V3D_DEBUG_SHADERDB)
85
V3D_DEBUG |= V3D_DEBUG_NORAST;
86
}
87
88
void
89
v3d_process_debug_variable(void)
90
{
91
static once_flag v3d_process_debug_variable_flag = ONCE_FLAG_INIT;
92
93
call_once(&v3d_process_debug_variable_flag,
94
v3d_process_debug_variable_once);
95
}
96
97