rtcore_scene.isph 12 KB

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