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

source code of qtquick3d/src/3rdparty/embree/kernels/common/state.h