Blender V5.3
debug.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include <cassert>
8
9#include "bvh/params.h"
10
12
13/* Global storage for all sort of flags used to fine-tune behavior of particular
14 * areas for the development purposes, without officially exposing settings to
15 * the interface.
16 */
17class DebugFlags {
18 public:
19 /* Descriptor of CPU feature-set to be used. */
20 struct CPU {
21 CPU();
22
23 /* Reset flags to their defaults. */
24 void reset();
25
26 /* Flags describing which instructions sets are allowed for use. */
27 bool avx2 = true;
28 bool sse42 = true;
29
30 /* Check functions to see whether instructions up to the given one
31 * are allowed for use.
32 */
33 bool has_avx2()
34 {
35 return has_sse42() && avx2;
36 }
37 bool has_sse42()
38 {
39 return sse42;
40 }
41
42 /* Requested BVH layout.
43 *
44 * By default the fastest will be used. For debugging the BVH used by other
45 * CPUs and GPUs can be selected here instead.
46 */
48 };
49
50 /* Descriptor of CUDA feature-set to be used. */
51 struct CUDA {
52 CUDA();
53
54 /* Reset flags to their defaults. */
55 void reset();
56
57 /* Whether adaptive feature based runtime compile is enabled or not.
58 * Requires the CUDA Toolkit and only works on Linux at the moment. */
59 bool adaptive_compile = false;
60
61 /* Whether local atomic sorting is enabled or not. */
63 };
64
65 /* Descriptor of HIP feature-set to be used. */
66 struct HIP {
67 HIP();
68
69 /* Reset flags to their defaults. */
70 void reset();
71
72 /* Whether adaptive feature based runtime compile is enabled or not. */
73 bool adaptive_compile = false;
74 };
75
76 /* Descriptor of OptiX feature-set to be used. */
77 struct OptiX {
78 OptiX();
79
80 /* Reset flags to their defaults. */
81 void reset();
82
83 /* Load OptiX module with debug capabilities. Will lower logging verbosity level, enable
84 * validations, and lower optimization level. */
85 bool use_debug = false;
86 };
87
88 /* Descriptor of Metal feature-set to be used. */
89 struct Metal {
90 Metal();
91
92 /* Reset flags to their defaults. */
93 void reset();
94
95 /* Whether adaptive feature based runtime compile is enabled or not. */
96 bool adaptive_compile = false;
97
98 /* Whether local atomic sorting is enabled or not. */
100
101 /* Whether nanovdb is enabled or not. */
102 bool use_nanovdb = true;
103
104 /* Whether async PSO creation is enabled or not. */
106
107 /* Whether to use per-component motion interpolation. */
108 bool use_metalrt_pcmi = true;
109
110 /* Whether to use residency sets. */
112 };
113
114 /* Descriptor of Texture Cache feature-set to be used. */
116 TextureCache();
117
118 /* Reset flags to their defaults. */
119 void reset();
120
121 /* Enable texture cache eviction. */
122 bool use_eviction = true;
123
124 /* Preserve unused image cache tile memory in megabytes. */
126
127 /* Minimum tile size, loading multiple smaller file tiles at once if
128 * a tx files contains tiles smaller than this. */
130 };
131
132 /* Get instance of debug flags registry. */
133 static DebugFlags &get()
134 {
135 static DebugFlags instance;
136 return instance;
137 }
138
139 /* Reset flags to their defaults. */
140 void reset();
141
142 /* Requested CPU flags. */
144
145 /* Requested CUDA flags. */
147
148 /* Requested OptiX flags. */
150
151 /* Requested HIP flags. */
153
154 /* Requested Metal flags. */
156
157 /* Requested Texture Cache flags. */
159
160 private:
161 DebugFlags() = default;
162
163 public:
164 explicit DebugFlags(const DebugFlags & /*other*/) = delete;
165 void operator=(const DebugFlags & /*other*/) = delete;
166};
167
170
172{
173 return DebugFlags::get();
174}
175
void reset()
static DebugFlags & get()
Definition debug.h:133
CPU cpu
Definition debug.h:143
OptiX optix
Definition debug.h:149
CUDA cuda
Definition debug.h:146
HIP hip
Definition debug.h:152
DebugFlags(const DebugFlags &)=delete
TextureCache texture_cache
Definition debug.h:158
void operator=(const DebugFlags &)=delete
Metal metal
Definition debug.h:155
DebugFlags & DebugFlagsRef
Definition debug.h:168
const DebugFlags & DebugFlagsConstRef
Definition debug.h:169
#define CCL_NAMESPACE_END
@ BVH_LAYOUT_AUTO
KernelBVHLayout BVHLayout
Definition params.h:22
bool has_avx2()
Definition debug.h:33
void reset()
Definition debug.cpp:18
BVHLayout bvh_layout
Definition debug.h:47
bool has_sse42()
Definition debug.h:37
bool adaptive_compile
Definition debug.h:59
bool use_local_atomic_sort
Definition debug.h:62
bool adaptive_compile
Definition debug.h:73
void reset()
Definition debug.cpp:63
bool use_async_pso_creation
Definition debug.h:105
bool use_metalrt_pcmi
Definition debug.h:108
bool adaptive_compile
Definition debug.h:96
bool use_residency_sets_if_available
Definition debug.h:111
bool use_local_atomic_sort
Definition debug.h:99