rtcore_scene.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. #ifndef __RTCORE_SCENE_H__
  17. #define __RTCORE_SCENE_H__
  18. /*! \ingroup embree_kernel_api */
  19. /*! \{ */
  20. /*! forward declarations for ray structures */
  21. struct RTCRay;
  22. struct RTCRay4;
  23. struct RTCRay8;
  24. struct RTCRay16;
  25. struct RTCRayNp;
  26. /*! scene flags */
  27. enum RTCSceneFlags
  28. {
  29. /* dynamic type flags */
  30. RTC_SCENE_STATIC = (0 << 0), //!< specifies static scene
  31. RTC_SCENE_DYNAMIC = (1 << 0), //!< specifies dynamic scene
  32. /* acceleration structure flags */
  33. RTC_SCENE_COMPACT = (1 << 8), //!< use memory conservative data structures
  34. RTC_SCENE_COHERENT = (1 << 9), //!< optimize data structures for coherent rays
  35. RTC_SCENE_INCOHERENT = (1 << 10), //!< optimize data structures for in-coherent rays (enabled by default)
  36. RTC_SCENE_HIGH_QUALITY = (1 << 11), //!< create higher quality data structures
  37. /* traversal algorithm flags */
  38. RTC_SCENE_ROBUST = (1 << 16) //!< use more robust traversal algorithms
  39. };
  40. /*! enabled algorithm flags */
  41. enum RTCAlgorithmFlags
  42. {
  43. RTC_INTERSECT1 = (1 << 0), //!< enables the rtcIntersect1 and rtcOccluded1 functions for this scene
  44. RTC_INTERSECT4 = (1 << 1), //!< enables the rtcIntersect4 and rtcOccluded4 functions for this scene
  45. RTC_INTERSECT8 = (1 << 2), //!< enables the rtcIntersect8 and rtcOccluded8 functions for this scene
  46. RTC_INTERSECT16 = (1 << 3), //!< enables the rtcIntersect16 and rtcOccluded16 functions for this scene
  47. RTC_INTERPOLATE = (1 << 4), //!< enables the rtcInterpolate function for this scene
  48. RTC_INTERSECT_STREAM = (1 << 5), //!< enables the rtcIntersectN and rtcOccludedN functions for this scene
  49. };
  50. /*! intersection flags */
  51. enum RTCIntersectFlags
  52. {
  53. RTC_INTERSECT_COHERENT = 0, //!< optimize for coherent rays
  54. RTC_INTERSECT_INCOHERENT = 1 //!< optimize for incoherent rays
  55. };
  56. /*! intersection context passed to intersect/occluded calls */
  57. struct RTCIntersectContext
  58. {
  59. RTCIntersectFlags flags; //!< intersection flags
  60. void* userRayExt; //!< can be used to pass extended ray data to callbacks
  61. };
  62. /*! \brief Defines an opaque scene type */
  63. typedef struct __RTCScene {}* RTCScene;
  64. /*! Creates a new scene.
  65. WARNING: This function is deprecated, use rtcDeviceNewScene instead.
  66. */
  67. RTCORE_API RTCORE_DEPRECATED RTCScene rtcNewScene (RTCSceneFlags flags, RTCAlgorithmFlags aflags);
  68. /*! Creates a new scene. */
  69. RTCORE_API RTCScene rtcDeviceNewScene (RTCDevice device, RTCSceneFlags flags, RTCAlgorithmFlags aflags);
  70. /*! \brief Type of progress callback function. */
  71. typedef bool (*RTCProgressMonitorFunc)(void* ptr, const double n);
  72. RTCORE_DEPRECATED typedef RTCProgressMonitorFunc RTC_PROGRESS_MONITOR_FUNCTION;
  73. /*! \brief Sets the progress callback function which is called during hierarchy build of this scene. */
  74. RTCORE_API void rtcSetProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunc func, void* ptr);
  75. /*! Commits the geometry of the scene. After initializing or modifying
  76. * geometries, commit has to get called before tracing
  77. * rays. */
  78. RTCORE_API void rtcCommit (RTCScene scene);
  79. /*! Commits the geometry of the scene in join mode. When Embree is
  80. * using TBB (default), threads that call `rtcCommitJoin` will
  81. * participate in the hierarchy build procedure. When Embree is using
  82. * the internal tasking system, exclusively threads that call
  83. * `rtcCommitJoin` will execute the build procedure. Do not
  84. * mix `rtcCommitJoin` with other commit calls. */
  85. RTCORE_API void rtcCommitJoin (RTCScene scene);
  86. /*! Commits the geometry of the scene. The calling threads will be
  87. * used internally as a worker threads on some implementations. The
  88. * function will wait until 'numThreads' threads have called this
  89. * function and all threads return from the function after the scene
  90. * commit is finished. The application threads will not be used as
  91. * worker threads when the TBB tasking system is enabled (which is
  92. * the default). On CPUs, we recommend also using TBB inside your
  93. * application to share threads. We recommend using the
  94. * rtcCommitThread feature to share threads on the Xeon Phi
  95. * coprocessor. */
  96. RTCORE_API void rtcCommitThread(RTCScene scene, unsigned int threadID, unsigned int numThreads);
  97. /*! Returns AABB of the scene. rtcCommit has to get called
  98. * previously to this function. */
  99. RTCORE_API void rtcGetBounds(RTCScene scene, RTCBounds& bounds_o);
  100. /*! Returns linear AABBs of the scene. The result bounds_o gets filled
  101. * with AABBs for time 0 and time 1. rtcCommit has to get called
  102. * previously to this function. */
  103. RTCORE_API void rtcGetLinearBounds(RTCScene scene, RTCBounds* bounds_o);
  104. /*! Intersects a single ray with the scene. The ray has to be aligned
  105. * to 16 bytes. This function can only be called for scenes with the
  106. * RTC_INTERSECT1 flag set. */
  107. RTCORE_API void rtcIntersect (RTCScene scene, RTCRay& ray);
  108. /*! Intersects a single ray with the scene. The ray has to be aligned
  109. * to 16 bytes. This function can only be called for scenes with the
  110. * RTC_INTERSECT1 flag set. */
  111. RTCORE_API void rtcIntersect1Ex (RTCScene scene, const RTCIntersectContext* context, RTCRay& ray);
  112. /*! Intersects a packet of 4 rays with the scene. The valid mask and
  113. * ray have both to be aligned to 16 bytes. This function can only be
  114. * called for scenes with the RTC_INTERSECT4 flag set. */
  115. RTCORE_API void rtcIntersect4 (const void* valid, RTCScene scene, RTCRay4& ray);
  116. /*! Intersects a packet of 4 rays with the scene. The valid mask and
  117. * ray have both to be aligned to 16 bytes. This function can only be
  118. * called for scenes with the RTC_INTERSECT4 flag set. */
  119. RTCORE_API void rtcIntersect4Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay4& ray);
  120. /*! Intersects a packet of 8 rays with the scene. The valid mask and
  121. * ray have both to be aligned to 32 bytes. This function can only be
  122. * called for scenes with the RTC_INTERSECT8 flag set. For performance
  123. * reasons, the rtcIntersect8 function should only get called if the
  124. * CPU supports AVX. */
  125. RTCORE_API void rtcIntersect8 (const void* valid, RTCScene scene, RTCRay8& ray);
  126. /*! Intersects a packet of 8 rays with the scene. The valid mask and
  127. * ray have both to be aligned to 32 bytes. This function can only be
  128. * called for scenes with the RTC_INTERSECT8 flag set. For performance
  129. * reasons, the rtcIntersect8 function should only get called if the
  130. * CPU supports AVX. */
  131. RTCORE_API void rtcIntersect8Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay8& ray);
  132. /*! Intersects a packet of 16 rays with the scene. The valid mask and
  133. * ray have both to be aligned to 64 bytes. This function can only be
  134. * called for scenes with the RTC_INTERSECT16 flag set. For
  135. * performance reasons, the rtcIntersect16 function should only get
  136. * called if the CPU supports the 16-wide SIMD instructions. */
  137. RTCORE_API void rtcIntersect16 (const void* valid, RTCScene scene, RTCRay16& ray);
  138. /*! Intersects a packet of 16 rays with the scene. The valid mask and
  139. * ray have both to be aligned to 64 bytes. This function can only be
  140. * called for scenes with the RTC_INTERSECT16 flag set. For
  141. * performance reasons, the rtcIntersect16 function should only get
  142. * called if the CPU supports the 16-wide SIMD instructions. */
  143. RTCORE_API void rtcIntersect16Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay16& ray);
  144. /*! Intersects a stream of M rays with the scene. This function can
  145. * only be called for scenes with the RTC_INTERSECT_STREAM flag set. The
  146. * stride specifies the offset between rays in bytes. */
  147. RTCORE_API void rtcIntersect1M (RTCScene scene, const RTCIntersectContext* context, RTCRay* rays, const size_t M, const size_t stride);
  148. /*! Intersects a stream of pointers to M rays with the scene. This function can
  149. * only be called for scenes with the RTC_INTERSECT_STREAM flag set. */
  150. RTCORE_API void rtcIntersect1Mp (RTCScene scene, const RTCIntersectContext* context, RTCRay** rays, const size_t M);
  151. /*! Intersects a stream of M ray packets of size N in SOA format with the
  152. * scene. This function can only be called for scenes with the
  153. * RTC_INTERSECT_STREAM flag set. The stride specifies the offset between
  154. * ray packets in bytes. */
  155. RTCORE_API void rtcIntersectNM (RTCScene scene, const RTCIntersectContext* context, struct RTCRayN* rays, const size_t N, const size_t M, const size_t stride);
  156. /*! Intersects a stream of M ray packets of size N in SOA format with
  157. * the scene. This function can only be called for scenes with the
  158. * RTC_INTERSECT_STREAM flag set. The stride specifies the offset between
  159. * ray packets in bytes. In contrast to the rtcIntersectNM function
  160. * this function accepts a separate data pointer for each component
  161. * of the ray packet. */
  162. RTCORE_API void rtcIntersectNp (RTCScene scene, const RTCIntersectContext* context, const RTCRayNp& rays, const size_t N);
  163. /*! Tests if a single ray is occluded by the scene. The ray has to be
  164. * aligned to 16 bytes. This function can only be called for scenes
  165. * with the RTC_INTERSECT1 flag set. */
  166. RTCORE_API void rtcOccluded (RTCScene scene, RTCRay& ray);
  167. /*! Tests if a single ray is occluded by the scene. The ray has to be
  168. * aligned to 16 bytes. This function can only be called for scenes
  169. * with the RTC_INTERSECT1 flag set. */
  170. RTCORE_API void rtcOccluded1Ex (RTCScene scene, const RTCIntersectContext* context, RTCRay& ray);
  171. /*! Tests if a packet of 4 rays is occluded by the scene. This
  172. * function can only be called for scenes with the RTC_INTERSECT4
  173. * flag set. The valid mask and ray have both to be aligned to 16
  174. * bytes. */
  175. RTCORE_API void rtcOccluded4 (const void* valid, RTCScene scene, RTCRay4& ray);
  176. /*! Tests if a packet of 4 rays is occluded by the scene. This
  177. * function can only be called for scenes with the RTC_INTERSECT4
  178. * flag set. The valid mask and ray have both to be aligned to 16
  179. * bytes. */
  180. RTCORE_API void rtcOccluded4Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay4& ray);
  181. /*! Tests if a packet of 8 rays is occluded by the scene. The valid
  182. * mask and ray have both to be aligned to 32 bytes. This function
  183. * can only be called for scenes with the RTC_INTERSECT8 flag
  184. * set. For performance reasons, the rtcOccluded8 function should
  185. * only get called if the CPU supports AVX. */
  186. RTCORE_API void rtcOccluded8 (const void* valid, RTCScene scene, RTCRay8& ray);
  187. /*! Tests if a packet of 8 rays is occluded by the scene. The valid
  188. * mask and ray have both to be aligned to 32 bytes. This function
  189. * can only be called for scenes with the RTC_INTERSECT8 flag
  190. * set. For performance reasons, the rtcOccluded8 function should
  191. * only get called if the CPU supports AVX. */
  192. RTCORE_API void rtcOccluded8Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay8& ray);
  193. /*! Tests if a packet of 16 rays is occluded by the scene. The valid
  194. * mask and ray have both to be aligned to 64 bytes. This function
  195. * can only be called for scenes with the RTC_INTERSECT16 flag
  196. * set. For performance reasons, the rtcOccluded16 function should
  197. * only get called if the CPU supports the 16-wide SIMD
  198. * instructions. */
  199. RTCORE_API void rtcOccluded16 (const void* valid, RTCScene scene, RTCRay16& ray);
  200. /*! Tests if a packet of 16 rays is occluded by the scene. The valid
  201. * mask and ray have both to be aligned to 64 bytes. This function
  202. * can only be called for scenes with the RTC_INTERSECT16 flag
  203. * set. For performance reasons, the rtcOccluded16 function should
  204. * only get called if the CPU supports the 16-wide SIMD
  205. * instructions. */
  206. RTCORE_API void rtcOccluded16Ex (const void* valid, RTCScene scene, const RTCIntersectContext* context, RTCRay16& ray);
  207. /*! Tests if a stream of M rays is occluded by the scene. This
  208. * function can only be called for scenes with the RTC_INTERSECT_STREAM
  209. * flag set. The stride specifies the offset between rays in bytes.*/
  210. RTCORE_API void rtcOccluded1M (RTCScene scene, const RTCIntersectContext* context, RTCRay* rays, const size_t M, const size_t stride);
  211. /*! Tests if a stream of pointers to M rays is occluded by the scene. This
  212. * function can only be called for scenes with the RTC_INTERSECT_STREAM
  213. * flag set. */
  214. RTCORE_API void rtcOccluded1Mp (RTCScene scene, const RTCIntersectContext* context, RTCRay** rays, const size_t M);
  215. /*! Tests if a stream of M ray packets of size N in SOA format is occluded by
  216. * the scene. This function can only be called for scenes with the
  217. * RTC_INTERSECT_STREAM flag set. The stride specifies the offset between
  218. * rays in bytes.*/
  219. RTCORE_API void rtcOccludedNM (RTCScene scene, const RTCIntersectContext* context, struct RTCRayN* rays, const size_t N, const size_t M, const size_t stride);
  220. /*! Tests if a stream of M ray packets of size N in SOA format is
  221. * occluded by the scene. This function can only be called for scenes
  222. * with the RTC_INTERSECT_STREAM flag set. The stride specifies the offset
  223. * between rays in bytes. In contrast to the rtcOccludedNM function
  224. * this function accepts a separate data pointer for each component
  225. * of the ray packet. */
  226. RTCORE_API void rtcOccludedNp (RTCScene scene, const RTCIntersectContext* context, const RTCRayNp& rays, const size_t N);
  227. /*! Deletes the scene. All contained geometry get also destroyed. */
  228. RTCORE_API void rtcDeleteScene (RTCScene scene);
  229. /*! @} */
  230. #endif