Blender  V3.3
debug.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __UTIL_DEBUG_H__
5 #define __UTIL_DEBUG_H__
6 
7 #include <cassert>
8 #include <iostream>
9 
10 #include "bvh/params.h"
11 
13 
14 /* Global storage for all sort of flags used to fine-tune behavior of particular
15  * areas for the development purposes, without officially exposing settings to
16  * the interface.
17  */
18 class DebugFlags {
19  public:
20  /* Use static BVH in viewport, to match final render exactly. */
22 
24 
25  /* Descriptor of CPU feature-set to be used. */
26  struct CPU {
27  CPU();
28 
29  /* Reset flags to their defaults. */
30  void reset();
31 
32  /* Flags describing which instructions sets are allowed for use. */
33  bool avx2;
34  bool avx;
35  bool sse41;
36  bool sse3;
37  bool sse2;
38 
39  /* Check functions to see whether instructions up to the given one
40  * are allowed for use.
41  */
42  bool has_avx2()
43  {
44  return has_avx() && avx2;
45  }
46  bool has_avx()
47  {
48  return has_sse41() && avx;
49  }
50  bool has_sse41()
51  {
52  return has_sse3() && sse41;
53  }
54  bool has_sse3()
55  {
56  return has_sse2() && sse3;
57  }
58  bool has_sse2()
59  {
60  return sse2;
61  }
62 
63  /* Requested BVH layout.
64  *
65  * By default the fastest will be used. For debugging the BVH used by other
66  * CPUs and GPUs can be selected here instead.
67  */
69  };
70 
71  /* Descriptor of CUDA feature-set to be used. */
72  struct CUDA {
73  CUDA();
74 
75  /* Reset flags to their defaults. */
76  void reset();
77 
78  /* Whether adaptive feature based runtime compile is enabled or not.
79  * Requires the CUDA Toolkit and only works on Linux at the moment. */
81  };
82 
83  /* Descriptor of HIP feature-set to be used. */
84  struct HIP {
85  HIP();
86 
87  /* Reset flags to their defaults. */
88  void reset();
89 
90  /* Whether adaptive feature based runtime compile is enabled or not. */
92  };
93 
94  /* Descriptor of OptiX feature-set to be used. */
95  struct OptiX {
96  OptiX();
97 
98  /* Reset flags to their defaults. */
99  void reset();
100 
101  /* Load OptiX module with debug capabilities. Will lower logging verbosity level, enable
102  * validations, and lower optimization level. */
103  bool use_debug;
104  };
105 
106  /* Descriptor of Metal feature-set to be used. */
107  struct Metal {
108  Metal();
109 
110  /* Reset flags to their defaults. */
111  void reset();
112 
113  /* Whether adaptive feature based runtime compile is enabled or not. */
115  };
116 
117  /* Get instance of debug flags registry. */
118  static DebugFlags &get()
119  {
120  static DebugFlags instance;
121  return instance;
122  }
123 
124  /* Reset flags to their defaults. */
125  void reset();
126 
127  /* Requested CPU flags. */
129 
130  /* Requested CUDA flags. */
132 
133  /* Requested OptiX flags. */
135 
136  /* Requested HIP flags. */
138 
139  /* Requested Metal flags. */
141 
142  private:
143  DebugFlags();
144 
145 #if (__cplusplus > 199711L)
146  public:
147  explicit DebugFlags(DebugFlags const & /*other*/) = delete;
148  void operator=(DebugFlags const & /*other*/) = delete;
149 #else
150  private:
151  explicit DebugFlags(DebugFlags const & /*other*/);
152  void operator=(DebugFlags const & /*other*/);
153 #endif
154 };
155 
158 
160 {
161  return DebugFlags::get();
162 }
163 
165 
166 #endif /* __UTIL_DEBUG_H__ */
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
CPU cpu
Definition: debug.h:128
void reset()
Definition: debug.cpp:92
OptiX optix
Definition: debug.h:134
CUDA cuda
Definition: debug.h:131
static DebugFlags & get()
Definition: debug.h:118
HIP hip
Definition: debug.h:137
bool running_inside_blender
Definition: debug.h:23
Metal metal
Definition: debug.h:140
bool viewport_static_bvh
Definition: debug.h:21
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
const DebugFlags & DebugFlagsConstRef
Definition: debug.h:157
DebugFlags & DebugFlagsRef
Definition: debug.h:156
DebugFlags & DebugFlags()
Definition: debug.h:159
CCL_NAMESPACE_BEGIN typedef KernelBVHLayout BVHLayout
Definition: params.h:19
bool avx
Definition: debug.h:34
bool sse2
Definition: debug.h:37
bool has_avx2()
Definition: debug.h:42
bool avx2
Definition: debug.h:33
bool has_sse41()
Definition: debug.h:50
bool sse3
Definition: debug.h:36
void reset()
Definition: debug.cpp:21
bool has_sse2()
Definition: debug.h:58
bool has_sse3()
Definition: debug.h:54
bool has_avx()
Definition: debug.h:46
BVHLayout bvh_layout
Definition: debug.h:68
bool sse41
Definition: debug.h:35
bool adaptive_compile
Definition: debug.h:80
void reset()
Definition: debug.cpp:59
bool adaptive_compile
Definition: debug.h:91
void reset()
Definition: debug.cpp:65
void reset()
Definition: debug.cpp:71
bool adaptive_compile
Definition: debug.h:114
bool use_debug
Definition: debug.h:103
void reset()
Definition: debug.cpp:82