1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (c) 2012-2013 Etnaviv Project
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
12bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
13bf215546Sopenharmony_ci * of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci/* Common debug stuffl */
25bf215546Sopenharmony_ci#ifndef H_ETNA_DEBUG
26bf215546Sopenharmony_ci#define H_ETNA_DEBUG
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include "util/log.h"
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include <stdint.h>
31bf215546Sopenharmony_ci#include <stdio.h>
32bf215546Sopenharmony_ci#include <stdlib.h>
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci/* Logging */
35bf215546Sopenharmony_ci#define ETNA_DBG_MSGS            0x1 /* Warnings and non-fatal errors */
36bf215546Sopenharmony_ci#define ETNA_DBG_FRAME_MSGS      0x2
37bf215546Sopenharmony_ci#define ETNA_DBG_RESOURCE_MSGS   0x4
38bf215546Sopenharmony_ci#define ETNA_DBG_COMPILER_MSGS   0x8
39bf215546Sopenharmony_ci#define ETNA_DBG_LINKER_MSGS     0x10
40bf215546Sopenharmony_ci#define ETNA_DBG_DUMP_SHADERS    0x20
41bf215546Sopenharmony_ci#define ETNA_DRM_MSGS            0x40 /* Debug messages from DRM */
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci/* Bypasses */
44bf215546Sopenharmony_ci#define ETNA_DBG_NO_TS           0x1000   /* Disable TS */
45bf215546Sopenharmony_ci#define ETNA_DBG_NO_AUTODISABLE  0x2000   /* Disable autodisable */
46bf215546Sopenharmony_ci#define ETNA_DBG_NO_SUPERTILE    0x4000   /* Disable supertile */
47bf215546Sopenharmony_ci#define ETNA_DBG_NO_EARLY_Z      0x8000   /* Disable early z */
48bf215546Sopenharmony_ci#define ETNA_DBG_CFLUSH_ALL      0x10000  /* Flush before every state update + draw call */
49bf215546Sopenharmony_ci#define ETNA_DBG_MSAA_2X         0x20000  /* Force 2X MSAA for screen */
50bf215546Sopenharmony_ci#define ETNA_DBG_MSAA_4X         0x40000  /* Force 4X MSAA for screen */
51bf215546Sopenharmony_ci#define ETNA_DBG_FINISH_ALL      0x80000  /* Finish on every flush */
52bf215546Sopenharmony_ci#define ETNA_DBG_FLUSH_ALL       0x100000 /* Flush after every rendered primitive */
53bf215546Sopenharmony_ci#define ETNA_DBG_ZERO            0x200000 /* Zero all resources after allocation */
54bf215546Sopenharmony_ci#define ETNA_DBG_DRAW_STALL      0x400000 /* Stall FE/PE after every draw op */
55bf215546Sopenharmony_ci#define ETNA_DBG_SHADERDB        0x800000 /* dump program compile information */
56bf215546Sopenharmony_ci#define ETNA_DBG_NO_SINGLEBUF    0x1000000 /* disable single buffer feature */
57bf215546Sopenharmony_ci#define ETNA_DBG_DEQP            0x2000000 /* Hacks to run dEQP GLES3 tests */
58bf215546Sopenharmony_ci#define ETNA_DBG_NOCACHE         0x4000000 /* Disable shader cache */
59bf215546Sopenharmony_ci#define ETNA_DBG_NO_LINEAR_PE    0x8000000 /* Disable linear PE */
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ciextern int etna_mesa_debug; /* set in etnaviv_screen.c from ETNA_MESA_DEBUG */
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ci#define DBG_ENABLED(flag) unlikely(etna_mesa_debug & (flag))
64bf215546Sopenharmony_ci
65bf215546Sopenharmony_ci#define DBG_F(flag, fmt, ...)                             \
66bf215546Sopenharmony_ci   do {                                                   \
67bf215546Sopenharmony_ci      if (etna_mesa_debug & (flag))                       \
68bf215546Sopenharmony_ci         mesa_logd("%s:%d: " fmt, __FUNCTION__, __LINE__, \
69bf215546Sopenharmony_ci                   ##__VA_ARGS__);                        \
70bf215546Sopenharmony_ci   } while (0)
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci#define DBG(fmt, ...)                                     \
73bf215546Sopenharmony_ci   do {                                                   \
74bf215546Sopenharmony_ci      if (etna_mesa_debug & ETNA_DBG_MSGS)                \
75bf215546Sopenharmony_ci         mesa_logd("%s:%d: " fmt, __FUNCTION__, __LINE__, \
76bf215546Sopenharmony_ci                   ##__VA_ARGS__);                        \
77bf215546Sopenharmony_ci   } while (0)
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci/* A serious bug, show this even in non-debug mode */
80bf215546Sopenharmony_ci#define BUG(fmt, ...)                                                  \
81bf215546Sopenharmony_ci   do {                                                                \
82bf215546Sopenharmony_ci      mesa_loge("%s:%d: " fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
83bf215546Sopenharmony_ci   } while (0)
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci#endif
86