rtcore.isph 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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_ISPH__
  17. #define __RTCORE_ISPH__
  18. #if !defined(RTCORE_API)
  19. #define RTCORE_API extern "C" unmasked
  20. #endif
  21. #ifdef _WIN32
  22. # define RTCORE_ALIGN(...) // FIXME: need to specify alignment
  23. #else
  24. # define RTCORE_ALIGN(...) // FIXME: need to specify alignment
  25. #endif
  26. #if !defined(RTCORE_DEPRECATED)
  27. #define RTCORE_DEPRECATED // FIXME: deprecation not supported by ISPC
  28. #endif
  29. /*! Embree API version */
  30. #define RTCORE_VERSION_MAJOR @EMBREE_VERSION_MAJOR@
  31. #define RTCORE_VERSION_MINOR @EMBREE_VERSION_MINOR@
  32. #define RTCORE_VERSION_PATCH @EMBREE_VERSION_PATCH@
  33. #define RTCORE_VERSION @EMBREE_VERSION_NUMBER@
  34. /*! \file rtcore.isph Defines the Embree Ray Tracing Kernel API for ISPC.
  35. This file defines the Embree ray tracing kernel API for C and
  36. C++. The user is supposed to include this file, and alternatively
  37. the rtcore_ray.isph file, but none of the other .isph files in this
  38. folder. */
  39. /*! \{ */
  40. /*! Axis aligned bounding box representation */
  41. RTCORE_ALIGN(16) struct RTCBounds
  42. {
  43. float lower_x, lower_y, lower_z, align0;
  44. float upper_x, upper_y, upper_z, align1;
  45. };
  46. /*! \brief Defines an opaque device type */
  47. typedef uniform struct __RTCDevice {}* uniform RTCDevice;
  48. /*! \brief Creates a new Embree device.
  49. Creates a new Embree device to be used by the application. An
  50. application typically creates only a single Embree device, but it is
  51. valid to use multiple devices inside an application. A configuration
  52. string can be passed at construction time, that allows to configure
  53. implementation specific parameters. If this string is NULL, a
  54. default configuration is used. The following configuration flags are
  55. supported by the Embree implementation of the API:
  56. verbose = num, // sets verbosity level (default is 0)
  57. If Embree is started on an unsupported CPU, rtcNewDevice will fail and
  58. set the RTC_UNSUPPORTED_CPU error code.
  59. */
  60. RTCDevice rtcNewDevice(const uniform int8* uniform cfg = NULL);
  61. /*! \brief Deletes an Embree device.
  62. Deletes the Embree device again. After deletion, all scene handles
  63. are invalid. */
  64. void rtcDeleteDevice(RTCDevice device);
  65. /*! \brief Initializes the Embree ray tracing core
  66. WARNING: This function is deprecated, use rtcNewDevice instead.
  67. Initializes the ray tracing core and passes some configuration
  68. string. The configuration string allows to configure implementation
  69. specific parameters. If this string is NULL, a default configuration
  70. is used. The following configuration flags are supported by the
  71. Embree implementation of the API:
  72. verbose = num, // sets verbosity level (default is 0)
  73. If Embree is started on an unsupported CPU, rtcInit will fail and
  74. set the RTC_UNSUPPORTED_CPU error code.
  75. */
  76. RTCORE_DEPRECATED void rtcInit(const uniform int8* uniform cfg = NULL);
  77. /*! \brief Shuts down Embree.
  78. WARNING: This function is deprecated, use rtcDeleteDevice instead.
  79. Shuts down the ray tracing core. After shutdown, all scene handles
  80. are invalid, and invoking any API call except rtcInit is not
  81. allowed. The application should invoke this call before
  82. terminating. It is safe to call rtcInit again after an rtcExit
  83. call. */
  84. RTCORE_DEPRECATED void rtcExit();
  85. /*! \brief Parameters that can get configured using the rtcSetParameter functions. */
  86. enum RTCParameter {
  87. RTC_SOFTWARE_CACHE_SIZE = 0, /*! Configures the software cache size (used
  88. to cache subdivision surfaces for
  89. instance). The size is specified as an
  90. integer number of bytes. The software
  91. cache cannot be configured during
  92. rendering. (write only) */
  93. RTC_CONFIG_INTERSECT1 = 1, //!< checks if rtcIntersect1 is supported (read only)
  94. RTC_CONFIG_INTERSECT4 = 2, //!< checks if rtcIntersect4 is supported (read only)
  95. RTC_CONFIG_INTERSECT8 = 3, //!< checks if rtcIntersect8 is supported (read only)
  96. RTC_CONFIG_INTERSECT16 = 4, //!< checks if rtcIntersect16 is supported (read only)
  97. RTC_CONFIG_INTERSECT_STREAM = 5, //!< checks if rtcIntersect1M, rtcIntersectVM, rtcIntersectNM and rtcIntersectNp are supported (read only)
  98. RTC_CONFIG_RAY_MASK = 6, //!< checks if ray masks are supported (read only)
  99. RTC_CONFIG_BACKFACE_CULLING = 7, //!< checks if backface culling is supported (read only)
  100. RTC_CONFIG_INTERSECTION_FILTER = 8, //!< checks if intersection filters are enabled (read only)
  101. RTC_CONFIG_INTERSECTION_FILTER_RESTORE = 9, //!< checks if intersection filters restores previous hit (read only)
  102. RTC_CONFIG_IGNORE_INVALID_RAYS = 11, //!< checks if invalid rays are ignored (read only)
  103. RTC_CONFIG_TASKING_SYSTEM = 12, //!< return used tasking system (0 = INTERNAL, 1 = TBB) (read only)
  104. RTC_CONFIG_VERSION_MAJOR = 13, //!< returns Embree major version (read only)
  105. RTC_CONFIG_VERSION_MINOR = 14, //!< returns Embree minor version (read only)
  106. RTC_CONFIG_VERSION_PATCH = 15, //!< returns Embree patch version (read only)
  107. RTC_CONFIG_VERSION = 16, //!< returns Embree version as integer (e.g. Embree v2.8.2 -> 20802) (read only)
  108. RTC_CONFIG_TRIANGLE_GEOMETRY = 17, //!< checks if triangle geometries are supported
  109. RTC_CONFIG_QUAD_GEOMETRY = 18, //!< checks if quad geometries are supported
  110. RTC_CONFIG_LINE_GEOMETRY = 19, //!< checks if line geometries are supported
  111. RTC_CONFIG_HAIR_GEOMETRY = 20, //!< checks if hair geometries are supported
  112. RTC_CONFIG_SUBDIV_GEOMETRY = 21, //!< checks if subdiv geometries are supported
  113. RTC_CONFIG_USER_GEOMETRY = 22, //!< checks if user geometries are supported
  114. RTC_CONFIG_COMMIT_JOIN = 23, //!< checks if rtcCommitJoin can be used to join build operation (not supported when compiled with some older TBB versions)
  115. RTC_CONFIG_COMMIT_THREAD = 24, //!< checks if rtcCommitThread is available (not supported when compiled with some older TBB versions)
  116. };
  117. /*! \brief Configures some parameters.
  118. WARNING: This function is deprecated, use rtcDeviceSetParameter1i instead.
  119. */
  120. RTCORE_DEPRECATED void rtcSetParameter1i(const uniform RTCParameter parm, uniform size_t val); // FIXME: should be ssize_t
  121. /*! \brief Reads some parameters.
  122. WARNING: This function is deprecated, use rtcDeviceGetParameter1i instead.
  123. */
  124. uniform size_t rtcGetParameter1i(const uniform RTCParameter parm); // FIXME: should return ssize_t
  125. /*! \brief Configures some device parameters.*/
  126. void rtcDeviceSetParameter1i(RTCDevice device, const uniform RTCParameter parm, uniform size_t val); // FIXME: should be ssize_t
  127. /*! \brief Reads some device parameters. */
  128. uniform size_t rtcDeviceGetParameter1i(RTCDevice device, const uniform RTCParameter parm); // FIXME: should return ssize_t
  129. /*! \brief Error codes returned by the rtcGetError function. */
  130. enum RTCError {
  131. RTC_NO_ERROR = 0, //!< No error has been recorded.
  132. RTC_UNKNOWN_ERROR = 1, //!< An unknown error has occured.
  133. RTC_INVALID_ARGUMENT = 2, //!< An invalid argument is specified
  134. RTC_INVALID_OPERATION = 3, //!< The operation is not allowed for the specified object.
  135. RTC_OUT_OF_MEMORY = 4, //!< There is not enough memory left to execute the command.
  136. RTC_UNSUPPORTED_CPU = 5, //!< The CPU is not supported as it does not support SSE2.
  137. RTC_CANCELLED = 6 //!< The user has cancelled the operation through the RTCProgressMonitorFunc callback
  138. };
  139. /*! \brief Returns the value of the per-thread error flag.
  140. WARNING: This function is deprecated, use rtcDeviceGetError instead.
  141. If an error occurs this flag is set to an error code if it stores no
  142. previous error. The rtcGetError function reads and returns the
  143. currently stored error and clears the error flag again. */
  144. RTCORE_DEPRECATED uniform RTCError rtcGetError();
  145. /*! \brief Returns the value of the per-thread error flag.
  146. If an error occurs this flag is set to an error code if it stores no
  147. previous error. The rtcGetError function reads and returns the
  148. currently stored error and clears the error flag again. */
  149. uniform RTCError rtcDeviceGetError(RTCDevice device);
  150. /*! \brief Type of error callback function.
  151. WARNING: This callback function is deprecated, use RTCErrorFunc2 instead.
  152. */
  153. RTCORE_DEPRECATED typedef unmasked void (*uniform RTCErrorFunc)(const uniform RTCError code, const uniform int8* uniform str);
  154. RTCORE_DEPRECATED typedef RTCErrorFunc RTC_ERROR_FUNCTION;
  155. /*! \brief Type of error callback function. */
  156. typedef unmasked void (*uniform RTCErrorFunc2)(void* uniform userPtr, const uniform RTCError code, const uniform int8* uniform str);
  157. /*! \brief Sets a callback function that is called whenever an error occurs.
  158. WARNING: This function is deprecated, use rtcDeviceSetErrorFunction2 instead.
  159. */
  160. RTCORE_DEPRECATED void rtcSetErrorFunction(uniform RTCErrorFunc func);
  161. /*! \brief Sets a callback function that is called whenever an error occurs.
  162. WARNING: This function is deprecated, use rtcDeviceSetErrorFunction2 instead.
  163. */
  164. RTCORE_DEPRECATED void rtcDeviceSetErrorFunction(RTCDevice device, uniform RTCErrorFunc func);
  165. /*! \brief Sets a callback function that is called whenever an error occurs. */
  166. void rtcDeviceSetErrorFunction2(RTCDevice device, uniform RTCErrorFunc2 func, void* uniform userPtr);
  167. /*! \brief Type of memory consumption callback function.
  168. WARNING: This callback function is deprecated, use RTCMemoryMonitorFunc2 instead.
  169. */
  170. RTCORE_DEPRECATED typedef uniform bool (*uniform RTCMemoryMonitorFunc)(const uniform size_t bytes, const uniform bool post); // FIXME: should be ssize_t
  171. RTCORE_DEPRECATED typedef RTCMemoryMonitorFunc RTC_MEMORY_MONITOR_FUNCTION;
  172. /*! \brief Type of memory consumption callback function. */
  173. typedef uniform bool (*uniform RTCMemoryMonitorFunc2)(const uniform size_t bytes, const uniform bool post); // FIXME: should be ssize_t
  174. /*! \brief Sets the memory consumption callback function which is
  175. * called before the library allocates or after the library frees
  176. * memory.
  177. * WARNING: This function is deprecated, use rtcDeviceSetMemoryMonitorFunction2 instead.
  178. */
  179. RTCORE_DEPRECATED void rtcSetMemoryMonitorFunction(RTCMemoryMonitorFunc func);
  180. /*! \brief Sets the memory consumption callback function which is
  181. * called before the library allocates or after the library frees
  182. * memory.
  183. WARNING: This function is deprecated, use rtcDeviceSetMemoryMonitorFunction2 instead.
  184. */
  185. void rtcDeviceSetMemoryMonitorFunction(RTCDevice device, RTCMemoryMonitorFunc func);
  186. /*! \brief Sets the memory consumption callback function which is
  187. * called before or after the library allocates or frees memory. The
  188. * userPtr pointer is passed to each invokation of the callback
  189. * function. */
  190. void rtcDeviceSetMemoryMonitorFunction2(RTCDevice device, RTCMemoryMonitorFunc2 func, void* uniform userPtr);
  191. /*! \brief Implementation specific.
  192. This function is implementation specific and only for debugging
  193. purposes.
  194. WARNING: This function is deprecated do not use it.
  195. */
  196. RTCORE_DEPRECATED void rtcDebug(); // FIXME: remove
  197. #include "rtcore_scene.isph"
  198. #include "rtcore_geometry.isph"
  199. #include "rtcore_geometry_user.isph"
  200. /*! \} */
  201. #endif