1b8e80941Smrg/*
2b8e80941Smrg * Copyright 2003 VMware, Inc.
3b8e80941Smrg * Copyright © 2007 Intel Corporation
4b8e80941Smrg *
5b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining
6b8e80941Smrg * a copy of this software and associated documentation files (the
7b8e80941Smrg * "Software"), to deal in the Software without restriction, including
8b8e80941Smrg * without limitation the rights to use, copy, modify, merge, publish,
9b8e80941Smrg * distribute, sublicense, and/or sell copies of the Software, and to
10b8e80941Smrg * permit persons to whom the Software is furnished to do so, subject to
11b8e80941Smrg * the following conditions:
12b8e80941Smrg *
13b8e80941Smrg * The above copyright notice and this permission notice (including the
14b8e80941Smrg * next paragraph) shall be included in all copies or substantial
15b8e80941Smrg * portions of the Software.
16b8e80941Smrg *
17b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18b8e80941Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19b8e80941Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20b8e80941Smrg * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21b8e80941Smrg * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22b8e80941Smrg * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23b8e80941Smrg * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24b8e80941Smrg */
25b8e80941Smrg
26b8e80941Smrg#ifndef GEN_DEBUG_H
27b8e80941Smrg#define GEN_DEBUG_H
28b8e80941Smrg
29b8e80941Smrg#include <stdint.h>
30b8e80941Smrg#include "compiler/shader_enums.h"
31b8e80941Smrg
32b8e80941Smrg#ifdef __cplusplus
33b8e80941Smrgextern "C" {
34b8e80941Smrg#endif
35b8e80941Smrg/**
36b8e80941Smrg * \file gen_debug.h
37b8e80941Smrg *
38b8e80941Smrg * Basic INTEL_DEBUG environment variable handling.  This file defines the
39b8e80941Smrg * list of debugging flags, as well as some macros for handling them.
40b8e80941Smrg */
41b8e80941Smrg
42b8e80941Smrgextern uint64_t INTEL_DEBUG;
43b8e80941Smrg
44b8e80941Smrg#define DEBUG_TEXTURE             (1ull <<  0)
45b8e80941Smrg#define DEBUG_STATE               (1ull <<  1)
46b8e80941Smrg#define DEBUG_BLIT                (1ull <<  2)
47b8e80941Smrg#define DEBUG_MIPTREE             (1ull <<  3)
48b8e80941Smrg#define DEBUG_PERF                (1ull <<  4)
49b8e80941Smrg#define DEBUG_PERFMON             (1ull <<  5)
50b8e80941Smrg#define DEBUG_BATCH               (1ull <<  6)
51b8e80941Smrg#define DEBUG_PIXEL               (1ull <<  7)
52b8e80941Smrg#define DEBUG_BUFMGR              (1ull <<  8)
53b8e80941Smrg#define DEBUG_FBO                 (1ull <<  9)
54b8e80941Smrg#define DEBUG_GS                  (1ull << 10)
55b8e80941Smrg#define DEBUG_SYNC                (1ull << 11)
56b8e80941Smrg#define DEBUG_PRIMS               (1ull << 12)
57b8e80941Smrg#define DEBUG_VERTS               (1ull << 13)
58b8e80941Smrg#define DEBUG_DRI                 (1ull << 14)
59b8e80941Smrg#define DEBUG_SF                  (1ull << 15)
60b8e80941Smrg#define DEBUG_SUBMIT              (1ull << 16)
61b8e80941Smrg#define DEBUG_WM                  (1ull << 17)
62b8e80941Smrg#define DEBUG_URB                 (1ull << 18)
63b8e80941Smrg#define DEBUG_VS                  (1ull << 19)
64b8e80941Smrg#define DEBUG_CLIP                (1ull << 20)
65b8e80941Smrg#define DEBUG_SHADER_TIME         (1ull << 21)
66b8e80941Smrg#define DEBUG_BLORP               (1ull << 22)
67b8e80941Smrg#define DEBUG_NO16                (1ull << 23)
68b8e80941Smrg#define DEBUG_NO_DUAL_OBJECT_GS   (1ull << 24)
69b8e80941Smrg#define DEBUG_OPTIMIZER           (1ull << 25)
70b8e80941Smrg#define DEBUG_ANNOTATION          (1ull << 26)
71b8e80941Smrg#define DEBUG_NO8                 (1ull << 27)
72b8e80941Smrg#define DEBUG_NO_OACONFIG         (1ull << 28)
73b8e80941Smrg#define DEBUG_SPILL_FS            (1ull << 29)
74b8e80941Smrg#define DEBUG_SPILL_VEC4          (1ull << 30)
75b8e80941Smrg#define DEBUG_CS                  (1ull << 31)
76b8e80941Smrg#define DEBUG_HEX                 (1ull << 32)
77b8e80941Smrg#define DEBUG_NO_COMPACTION       (1ull << 33)
78b8e80941Smrg#define DEBUG_TCS                 (1ull << 34)
79b8e80941Smrg#define DEBUG_TES                 (1ull << 35)
80b8e80941Smrg#define DEBUG_L3                  (1ull << 36)
81b8e80941Smrg#define DEBUG_DO32                (1ull << 37)
82b8e80941Smrg#define DEBUG_NO_RBC              (1ull << 38)
83b8e80941Smrg#define DEBUG_NO_HIZ              (1ull << 39)
84b8e80941Smrg#define DEBUG_COLOR               (1ull << 40)
85b8e80941Smrg#define DEBUG_REEMIT              (1ull << 41)
86b8e80941Smrg#define DEBUG_SOFT64              (1ull << 42)
87b8e80941Smrg
88b8e80941Smrg/* These flags are not compatible with the disk shader cache */
89b8e80941Smrg#define DEBUG_DISK_CACHE_DISABLE_MASK DEBUG_SHADER_TIME
90b8e80941Smrg
91b8e80941Smrg/* These flags may affect program generation */
92b8e80941Smrg#define DEBUG_DISK_CACHE_MASK \
93b8e80941Smrg   (DEBUG_NO16 | DEBUG_NO_DUAL_OBJECT_GS | DEBUG_NO8 |  DEBUG_SPILL_FS | \
94b8e80941Smrg   DEBUG_SPILL_VEC4 | DEBUG_NO_COMPACTION | DEBUG_DO32 | DEBUG_SOFT64)
95b8e80941Smrg
96b8e80941Smrg#ifdef HAVE_ANDROID_PLATFORM
97b8e80941Smrg#define LOG_TAG "INTEL-MESA"
98b8e80941Smrg#if ANDROID_API_LEVEL >= 26
99b8e80941Smrg#include <log/log.h>
100b8e80941Smrg#else
101b8e80941Smrg#include <cutils/log.h>
102b8e80941Smrg#endif /* use log/log.h start from android 8 major version */
103b8e80941Smrg#ifndef ALOGW
104b8e80941Smrg#define ALOGW LOGW
105b8e80941Smrg#endif
106b8e80941Smrg#define dbg_printf(...)	ALOGW(__VA_ARGS__)
107b8e80941Smrg#else
108b8e80941Smrg#define dbg_printf(...)	fprintf(stderr, __VA_ARGS__)
109b8e80941Smrg#endif /* HAVE_ANDROID_PLATFORM */
110b8e80941Smrg
111b8e80941Smrg#define DBG(...) do {						\
112b8e80941Smrg	if (unlikely(INTEL_DEBUG & FILE_DEBUG_FLAG))		\
113b8e80941Smrg		dbg_printf(__VA_ARGS__);			\
114b8e80941Smrg} while(0)
115b8e80941Smrg
116b8e80941Smrgextern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
117b8e80941Smrg
118b8e80941Smrgextern void brw_process_intel_debug_variable(void);
119b8e80941Smrg
120b8e80941Smrg#ifdef __cplusplus
121b8e80941Smrg}
122b8e80941Smrg#endif
123b8e80941Smrg
124b8e80941Smrg#endif /* GEN_DEBUG_H */
125