xref: /third_party/mesa3d/src/intel/dev/intel_debug.h (revision bf215546)
1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2003 VMware, Inc.
3bf215546Sopenharmony_ci * Copyright © 2007 Intel Corporation
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining
6bf215546Sopenharmony_ci * a copy of this software and associated documentation files (the
7bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
8bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
9bf215546Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to
10bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
11bf215546Sopenharmony_ci * the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
14bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial
15bf215546Sopenharmony_ci * portions of the Software.
16bf215546Sopenharmony_ci *
17bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20bf215546Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21bf215546Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22bf215546Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23bf215546Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24bf215546Sopenharmony_ci */
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#ifndef INTEL_DEBUG_H
27bf215546Sopenharmony_ci#define INTEL_DEBUG_H
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci#include <stdint.h>
30bf215546Sopenharmony_ci#include "compiler/shader_enums.h"
31bf215546Sopenharmony_ci#include "util/macros.h"
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#ifdef __cplusplus
34bf215546Sopenharmony_ciextern "C" {
35bf215546Sopenharmony_ci#endif
36bf215546Sopenharmony_ci/**
37bf215546Sopenharmony_ci * \file intel_debug.h
38bf215546Sopenharmony_ci *
39bf215546Sopenharmony_ci * Basic INTEL_DEBUG environment variable handling.  This file defines the
40bf215546Sopenharmony_ci * list of debugging flags, as well as some macros for handling them.
41bf215546Sopenharmony_ci */
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ciextern uint64_t intel_debug;
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci/* Returns 0/1, not the matching bit mask. */
46bf215546Sopenharmony_ci#define INTEL_DEBUG(flags)        unlikely(intel_debug & (flags))
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ci#define DEBUG_TEXTURE             (1ull <<  0)
49bf215546Sopenharmony_ci#define DEBUG_BLIT                (1ull <<  1)
50bf215546Sopenharmony_ci#define DEBUG_PERF                (1ull <<  2)
51bf215546Sopenharmony_ci#define DEBUG_PERFMON             (1ull <<  3)
52bf215546Sopenharmony_ci#define DEBUG_BATCH               (1ull <<  4)
53bf215546Sopenharmony_ci#define DEBUG_BUFMGR              (1ull <<  5)
54bf215546Sopenharmony_ci#define DEBUG_GS                  (1ull <<  6)
55bf215546Sopenharmony_ci#define DEBUG_SYNC                (1ull <<  7)
56bf215546Sopenharmony_ci#define DEBUG_SF                  (1ull <<  8)
57bf215546Sopenharmony_ci#define DEBUG_SUBMIT              (1ull <<  9)
58bf215546Sopenharmony_ci#define DEBUG_WM                  (1ull << 10)
59bf215546Sopenharmony_ci#define DEBUG_URB                 (1ull << 11)
60bf215546Sopenharmony_ci#define DEBUG_VS                  (1ull << 12)
61bf215546Sopenharmony_ci#define DEBUG_CLIP                (1ull << 13)
62bf215546Sopenharmony_ci#define DEBUG_STALL               (1ull << 14)
63bf215546Sopenharmony_ci#define DEBUG_BLORP               (1ull << 15)
64bf215546Sopenharmony_ci#define DEBUG_NO16                (1ull << 16)
65bf215546Sopenharmony_ci#define DEBUG_NO_DUAL_OBJECT_GS   (1ull << 17)
66bf215546Sopenharmony_ci#define DEBUG_OPTIMIZER           (1ull << 18)
67bf215546Sopenharmony_ci#define DEBUG_ANNOTATION          (1ull << 19)
68bf215546Sopenharmony_ci#define DEBUG_NO8                 (1ull << 20)
69bf215546Sopenharmony_ci#define DEBUG_NO_OACONFIG         (1ull << 21)
70bf215546Sopenharmony_ci#define DEBUG_SPILL_FS            (1ull << 22)
71bf215546Sopenharmony_ci#define DEBUG_SPILL_VEC4          (1ull << 23)
72bf215546Sopenharmony_ci#define DEBUG_CS                  (1ull << 24)
73bf215546Sopenharmony_ci#define DEBUG_HEX                 (1ull << 25)
74bf215546Sopenharmony_ci#define DEBUG_NO_COMPACTION       (1ull << 26)
75bf215546Sopenharmony_ci#define DEBUG_TCS                 (1ull << 27)
76bf215546Sopenharmony_ci#define DEBUG_TES                 (1ull << 28)
77bf215546Sopenharmony_ci#define DEBUG_L3                  (1ull << 29)
78bf215546Sopenharmony_ci#define DEBUG_DO32                (1ull << 30)
79bf215546Sopenharmony_ci#define DEBUG_NO_CCS              (1ull << 31)
80bf215546Sopenharmony_ci#define DEBUG_NO_HIZ              (1ull << 32)
81bf215546Sopenharmony_ci#define DEBUG_COLOR               (1ull << 33)
82bf215546Sopenharmony_ci#define DEBUG_REEMIT              (1ull << 34)
83bf215546Sopenharmony_ci#define DEBUG_SOFT64              (1ull << 35)
84bf215546Sopenharmony_ci#define DEBUG_TCS_EIGHT_PATCH     (1ull << 36)
85bf215546Sopenharmony_ci#define DEBUG_BT                  (1ull << 37)
86bf215546Sopenharmony_ci#define DEBUG_PIPE_CONTROL        (1ull << 38)
87bf215546Sopenharmony_ci#define DEBUG_NO_FAST_CLEAR       (1ull << 39)
88bf215546Sopenharmony_ci#define DEBUG_NO32                (1ull << 40)
89bf215546Sopenharmony_ci#define DEBUG_RT                  (1ull << 41)
90bf215546Sopenharmony_ci#define DEBUG_TASK                (1ull << 42)
91bf215546Sopenharmony_ci#define DEBUG_MESH                (1ull << 43)
92bf215546Sopenharmony_ci
93bf215546Sopenharmony_ci#define DEBUG_ANY                 (~0ull)
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci#define DEBUG_ANY                 (~0ull)
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci/* These flags are not compatible with the disk shader cache */
98bf215546Sopenharmony_ci#define DEBUG_DISK_CACHE_DISABLE_MASK 0
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_ci/* These flags may affect program generation */
101bf215546Sopenharmony_ci#define DEBUG_DISK_CACHE_MASK \
102bf215546Sopenharmony_ci   (DEBUG_NO16 | DEBUG_NO_DUAL_OBJECT_GS | DEBUG_NO8 |  DEBUG_SPILL_FS | \
103bf215546Sopenharmony_ci   DEBUG_SPILL_VEC4 | DEBUG_NO_COMPACTION | DEBUG_DO32 | DEBUG_SOFT64 | \
104bf215546Sopenharmony_ci   DEBUG_TCS_EIGHT_PATCH | DEBUG_NO32)
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci#ifdef HAVE_ANDROID_PLATFORM
107bf215546Sopenharmony_ci#define LOG_TAG "INTEL-MESA"
108bf215546Sopenharmony_ci#if ANDROID_API_LEVEL >= 26
109bf215546Sopenharmony_ci#include <log/log.h>
110bf215546Sopenharmony_ci#else
111bf215546Sopenharmony_ci#include <cutils/log.h>
112bf215546Sopenharmony_ci#endif /* use log/log.h start from android 8 major version */
113bf215546Sopenharmony_ci#ifndef ALOGW
114bf215546Sopenharmony_ci#define ALOGW LOGW
115bf215546Sopenharmony_ci#endif
116bf215546Sopenharmony_ci#define dbg_printf(...)	ALOGW(__VA_ARGS__)
117bf215546Sopenharmony_ci#else
118bf215546Sopenharmony_ci#define dbg_printf(...)	fprintf(stderr, __VA_ARGS__)
119bf215546Sopenharmony_ci#endif /* HAVE_ANDROID_PLATFORM */
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci#define DBG(...) do {                  \
122bf215546Sopenharmony_ci   if (INTEL_DEBUG(FILE_DEBUG_FLAG))   \
123bf215546Sopenharmony_ci      dbg_printf(__VA_ARGS__);         \
124bf215546Sopenharmony_ci} while(0)
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ciextern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_ciextern void brw_process_intel_debug_variable(void);
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci/* Below is a list of structure located in the identifier buffer. The driver
131bf215546Sopenharmony_ci * can fill those in for debug purposes.
132bf215546Sopenharmony_ci */
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_cienum intel_debug_block_type {
135bf215546Sopenharmony_ci   /* End of the debug blocks */
136bf215546Sopenharmony_ci   INTEL_DEBUG_BLOCK_TYPE_END = 1,
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ci   /* Driver identifier (struct intel_debug_block_driver) */
139bf215546Sopenharmony_ci   INTEL_DEBUG_BLOCK_TYPE_DRIVER,
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ci   /* Frame identifier (struct intel_debug_block_frame) */
142bf215546Sopenharmony_ci   INTEL_DEBUG_BLOCK_TYPE_FRAME,
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci   /* Internal, never to be written out */
145bf215546Sopenharmony_ci   INTEL_DEBUG_BLOCK_TYPE_MAX,
146bf215546Sopenharmony_ci};
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_cistruct intel_debug_block_base {
149bf215546Sopenharmony_ci   uint32_t type; /* enum intel_debug_block_type */
150bf215546Sopenharmony_ci   uint32_t length; /* inclusive of this structure size */
151bf215546Sopenharmony_ci};
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_cistruct intel_debug_block_driver {
154bf215546Sopenharmony_ci   struct intel_debug_block_base base;
155bf215546Sopenharmony_ci   uint8_t description[];
156bf215546Sopenharmony_ci};
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_cistruct intel_debug_block_frame {
159bf215546Sopenharmony_ci   struct intel_debug_block_base base;
160bf215546Sopenharmony_ci   uint64_t frame_id;
161bf215546Sopenharmony_ci};
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ciextern void *intel_debug_identifier(void);
164bf215546Sopenharmony_ciextern uint32_t intel_debug_identifier_size(void);
165bf215546Sopenharmony_ci
166bf215546Sopenharmony_ciextern uint32_t intel_debug_write_identifiers(void *output,
167bf215546Sopenharmony_ci                                              uint32_t output_size,
168bf215546Sopenharmony_ci                                              const char *driver_name);
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ciextern void *intel_debug_get_identifier_block(void *buffer,
171bf215546Sopenharmony_ci                                              uint32_t buffer_size,
172bf215546Sopenharmony_ci                                              enum intel_debug_block_type type);
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci#ifdef __cplusplus
175bf215546Sopenharmony_ci}
176bf215546Sopenharmony_ci#endif
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci#endif /* INTEL_DEBUG_H */
179