Blender V4.3
mtl_debug.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BKE_global.hh"
12#include "BLI_system.h"
13#include "CLG_log.h"
14
16/* Maximum nested debug group depth. Groups beyond this will still have the pass name pulled into
17 * the RenderCommandEncoder, but will not display in the trace.
18 * Use -1 for unlimited. */
19#define METAL_DEBUG_CAPTURE_MAX_NESTED_GROUPS -1
20
21/* Whether empty debug groups should be hidden. */
22#define METAL_DEBUG_CAPTURE_HIDE_EMPTY 0
23
24namespace blender {
25namespace gpu {
26namespace debug {
27
28extern CLG_LogRef LOG;
29
30/* Initialize debugging. */
31void mtl_debug_init();
32
33/* Using Macro's instead of variadic template due to non-string-literal
34 * warning for CLG_logf when indirectly passing format string. */
35#define EXPAND_ARGS(...) , ##__VA_ARGS__
36#define MTL_LOG_ERROR(info, ...) \
37 { \
38 if (G.debug & G_DEBUG_GPU) { \
39 CLOG_ERROR(&debug::LOG, info EXPAND_ARGS(__VA_ARGS__)); \
40 BLI_system_backtrace(stderr); \
41 } \
42 }
43
44#define MTL_LOG_WARNING(info, ...) \
45 { \
46 if (G.debug & G_DEBUG_GPU) { \
47 CLOG_WARN(&debug::LOG, info EXPAND_ARGS(__VA_ARGS__)); \
48 } \
49 }
50
51#define MTL_LOG_INFO(info, ...) \
52 { \
53 if (G.debug & G_DEBUG_GPU) { \
54 CLOG_INFO(&debug::LOG, 2, info EXPAND_ARGS(__VA_ARGS__)); \
55 } \
56 }
57
58} // namespace debug
59} // namespace gpu
60} // namespace blender