Blender V5.0
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
62 /* Descriptor of HIP feature-set to be used. */
63 struct HIP {
64 HIP();
65
66 /* Reset flags to their defaults. */
67 void reset();
68
69 /* Whether adaptive feature based runtime compile is enabled or not. */
70 bool adaptive_compile = false;
71 };
72
73 /* Descriptor of OptiX feature-set to be used. */
74 struct OptiX {
75 OptiX();
76
77 /* Reset flags to their defaults. */
78 void reset();
79
80 /* Load OptiX module with debug capabilities. Will lower logging verbosity level, enable
81 * validations, and lower optimization level. */
82 bool use_debug = false;
83 };
84
85 /* Descriptor of Metal feature-set to be used. */
86 struct Metal {
87 Metal();
88
89 /* Reset flags to their defaults. */
90 void reset();
91
92 /* Whether adaptive feature based runtime compile is enabled or not. */
93 bool adaptive_compile = false;
94
95 /* Whether local atomic sorting is enabled or not. */
97
98 /* Whether nanovdb is enabled or not. */
99 bool use_nanovdb = true;
100
101 /* Whether async PSO creation is enabled or not. */
103
104 /* Whether to use per-component motion interpolation.
105 */
106 bool use_metalrt_pcmi = true;
107 };
108
109 /* Get instance of debug flags registry. */
110 static DebugFlags &get()
111 {
112 static DebugFlags instance;
113 return instance;
114 }
115
116 /* Reset flags to their defaults. */
117 void reset();
118
119 /* Requested CPU flags. */
121
122 /* Requested CUDA flags. */
124
125 /* Requested OptiX flags. */
127
128 /* Requested HIP flags. */
130
131 /* Requested Metal flags. */
133
134 private:
135 DebugFlags() = default;
136
137 public:
138 explicit DebugFlags(const DebugFlags & /*other*/) = delete;
139 void operator=(const DebugFlags & /*other*/) = delete;
140};
141
144
146{
147 return DebugFlags::get();
148}
149
static DebugFlags & get()
Definition debug.h:110
CPU cpu
Definition debug.h:120
void reset()
Definition debug.cpp:99
OptiX optix
Definition debug.h:126
CUDA cuda
Definition debug.h:123
HIP hip
Definition debug.h:129
DebugFlags(const DebugFlags &)=delete
void operator=(const DebugFlags &)=delete
Metal metal
Definition debug.h:132
DebugFlags & DebugFlagsRef
Definition debug.h:142
DebugFlags & DebugFlags()
Definition debug.h:145
const DebugFlags & DebugFlagsConstRef
Definition debug.h:143
#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 adaptive_compile
Definition debug.h:70
void reset()
Definition debug.cpp:59
bool use_async_pso_creation
Definition debug.h:102
bool use_metalrt_pcmi
Definition debug.h:106
bool adaptive_compile
Definition debug.h:93
bool use_nanovdb
Definition debug.h:99
bool use_local_atomic_sort
Definition debug.h:96