xref: /aosp_15_r20/external/mesa3d/src/broadcom/common/v3d_debug.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2003 VMware, Inc.
3  * Copyright © 2007 Intel Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial
15  * portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef MESA_V3D_DEBUG_H
27 #define MESA_V3D_DEBUG_H
28 
29 #include <stdint.h>
30 #include "compiler/shader_enums.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 /**
36  * \file v3d_debug.h
37  *
38  * Basic V3D_DEBUG environment variable handling.  This file defines the
39  * list of debugging flags, as well as some macros for handling them.
40  */
41 
42 extern uint32_t v3d_mesa_debug;
43 
44 #define V3D_DBG(flag) unlikely(v3d_mesa_debug & V3D_DEBUG_ ## flag)
45 
46 #define V3D_DEBUG_SHADERDB          (1 << 0)
47 #define V3D_DEBUG_TGSI              (1 << 1)
48 #define V3D_DEBUG_NIR               (1 << 2)
49 #define V3D_DEBUG_VIR               (1 << 3)
50 #define V3D_DEBUG_QPU               (1 << 4)
51 #define V3D_DEBUG_FS                (1 << 5)
52 #define V3D_DEBUG_GS                (1 << 6)
53 #define V3D_DEBUG_VS                (1 << 7)
54 #define V3D_DEBUG_CS                (1 << 8)
55 #define V3D_DEBUG_CL                (1 << 9)
56 #define V3D_DEBUG_SURFACE           (1 << 10)
57 #define V3D_DEBUG_PERF              (1 << 11)
58 #define V3D_DEBUG_NORAST            (1 << 12)
59 #define V3D_DEBUG_ALWAYS_FLUSH      (1 << 13)
60 #define V3D_DEBUG_CLIF              (1 << 14)
61 #define V3D_DEBUG_PRECOMPILE        (1 << 15)
62 #define V3D_DEBUG_RA                (1 << 16)
63 #define V3D_DEBUG_TMU_32BIT         (1 << 18)
64 #define V3D_DEBUG_TMU_16BIT         (1 << 19)
65 #define V3D_DEBUG_NO_LOOP_UNROLL    (1 << 20)
66 #define V3D_DEBUG_CL_NO_BIN         (1 << 21)
67 #define V3D_DEBUG_DOUBLE_BUFFER     (1 << 22)
68 #define V3D_DEBUG_CACHE             (1 << 23)
69 #define V3D_DEBUG_NO_MERGE_JOBS     (1 << 24)
70 #define V3D_DEBUG_OPT_COMPILE_TIME  (1 << 25)
71 #define V3D_DEBUG_DISABLE_TFU       (1 << 26)
72 
73 #define V3D_DEBUG_SHADERS           (V3D_DEBUG_TGSI | V3D_DEBUG_NIR | \
74                                      V3D_DEBUG_VIR | V3D_DEBUG_QPU | \
75                                      V3D_DEBUG_FS | V3D_DEBUG_GS | \
76                                      V3D_DEBUG_VS | V3D_DEBUG_CS | \
77                                      V3D_DEBUG_RA)
78 
79 #ifdef HAVE_ANDROID_PLATFORM
80 #define LOG_TAG "BROADCOM-MESA"
81 #if ANDROID_API_LEVEL >= 26
82 #include <log/log.h>
83 #else
84 #include <cutils/log.h>
85 #endif /* use log/log.h start from android 8 major version */
86 #ifndef ALOGW
87 #define ALOGW LOGW
88 #endif
89 #define dbg_printf(...)	ALOGW(__VA_ARGS__)
90 #else
91 #define dbg_printf(...)	fprintf(stderr, __VA_ARGS__)
92 #endif /* HAVE_ANDROID_PLATFORM */
93 
94 extern bool v3d_debug_flag_for_shader_stage(gl_shader_stage stage);
95 
96 extern void v3d_process_debug_variable(void);
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* V3D_DEBUG_H */
103