Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/common/state.h
9905 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "default.h"
7
8
namespace embree
9
{
10
/* mutex to make printing to cout thread safe */
11
extern MutexSys g_printMutex;
12
struct RTCErrorMessage
13
{
14
RTCErrorMessage(RTCError error, std::string const& msg)
15
: error(error), msg(msg) {}
16
17
RTCError error;
18
std::string msg;
19
};
20
21
struct State : public RefCount
22
{
23
public:
24
/*! state construction */
25
State ();
26
27
/*! state destruction */
28
~State();
29
30
/*! verifies that state is correct */
31
void verify();
32
33
/*! parses state from a configuration file */
34
bool parseFile(const FileName& fileName);
35
36
/*! parses the state from a string */
37
void parseString(const char* cfg);
38
39
/*! parses the state from a stream */
40
void parse(Ref<TokenStream> cin);
41
42
/*! prints the state */
43
void print();
44
45
/*! checks if verbosity level is at least N */
46
bool verbosity(size_t N);
47
48
/*! checks if some particular ISA is enabled */
49
bool hasISA(const int isa);
50
51
/*! check whether selected ISA is supported by the HW */
52
bool checkISASupport();
53
54
public:
55
std::string tri_accel; //!< acceleration structure to use for triangles
56
std::string tri_builder; //!< builder to use for triangles
57
std::string tri_traverser; //!< traverser to use for triangles
58
59
public:
60
std::string tri_accel_mb; //!< acceleration structure to use for motion blur triangles
61
std::string tri_builder_mb; //!< builder to use for motion blur triangles
62
std::string tri_traverser_mb; //!< traverser to use for triangles
63
64
public:
65
std::string quad_accel; //!< acceleration structure to use for quads
66
std::string quad_builder; //!< builder to use for quads
67
std::string quad_traverser; //!< traverser to use for quads
68
69
public:
70
std::string quad_accel_mb; //!< acceleration structure to use for motion blur quads
71
std::string quad_builder_mb; //!< builder to use for motion blur quads
72
std::string quad_traverser_mb; //!< traverser to use for motion blur quads
73
74
public:
75
std::string line_accel; //!< acceleration structure to use for line segments
76
std::string line_builder; //!< builder to use for line segments
77
std::string line_traverser; //!< traverser to use for line segments
78
79
public:
80
std::string line_accel_mb; //!< acceleration structure to use for motion blur line segments
81
std::string line_builder_mb; //!< builder to use for motion blur line segments
82
std::string line_traverser_mb; //!< traverser to use for motion blur line segments
83
84
public:
85
std::string hair_accel; //!< hair acceleration structure to use
86
std::string hair_builder; //!< builder to use for hair
87
std::string hair_traverser; //!< traverser to use for hair
88
89
public:
90
std::string hair_accel_mb; //!< acceleration structure to use for motion blur hair
91
std::string hair_builder_mb; //!< builder to use for motion blur hair
92
std::string hair_traverser_mb; //!< traverser to use for motion blur hair
93
94
public:
95
std::string object_accel; //!< acceleration structure for user geometries
96
std::string object_builder; //!< builder for user geometries
97
int object_accel_min_leaf_size; //!< minimum leaf size for object acceleration structure
98
int object_accel_max_leaf_size; //!< maximum leaf size for object acceleration structure
99
100
public:
101
std::string object_accel_mb; //!< acceleration structure for user geometries
102
std::string object_builder_mb; //!< builder for user geometries
103
int object_accel_mb_min_leaf_size; //!< minimum leaf size for mblur object acceleration structure
104
int object_accel_mb_max_leaf_size; //!< maximum leaf size for mblur object acceleration structure
105
106
public:
107
std::string subdiv_accel; //!< acceleration structure to use for subdivision surfaces
108
std::string subdiv_accel_mb; //!< acceleration structure to use for subdivision surfaces
109
110
public:
111
std::string grid_accel; //!< acceleration structure to use for grids
112
std::string grid_builder; //!< builder for grids
113
std::string grid_accel_mb; //!< acceleration structure to use for motion blur grids
114
std::string grid_builder_mb; //!< builder for motion blur grids
115
116
public:
117
float max_spatial_split_replications; //!< maximally replications*N many primitives in accel for spatial splits
118
bool useSpatialPreSplits; //!< use spatial pre-splits instead of the full spatial split builder
119
size_t tessellation_cache_size; //!< size of the shared tessellation cache
120
size_t max_triangles_per_leaf;
121
122
public:
123
size_t instancing_open_min; //!< instancing opens tree to minimally that number of subtrees
124
size_t instancing_block_size; //!< instancing opens tree up to average block size of primitives
125
float instancing_open_factor; //!< instancing opens tree up to x times the number of instances
126
size_t instancing_open_max_depth; //!< maximum open depth for geometries
127
size_t instancing_open_max; //!< instancing opens tree to maximally that number of subtrees
128
129
public:
130
bool float_exceptions; //!< enable floating point exceptions
131
int quality_flags;
132
int scene_flags;
133
size_t verbose; //!< verbosity of output
134
size_t benchmark; //!< true
135
136
public:
137
size_t numThreads; //!< number of threads to use in builders
138
size_t numUserThreads; //!< number of user provided threads to use in builders
139
bool set_affinity; //!< sets affinity for worker threads
140
bool start_threads; //!< true when threads should be started at device creation time
141
int enabled_cpu_features; //!< CPU ISA features to use
142
int enabled_builder_cpu_features; //!< CPU ISA features to use for builders only
143
enum FREQUENCY_LEVEL {
144
FREQUENCY_SIMD128,
145
FREQUENCY_SIMD256,
146
FREQUENCY_SIMD512
147
} frequency_level; //!< frequency level the app wants to run on (default is SIMD256)
148
bool enable_selockmemoryprivilege; //!< configures the SeLockMemoryPrivilege under Windows to enable huge pages
149
bool hugepages; //!< true if huge pages should get used
150
bool hugepages_success; //!< status for enabling huge pages
151
152
public:
153
size_t alloc_main_block_size; //!< main allocation block size (shared between threads)
154
int alloc_num_main_slots; //!< number of such shared blocks to be used to allocate
155
size_t alloc_thread_block_size; //!< size of thread local allocator block size
156
int alloc_single_thread_alloc; //!< in single mode nodes and leaves use same thread local allocator
157
158
public:
159
160
/*! checks if we can use AVX */
161
bool canUseAVX() {
162
return hasISA(AVX) && frequency_level != FREQUENCY_SIMD128;
163
}
164
165
/*! checks if we can use AVX2 */
166
bool canUseAVX2() {
167
return hasISA(AVX2) && frequency_level != FREQUENCY_SIMD128;
168
}
169
170
struct ErrorHandler
171
{
172
public:
173
ErrorHandler();
174
~ErrorHandler();
175
RTCErrorMessage* error();
176
177
public:
178
tls_t thread_error;
179
std::vector<RTCErrorMessage*> thread_errors;
180
MutexSys errors_mutex;
181
};
182
ErrorHandler errorHandler;
183
static ErrorHandler g_errorHandler;
184
185
public:
186
void setErrorFunction(RTCErrorFunction fptr, void* uptr)
187
{
188
error_function = fptr;
189
error_function_userptr = uptr;
190
}
191
192
RTCErrorFunction error_function;
193
void* error_function_userptr;
194
195
public:
196
void setMemoryMonitorFunction(RTCMemoryMonitorFunction fptr, void* uptr)
197
{
198
memory_monitor_function = fptr;
199
memory_monitor_userptr = uptr;
200
}
201
202
RTCMemoryMonitorFunction memory_monitor_function;
203
void* memory_monitor_userptr;
204
};
205
}
206
207