state.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "default.h"
  18. namespace embree
  19. {
  20. struct State
  21. {
  22. public:
  23. /*! state construction */
  24. State (bool singledevice);
  25. /*! state destruction */
  26. ~State();
  27. /*! verifies that state is correct */
  28. void verify();
  29. /*! parses state from a configuration file */
  30. bool parseFile(const FileName& fileName);
  31. /*! parses the state from a string */
  32. void parseString(const char* cfg);
  33. /*! parses the state from a stream */
  34. void parse(Ref<TokenStream> cin);
  35. /*! prints the state */
  36. void print();
  37. /*! checks if verbosity level is at least N */
  38. bool verbosity(size_t N);
  39. /*! checks if some particular ISA is enabled */
  40. bool hasISA(const int isa);
  41. public:
  42. std::string tri_accel; //!< acceleration structure to use for triangles
  43. std::string tri_builder; //!< builder to use for triangles
  44. std::string tri_traverser; //!< traverser to use for triangles
  45. public:
  46. std::string tri_accel_mb; //!< acceleration structure to use for motion blur triangles
  47. std::string tri_builder_mb; //!< builder to use for motion blur triangles
  48. std::string tri_traverser_mb; //!< traverser to use for triangles
  49. public:
  50. std::string quad_accel; //!< acceleration structure to use for quads
  51. std::string quad_builder; //!< builder to use for quads
  52. std::string quad_traverser; //!< traverser to use for quads
  53. public:
  54. std::string quad_accel_mb; //!< acceleration structure to use for motion blur quads
  55. std::string quad_builder_mb; //!< builder to use for motion blur quads
  56. std::string quad_traverser_mb; //!< traverser to use for motion blur quads
  57. public:
  58. std::string line_accel; //!< acceleration structure to use for line segments
  59. std::string line_builder; //!< builder to use for line segments
  60. std::string line_traverser; //!< traverser to use for line segments
  61. public:
  62. std::string line_accel_mb; //!< acceleration structure to use for motion blur line segments
  63. std::string line_builder_mb; //!< builder to use for motion blur line segments
  64. std::string line_traverser_mb; //!< traverser to use for motion blur line segments
  65. public:
  66. std::string hair_accel; //!< hair acceleration structure to use
  67. std::string hair_builder; //!< builder to use for hair
  68. std::string hair_traverser; //!< traverser to use for hair
  69. public:
  70. std::string hair_accel_mb; //!< acceleration structure to use for motion blur hair
  71. std::string hair_builder_mb; //!< builder to use for motion blur hair
  72. std::string hair_traverser_mb; //!< traverser to use for motion blur hair
  73. public:
  74. std::string object_accel; //!< acceleration structure for user geometries
  75. std::string object_builder; //!< builder for user geometries
  76. int object_accel_min_leaf_size; //!< minimal leaf size for object acceleration structure
  77. int object_accel_max_leaf_size; //!< maximal leaf size for object acceleration structure
  78. public:
  79. int object_accel_mb_min_leaf_size; //!< minimal leaf size for mblur object acceleration structure
  80. int object_accel_mb_max_leaf_size; //!< maximal leaf size for mblur object acceleration structure
  81. public:
  82. std::string subdiv_accel; //!< acceleration structure to use for subdivision surfaces
  83. std::string subdiv_accel_mb; //!< acceleration structure to use for subdivision surfaces
  84. public:
  85. float max_spatial_split_replications; //!< maximally replications*N many primitives in accel for spatial splits
  86. size_t tessellation_cache_size; //!< size of the shared tessellation cache
  87. public:
  88. size_t instancing_open_min; //!< instancing opens tree to minimally that number of subtrees
  89. size_t instancing_block_size; //!< instancing opens tree up to average block size of primitives
  90. float instancing_open_factor; //!< instancing opens tree up to x times the number of instances
  91. size_t instancing_open_max_depth; //!< maximal open depth for geometries
  92. size_t instancing_open_max; //!< instancing opens tree to maximally that number of subtrees
  93. public:
  94. bool ignore_config_files; //!< if true no more config files get parse
  95. bool float_exceptions; //!< enable floating point exceptions
  96. int scene_flags; //!< scene flags to use
  97. size_t verbose; //!< verbosity of output
  98. size_t benchmark; //!< true
  99. public:
  100. size_t numThreads; //!< number of threads to use in builders
  101. bool set_affinity; //!< sets affinity for worker threads
  102. bool start_threads; //!< true when threads should be started at device creation time
  103. int enabled_cpu_features; //!< CPU ISA features to use
  104. int enabled_builder_cpu_features; //!< CPU ISA features to use for builders only
  105. public:
  106. struct ErrorHandler
  107. {
  108. public:
  109. ErrorHandler();
  110. ~ErrorHandler();
  111. RTCError* error();
  112. public:
  113. tls_t thread_error;
  114. std::vector<RTCError*> thread_errors;
  115. MutexSys errors_mutex;
  116. };
  117. ErrorHandler errorHandler;
  118. static ErrorHandler g_errorHandler;
  119. public:
  120. void setErrorFunction(RTCErrorFunc fptr)
  121. {
  122. error_function = fptr;
  123. error_function2 = nullptr;
  124. error_function_userptr = nullptr;
  125. }
  126. void setErrorFunction(RTCErrorFunc2 fptr, void* uptr)
  127. {
  128. error_function = nullptr;
  129. error_function2 = fptr;
  130. error_function_userptr = uptr;
  131. }
  132. RTCErrorFunc error_function;
  133. RTCErrorFunc2 error_function2;
  134. void* error_function_userptr;
  135. public:
  136. void setMemoryMonitorFunction(RTCMemoryMonitorFunc fptr)
  137. {
  138. memory_monitor_function = fptr;
  139. memory_monitor_function2 = nullptr;
  140. memory_monitor_userptr = nullptr;
  141. }
  142. void setMemoryMonitorFunction(RTCMemoryMonitorFunc2 fptr, void* uptr)
  143. {
  144. memory_monitor_function = nullptr;
  145. memory_monitor_function2 = fptr;
  146. memory_monitor_userptr = uptr;
  147. }
  148. RTCMemoryMonitorFunc memory_monitor_function;
  149. RTCMemoryMonitorFunc2 memory_monitor_function2;
  150. void* memory_monitor_userptr;
  151. };
  152. }