rtcore_ispc.ispc 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. #include "../../include/embree2/rtcore.isph"
  17. #include "../../include/embree2/rtcore_ray.isph"
  18. #define size_tt int // FIXME: workaround of ISPC bug
  19. #define ssize_tt int // FIXME: workaround of ISPC bug
  20. extern "C" RTCDevice ispcNewDevice(const uniform int8* uniform cfg);
  21. extern "C" void ispcDeleteDevice(RTCDevice device);
  22. extern "C" void ispcInit(const uniform int8* uniform cfg);
  23. extern "C" void ispcExit();
  24. extern "C" void ispcSetParameter1i(const uniform RTCParameter parm, uniform ssize_tt val);
  25. extern "C" uniform ssize_tt ispcGetParameter1i(const uniform RTCParameter parm);
  26. extern "C" void ispcDeviceSetParameter1i(RTCDevice device, const uniform RTCParameter parm, uniform ssize_tt val);
  27. extern "C" uniform ssize_tt ispcDeviceGetParameter1i(RTCDevice device, const uniform RTCParameter parm);
  28. extern "C" uniform RTCError ispcGetError ();
  29. extern "C" uniform RTCError ispcDeviceGetError (RTCDevice device);
  30. extern "C" void ispcSetErrorFunction (void* uniform ptr);
  31. extern "C" void ispcDeviceSetErrorFunction (RTCDevice device, void* uniform ptr);
  32. extern "C" void ispcDeviceSetErrorFunction2(RTCDevice device, void* uniform fptr, void* uniform uptr);
  33. extern "C" void ispcSetMemoryMonitorFunction (void* uniform ptr);
  34. extern "C" void ispcDeviceSetMemoryMonitorFunction (RTCDevice device, void* uniform ptr);
  35. extern "C" void ispcDeviceSetMemoryMonitorFunction2 (RTCDevice device, void* uniform fptr, void* uniform uptr);
  36. extern "C" void ispcDebug();
  37. extern "C" RTCScene ispcNewScene (uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags);
  38. extern "C" RTCScene ispcNewScene2 (RTCDevice device, uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags);
  39. extern "C" void ispcSetProgressMonitorFunction (RTCScene scene, void* uniform func, void* uniform ptr);
  40. extern "C" void ispcCommit (RTCScene scene);
  41. extern "C" void ispcCommitJoin (RTCScene scene);
  42. extern "C" void ispcCommitThread (RTCScene scene, uniform unsigned int threadID, uniform unsigned int numThreads);
  43. extern "C" void ispcGetBounds(RTCScene scene, uniform RTCBounds& bounds_o);
  44. extern "C" void ispcGetLinearBounds(RTCScene scene, uniform RTCBounds* uniform bounds_o);
  45. extern "C" void ispcIntersect1 (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1& ray);
  46. extern "C" void ispcIntersect4 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  47. extern "C" void ispcIntersect8 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  48. extern "C" void ispcIntersect16 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  49. extern "C" void ispcIntersect1M (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1* uniform rays, const uniform size_t M, const uniform size_t stride);
  50. extern "C" void ispcIntersect1Mp (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1** uniform rays, const uniform size_t M);
  51. extern "C" void ispcIntersectNM (RTCScene scene, const uniform RTCIntersectContext* uniform context, struct RTCRayN* uniform rays, const uniform size_t M, const uniform size_t N, const uniform size_t stride);
  52. extern "C" void ispcIntersectNp (RTCScene scene, const uniform RTCIntersectContext* uniform context, const uniform RTCRayNp& rays, const uniform size_t N);
  53. extern "C" void ispcOccluded1 (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1& ray);
  54. extern "C" void ispcOccluded4 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  55. extern "C" void ispcOccluded8 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  56. extern "C" void ispcOccluded16 (void* uniform valid, RTCScene scene, const uniform RTCIntersectContext* uniform context, void* uniform ray);
  57. extern "C" void ispcOccluded1M (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1* uniform rays, const uniform size_t M, const uniform size_t stride);
  58. extern "C" void ispcOccluded1Mp (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1** uniform rays, const uniform size_t M);
  59. extern "C" void ispcOccludedNM (RTCScene scene, const uniform RTCIntersectContext* uniform context, struct RTCRayN* uniform rays, const uniform size_t M, const uniform size_t N, const uniform size_t stride);
  60. extern "C" void ispcOccludedNp (RTCScene scene, const uniform RTCIntersectContext* uniform context, const uniform RTCRayNp& rays, const uniform size_t N);
  61. extern "C" void ispcDeleteScene (RTCScene scene);
  62. extern "C" uniform unsigned int ispcNewInstance (RTCScene target, RTCScene source);
  63. extern "C" uniform unsigned int ispcNewInstance2 (RTCScene target, RTCScene source, uniform size_tt numTimeSteps);
  64. extern "C" void ispcSetTransform (RTCScene scene, uniform unsigned int geomID, uniform RTCMatrixType layout, const uniform float* uniform xfm);
  65. extern "C" void ispcSetTransform2 (RTCScene scene, uniform unsigned int geomID, uniform RTCMatrixType layout, const uniform float* uniform xfm, uniform size_tt timeStep);
  66. extern "C" uniform unsigned int ispcNewUserGeometry (RTCScene scene, uniform size_tt numItems);
  67. extern "C" uniform unsigned int ispcNewUserGeometry2 (RTCScene scene, uniform size_tt numItems, uniform size_tt numTimeSteps);
  68. extern "C" uniform unsigned int ispcNewUserGeometry3 (RTCScene scene, uniform RTCGeometryFlags gflags, uniform size_tt numItems, uniform size_tt numTimeSteps);
  69. extern "C" uniform unsigned int ispcNewTriangleMesh (RTCScene scene,
  70. uniform RTCGeometryFlags flags,
  71. uniform size_tt numTriangles,
  72. uniform size_tt numVertices,
  73. uniform size_tt numTimeSteps);
  74. extern "C" uniform unsigned int ispcNewQuadMesh (RTCScene scene,
  75. uniform RTCGeometryFlags flags,
  76. uniform size_tt numQuads,
  77. uniform size_tt numVertices,
  78. uniform size_tt numTimeSteps);
  79. extern "C" uniform unsigned int ispcNewLineSegments (RTCScene scene,
  80. uniform RTCGeometryFlags flags,
  81. uniform size_tt numSegments,
  82. uniform size_tt numVertices,
  83. uniform size_tt numTimeSteps);
  84. extern "C" uniform unsigned int ispcNewHairGeometry (RTCScene scene,
  85. uniform RTCGeometryFlags flags,
  86. uniform size_tt numCurves,
  87. uniform size_tt numVertices,
  88. uniform size_tt numTimeSteps);
  89. extern "C" uniform unsigned int ispcNewCurveGeometry (RTCScene scene,
  90. uniform RTCGeometryFlags flags,
  91. uniform size_tt numCurves,
  92. uniform size_tt numVertices,
  93. uniform size_tt numTimeSteps);
  94. extern "C" uniform unsigned int ispcNewSubdivisionMesh (RTCScene scene,
  95. uniform RTCGeometryFlags flags,
  96. uniform size_tt numFaces,
  97. uniform size_tt numEdges,
  98. uniform size_tt numVertices,
  99. uniform size_tt numCreases,
  100. uniform size_tt numCorners,
  101. uniform size_tt numHoles,
  102. uniform size_tt numTimeSteps);
  103. extern "C" void ispcSetRayMask (RTCScene scene, uniform unsigned int geomID, uniform int mask);
  104. extern "C" void ispcSetBoundaryMode(RTCScene scene, uniform unsigned int geomID, uniform size_tt mode);
  105. extern "C" void ispcSetSubdivisionMode(RTCScene scene, uniform unsigned int geomID, uniform size_tt topologyID, uniform size_tt mode);
  106. extern "C" void ispcSetIndexBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType vertexBuffer, uniform RTCBufferType indexBuffer);
  107. extern "C" void* uniform ispcMapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  108. extern "C" void ispcUnmapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  109. extern "C" void ispcSetBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type, const void* uniform ptr, uniform size_tt offset, uniform size_tt stride, uniform size_tt size);
  110. extern "C" void ispcEnable (RTCScene scene, uniform unsigned int geomID);
  111. extern "C" void ispcUpdate (RTCScene scene, uniform unsigned int geomID);
  112. extern "C" void ispcUpdateBuffer (RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
  113. extern "C" void ispcDisable (RTCScene scene, uniform unsigned int geomID);
  114. extern "C" void ispcDeleteGeometry (RTCScene scene, uniform unsigned int geomID);
  115. extern "C" void ispcSetBoundsFunction (RTCScene scene, uniform unsigned int geomID, void* uniform bounds);
  116. extern "C" void ispcSetBoundsFunction2 (RTCScene scene, uniform unsigned int geomID, void* uniform bounds, void* uniform userPtr);
  117. extern "C" void ispcSetBoundsFunction3 (RTCScene scene, uniform unsigned int geomID, void* uniform bounds, void* uniform userPtr);
  118. extern "C" void ispcSetTessellationRate (RTCScene hscene, uniform unsigned geomID, uniform float tessellationRate);
  119. extern "C" void ispcSetUserData (RTCScene scene, uniform unsigned int geomID, void* uniform ptr);
  120. extern "C" void* uniform ispcGetUserData (RTCScene scene, uniform unsigned int geomID);
  121. extern "C" void ispcSetIntersectFunction1 (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  122. extern "C" void ispcSetIntersectFunction4 (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  123. extern "C" void ispcSetIntersectFunction8 (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  124. extern "C" void ispcSetIntersectFunction16 (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  125. extern "C" void ispcSetIntersectFunction1Mp (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  126. extern "C" void ispcSetIntersectFunctionN (RTCScene scene, uniform unsigned int geomID, void* uniform intersect);
  127. extern "C" void ispcSetOccludedFunction1 (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  128. extern "C" void ispcSetOccludedFunction4 (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  129. extern "C" void ispcSetOccludedFunction8 (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  130. extern "C" void ispcSetOccludedFunction16 (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  131. extern "C" void ispcSetOccludedFunction1Mp (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  132. extern "C" void ispcSetOccludedFunctionN (RTCScene scene, uniform unsigned int geomID, void* uniform occluded);
  133. extern "C" void ispcSetIntersectionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  134. extern "C" void ispcSetIntersectionFilterFunction4 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  135. extern "C" void ispcSetIntersectionFilterFunction8 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  136. extern "C" void ispcSetIntersectionFilterFunction16 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  137. extern "C" void ispcSetIntersectionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  138. extern "C" void ispcSetOcclusionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  139. extern "C" void ispcSetOcclusionFilterFunction4 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  140. extern "C" void ispcSetOcclusionFilterFunction8 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  141. extern "C" void ispcSetOcclusionFilterFunction16 (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  142. extern "C" void ispcSetOcclusionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, void* uniform filter);
  143. extern "C" void ispcSetDisplacementFunction (RTCScene scene, uniform unsigned int geomID, void *uniform func, uniform RTCBounds* uniform bounds);
  144. extern "C" void ispcSetDisplacementFunction2 (RTCScene scene, uniform unsigned int geomID, void *uniform func, uniform RTCBounds* uniform bounds);
  145. extern "C" void ispcInterpolateN(RTCScene scene, uniform unsigned int geomID,
  146. const void* uniform valid, const uniform unsigned int* uniform primIDs, const uniform float* uniform u, const uniform float* uniform v, uniform size_tt numUVs,
  147. uniform RTCBufferType buffer,
  148. uniform float* uniform P, uniform float* uniform dPdu, uniform float* uniform dPdv, uniform size_tt numFloats);
  149. extern "C" void ispcInterpolateN2(RTCScene scene, uniform unsigned int geomID,
  150. const void* uniform valid, const uniform unsigned int* uniform primIDs, const uniform float* uniform u, const uniform float* uniform v, uniform size_tt numUVs,
  151. uniform RTCBufferType buffer,
  152. uniform float* uniform P, uniform float* uniform dPdu, uniform float* uniform dPdv,
  153. uniform float* uniform ddPdudu, uniform float* uniform ddPdvdv, uniform float* uniform ddPdudv,
  154. uniform size_tt numFloats);
  155. RTCDevice rtcNewDevice(const uniform int8* uniform cfg) {
  156. return ispcNewDevice(cfg);
  157. }
  158. void rtcDeleteDevice(RTCDevice device) {
  159. ispcDeleteDevice(device);
  160. }
  161. void rtcInit(const uniform int8* uniform cfg) {
  162. ispcInit(cfg);
  163. }
  164. void rtcExit() {
  165. ispcExit();
  166. }
  167. void rtcSetParameter1i(const uniform RTCParameter parm, uniform size_t val) {
  168. ispcSetParameter1i(parm,val);
  169. }
  170. uniform size_t rtcGetParameter1i(const uniform RTCParameter parm) {
  171. return ispcGetParameter1i(parm);
  172. }
  173. void rtcDeviceSetParameter1i(RTCDevice device, const uniform RTCParameter parm, uniform size_t val) {
  174. ispcDeviceSetParameter1i(device,parm,val);
  175. }
  176. uniform size_t rtcDeviceGetParameter1i(RTCDevice device, const uniform RTCParameter parm) {
  177. return ispcDeviceGetParameter1i(device,parm);
  178. }
  179. uniform RTCError rtcGetError() {
  180. return ispcGetError();
  181. }
  182. uniform RTCError rtcDeviceGetError(RTCDevice device) {
  183. return ispcDeviceGetError(device);
  184. }
  185. void rtcSetErrorFunction(uniform RTCErrorFunc func) {
  186. ispcSetErrorFunction(func);
  187. }
  188. void rtcDeviceSetErrorFunction(RTCDevice device, uniform RTCErrorFunc func) {
  189. ispcDeviceSetErrorFunction(device,func);
  190. }
  191. void rtcDeviceSetErrorFunction2(RTCDevice device, uniform RTCErrorFunc2 fptr, void* uniform uptr) {
  192. ispcDeviceSetErrorFunction2(device,fptr,uptr);
  193. }
  194. void rtcSetMemoryMonitorFunction(uniform RTCMemoryMonitorFunc func) {
  195. ispcSetMemoryMonitorFunction(func);
  196. }
  197. void rtcDeviceSetMemoryMonitorFunction(RTCDevice device, uniform RTCMemoryMonitorFunc func) {
  198. ispcDeviceSetMemoryMonitorFunction(device,func);
  199. }
  200. void rtcDeviceSetMemoryMonitorFunction2(RTCDevice device, uniform RTCMemoryMonitorFunc2 func, void* uniform userPtr) {
  201. ispcDeviceSetMemoryMonitorFunction2(device,func,userPtr);
  202. }
  203. void rtcDebug() {
  204. ispcDebug();
  205. }
  206. RTCScene rtcNewScene (uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags)
  207. {
  208. if (aflags & RTC_INTERSECT_VARYING) {
  209. if (sizeof(varying float) == 16)
  210. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 1));
  211. else if (sizeof(varying float) == 32)
  212. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 2));
  213. else if (sizeof(varying float) == 64)
  214. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 3));
  215. }
  216. return ispcNewScene(flags,aflags);
  217. }
  218. RTCScene rtcDeviceNewScene (RTCDevice device, uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags)
  219. {
  220. if (aflags & RTC_INTERSECT_VARYING) {
  221. if (sizeof(varying float) == 16)
  222. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 1));
  223. else if (sizeof(varying float) == 32)
  224. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 2));
  225. else if (sizeof(varying float) == 64)
  226. aflags = (uniform RTCAlgorithmFlags) ((aflags & ~RTC_INTERSECT_VARYING) | (1 << 3));
  227. }
  228. return ispcNewScene2(device,flags,aflags);
  229. }
  230. void rtcSetProgressMonitorFunction(RTCScene scene, uniform RTC_PROGRESS_MONITOR_FUNCTION func, void* uniform ptr) {
  231. ispcSetProgressMonitorFunction(scene,func,ptr);
  232. }
  233. void rtcCommit (RTCScene scene) {
  234. ispcCommit(scene);
  235. }
  236. void rtcCommitJoin (RTCScene scene) {
  237. ispcCommitJoin(scene);
  238. }
  239. void rtcCommitThread (RTCScene scene, uniform unsigned int threadID, uniform unsigned int numThreads) {
  240. ispcCommitThread(scene,threadID,numThreads);
  241. }
  242. void rtcGetBounds(RTCScene scene, uniform RTCBounds& bounds_o) {
  243. ispcGetBounds(scene,bounds_o);
  244. }
  245. void rtcGetLinearBounds(RTCScene scene, uniform RTCBounds* uniform bounds_o) {
  246. ispcGetLinearBounds(scene,bounds_o);
  247. }
  248. void rtcIntersect1 (RTCScene scene, uniform RTCRay1& ray) {
  249. ispcIntersect1(scene,NULL,ray);
  250. }
  251. void rtcIntersect1Ex (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1& ray) {
  252. ispcIntersect1(scene,context,ray);
  253. }
  254. void rtcIntersect (RTCScene scene, varying RTCRay& ray)
  255. {
  256. varying bool mask = __mask;
  257. unmasked {
  258. varying int imask = mask ? -1 : 0;
  259. }
  260. if (sizeof(varying float) == 16)
  261. ispcIntersect4(&imask,scene,NULL,&ray);
  262. else if (sizeof(varying float) == 32)
  263. ispcIntersect8(&imask,scene,NULL,&ray);
  264. else if (sizeof(varying float) == 64)
  265. ispcIntersect16(&imask,scene,NULL,&ray);
  266. }
  267. void rtcIntersectEx (RTCScene scene, const uniform RTCIntersectContext* uniform context, varying RTCRay& ray)
  268. {
  269. varying bool mask = __mask;
  270. unmasked {
  271. varying int imask = mask ? -1 : 0;
  272. }
  273. if (sizeof(varying float) == 16)
  274. ispcIntersect4(&imask,scene,context,&ray);
  275. else if (sizeof(varying float) == 32)
  276. ispcIntersect8(&imask,scene,context,&ray);
  277. else if (sizeof(varying float) == 64)
  278. ispcIntersect16(&imask,scene,context,&ray);
  279. }
  280. void rtcIntersect1M (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1* uniform rays, const uniform size_t M, const uniform size_t stride) {
  281. ispcIntersect1M(scene,context,rays,M,stride);
  282. }
  283. void rtcIntersect1M (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1** uniform rays, const uniform size_t M, const uniform size_t stride) {
  284. ispcIntersect1Mp(scene,context,rays,M);
  285. }
  286. void rtcIntersectVM (RTCScene scene, const uniform RTCIntersectContext* uniform context, varying RTCRay* uniform rays, const uniform size_t M, const uniform size_t stride) {
  287. ispcIntersectNM(scene,context,(struct RTCRayN*)rays,sizeof(varying float)/4,M,stride);
  288. }
  289. 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) {
  290. ispcIntersectNM(scene,context,(struct RTCRayN*)rays,N,M,stride);
  291. }
  292. void rtcIntersectNp (RTCScene scene, const uniform RTCIntersectContext* uniform context, const uniform RTCRayNp& rays, const uniform size_t N) {
  293. ispcIntersectNp(scene,context,rays,N);
  294. }
  295. void rtcOccluded1 (RTCScene scene, uniform RTCRay1& ray) {
  296. ispcOccluded1(scene,NULL,ray);
  297. }
  298. void rtcOccluded1Ex (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1& ray) {
  299. ispcOccluded1(scene,context,ray);
  300. }
  301. void rtcOccluded (RTCScene scene, varying RTCRay& ray)
  302. {
  303. varying bool mask = __mask;
  304. unmasked {
  305. varying int imask = mask ? -1 : 0;
  306. }
  307. if (sizeof(varying float) == 16)
  308. ispcOccluded4(&imask,scene,NULL,&ray);
  309. else if (sizeof(varying float) == 32)
  310. ispcOccluded8(&imask,scene,NULL,&ray);
  311. else if (sizeof(varying float) == 64)
  312. ispcOccluded16(&imask,scene,NULL,&ray);
  313. }
  314. void rtcOccludedEx (RTCScene scene, const uniform RTCIntersectContext* uniform context, varying RTCRay& ray)
  315. {
  316. varying bool mask = __mask;
  317. unmasked {
  318. varying int imask = mask ? -1 : 0;
  319. }
  320. if (sizeof(varying float) == 16)
  321. ispcOccluded4(&imask,scene,context,&ray);
  322. else if (sizeof(varying float) == 32)
  323. ispcOccluded8(&imask,scene,context,&ray);
  324. else if (sizeof(varying float) == 64)
  325. ispcOccluded16(&imask,scene,context,&ray);
  326. }
  327. void rtcOccluded1M (RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1* uniform rays, const uniform size_t M, const uniform size_t stride) {
  328. ispcOccluded1M(scene,context,rays,M,stride);
  329. }
  330. void rtcOccluded1Mp(RTCScene scene, const uniform RTCIntersectContext* uniform context, uniform RTCRay1** uniform rays, const uniform size_t M, const uniform size_t stride) {
  331. ispcOccluded1Mp(scene,context,rays,M);
  332. }
  333. void rtcOccludedVM (RTCScene scene, const uniform RTCIntersectContext* uniform context, varying RTCRay* uniform rays, const uniform size_t M, const uniform size_t stride) {
  334. ispcOccludedNM(scene,context,(struct RTCRayN*)rays,sizeof(varying float)/4,M,stride);
  335. }
  336. 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) {
  337. ispcOccludedNM(scene,context,(struct RTCRayN*)rays,N,M,stride);
  338. }
  339. void rtcOccludedNp (RTCScene scene, const uniform RTCIntersectContext* uniform context, const uniform RTCRayNp& rays, const uniform size_t N) {
  340. ispcOccludedNp(scene,context,rays,N);
  341. }
  342. void rtcDeleteScene (RTCScene scene) {
  343. ispcDeleteScene(scene);
  344. }
  345. uniform unsigned int rtcNewInstance (RTCScene target, RTCScene source) {
  346. return ispcNewInstance(target,source);
  347. }
  348. uniform unsigned int rtcNewInstance2 (RTCScene target, RTCScene source, uniform size_t numTimeSteps) {
  349. return ispcNewInstance2(target,source,numTimeSteps);
  350. }
  351. void rtcSetTransform (RTCScene scene, uniform unsigned int geomID, uniform RTCMatrixType layout, const uniform float* uniform xfm) {
  352. ispcSetTransform(scene,geomID,layout,xfm);
  353. }
  354. void rtcSetTransform2 (RTCScene scene, uniform unsigned int geomID, uniform RTCMatrixType layout, const uniform float* uniform xfm, uniform size_t timeStep) {
  355. ispcSetTransform2(scene,geomID,layout,xfm,timeStep);
  356. }
  357. uniform unsigned int rtcNewUserGeometry (RTCScene scene, uniform size_t numItems) {
  358. return ispcNewUserGeometry(scene,numItems);
  359. }
  360. uniform unsigned int rtcNewUserGeometry2 (RTCScene scene, uniform size_t numItems, uniform size_t numTimeSteps) {
  361. return ispcNewUserGeometry2(scene,numItems,numTimeSteps);
  362. }
  363. uniform unsigned int rtcNewUserGeometry3 (RTCScene scene, uniform RTCGeometryFlags gflags, uniform size_t numItems, uniform size_t numTimeSteps) {
  364. return ispcNewUserGeometry3(scene,gflags,numItems,numTimeSteps);
  365. }
  366. uniform unsigned int rtcNewTriangleMesh (RTCScene scene,
  367. uniform RTCGeometryFlags flags,
  368. uniform size_t numTriangles,
  369. uniform size_t numVertices,
  370. uniform size_t numTimeSteps)
  371. {
  372. return ispcNewTriangleMesh(scene,flags,numTriangles,numVertices,numTimeSteps);
  373. }
  374. uniform unsigned int rtcNewQuadMesh (RTCScene scene,
  375. uniform RTCGeometryFlags flags,
  376. uniform size_t numQuads,
  377. uniform size_t numVertices,
  378. uniform size_t numTimeSteps)
  379. {
  380. return ispcNewQuadMesh(scene,flags,numQuads,numVertices,numTimeSteps);
  381. }
  382. uniform unsigned int rtcNewLineSegments (RTCScene scene,
  383. uniform RTCGeometryFlags flags,
  384. uniform size_t numSegments,
  385. uniform size_t numVertices,
  386. uniform size_t numTimeSteps)
  387. {
  388. return ispcNewLineSegments (scene,flags,numSegments,numVertices,numTimeSteps);
  389. }
  390. uniform unsigned int rtcNewHairGeometry (RTCScene scene,
  391. uniform RTCGeometryFlags flags,
  392. uniform size_t numCurves,
  393. uniform size_t numVertices,
  394. uniform size_t numTimeSteps)
  395. {
  396. return ispcNewHairGeometry (scene,flags,numCurves,numVertices,numTimeSteps);
  397. }
  398. uniform unsigned int rtcNewCurveGeometry (RTCScene scene,
  399. uniform RTCGeometryFlags flags,
  400. uniform size_t numCurves,
  401. uniform size_t numVertices,
  402. uniform size_t numTimeSteps)
  403. {
  404. return ispcNewCurveGeometry (scene,flags,numCurves,numVertices,numTimeSteps);
  405. }
  406. uniform unsigned int rtcNewSubdivisionMesh (RTCScene scene,
  407. uniform RTCGeometryFlags flags,
  408. uniform size_t numFaces,
  409. uniform size_t numEdges,
  410. uniform size_t numVertices,
  411. uniform size_t numEdgeCreases,
  412. uniform size_t numVertexCreases,
  413. uniform size_t numHoles,
  414. uniform size_t numTimeSteps)
  415. {
  416. return ispcNewSubdivisionMesh(scene,flags,numFaces,numEdges,numVertices,numEdgeCreases,numVertexCreases,numHoles,numTimeSteps);
  417. }
  418. void rtcSetMask (RTCScene scene, uniform unsigned int geomID, uniform int mask) {
  419. ispcSetRayMask(scene,geomID,mask);
  420. }
  421. void rtcSetBoundaryMode(RTCScene scene, uniform unsigned int geomID, uniform RTCBoundaryMode mode) {
  422. ispcSetBoundaryMode(scene,geomID,mode);
  423. }
  424. void rtcSetSubdivisionMode(RTCScene scene, uniform unsigned int geomID, uniform unsigned int topologyID, uniform RTCSubdivisionMode mode) {
  425. ispcSetSubdivisionMode(scene,geomID,topologyID,mode);
  426. }
  427. void rtcSetIndexBuffer(RTCScene scene, uniform unsigned geomID, uniform RTCBufferType vertexBuffer, uniform RTCBufferType indexBuffer) {
  428. ispcSetIndexBuffer(scene,geomID,vertexBuffer,indexBuffer);
  429. }
  430. void* uniform rtcMapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type) {
  431. return ispcMapBuffer(scene,geomID,type);
  432. }
  433. void rtcUnmapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type) {
  434. ispcUnmapBuffer(scene,geomID,type);
  435. }
  436. void rtcSetBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type, const void* uniform ptr, uniform size_t offset, uniform size_t stride) {
  437. ispcSetBuffer(scene,geomID,type,ptr,offset,stride,-1);
  438. }
  439. void rtcSetBuffer2(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type, const void* uniform ptr, uniform size_t offset, uniform size_t stride, uniform size_t size) {
  440. ispcSetBuffer(scene,geomID,type,ptr,offset,stride,size);
  441. }
  442. void rtcEnable (RTCScene scene, uniform unsigned int geomID) {
  443. ispcEnable(scene,geomID);
  444. }
  445. void rtcUpdate (RTCScene scene, uniform unsigned int geomID) {
  446. ispcUpdate(scene,geomID);
  447. }
  448. void rtcUpdateBuffer (RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type) {
  449. ispcUpdateBuffer(scene,geomID,type);
  450. }
  451. void rtcDisable (RTCScene scene, uniform unsigned int geomID) {
  452. ispcDisable(scene,geomID);
  453. }
  454. void rtcDeleteGeometry (RTCScene scene, uniform unsigned int geomID) {
  455. ispcDeleteGeometry(scene,geomID);
  456. }
  457. void rtcSetTessellationRate (RTCScene hscene, uniform unsigned geomID, uniform float tessellationRate) {
  458. ispcSetTessellationRate(hscene,geomID,tessellationRate);
  459. }
  460. void rtcSetUserData (RTCScene scene, uniform unsigned int geomID, void* uniform ptr) {
  461. ispcSetUserData(scene,geomID,ptr);
  462. }
  463. void* uniform rtcGetUserData (RTCScene scene, uniform unsigned int geomID) {
  464. return ispcGetUserData(scene,geomID);
  465. }
  466. void rtcSetBoundsFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCBoundsFunc bounds) {
  467. ispcSetBoundsFunction(scene,geomID,bounds);
  468. }
  469. void rtcSetBoundsFunction2 (RTCScene scene, uniform unsigned int geomID, uniform RTCBoundsFunc2 bounds, void* uniform userPtr) {
  470. ispcSetBoundsFunction2(scene,geomID,bounds,userPtr);
  471. }
  472. void rtcSetBoundsFunction3 (RTCScene scene, uniform unsigned int geomID, uniform RTCBoundsFunc3 bounds, void* uniform userPtr) {
  473. ispcSetBoundsFunction3(scene,geomID,bounds,userPtr);
  474. }
  475. void rtcSetIntersectFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncUniform intersect) {
  476. ispcSetIntersectFunction1(scene,geomID,intersect);
  477. }
  478. void rtcSetIntersectFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncVarying intersect)
  479. {
  480. if (sizeof(varying float) == 16)
  481. ispcSetIntersectFunction4(scene,geomID,intersect);
  482. else if (sizeof(varying float) == 32)
  483. ispcSetIntersectFunction8(scene,geomID,intersect);
  484. else if (sizeof(varying float) == 64)
  485. ispcSetIntersectFunction16(scene,geomID,intersect);
  486. }
  487. void rtcSetIntersectFunction1Mp (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFunc1Mp intersect) {
  488. ispcSetIntersectFunction1Mp(scene,geomID,intersect);
  489. }
  490. void rtcSetIntersectFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncN intersect) {
  491. ispcSetIntersectFunctionN(scene,geomID,intersect);
  492. }
  493. void rtcSetOccludedFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncUniform occluded) {
  494. ispcSetOccludedFunction1(scene,geomID,occluded);
  495. }
  496. void rtcSetOccludedFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncVarying occluded)
  497. {
  498. if (sizeof(varying float) == 16)
  499. ispcSetOccludedFunction4(scene,geomID,occluded);
  500. else if (sizeof(varying float) == 32)
  501. ispcSetOccludedFunction8(scene,geomID,occluded);
  502. else if (sizeof(varying float) == 64)
  503. ispcSetOccludedFunction16(scene,geomID,occluded);
  504. }
  505. void rtcSetOccludedFunction1Mp (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFunc1Mp occluded) {
  506. ispcSetOccludedFunction1Mp(scene,geomID,occluded);
  507. }
  508. void rtcSetOccludedFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncN occluded) {
  509. ispcSetOccludedFunctionN(scene,geomID,occluded);
  510. }
  511. void rtcSetIntersectionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform filter) {
  512. ispcSetIntersectionFilterFunction1(scene,geomID,filter);
  513. }
  514. void rtcSetIntersectionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying filter)
  515. {
  516. if (sizeof(varying float) == 16)
  517. ispcSetIntersectionFilterFunction4(scene,geomID,filter);
  518. else if (sizeof(varying float) == 32)
  519. ispcSetIntersectionFilterFunction8(scene,geomID,filter);
  520. else if (sizeof(varying float) == 64)
  521. ispcSetIntersectionFilterFunction16(scene,geomID,filter);
  522. }
  523. void rtcSetIntersectionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncN filter) {
  524. ispcSetIntersectionFilterFunctionN(scene,geomID,filter);
  525. }
  526. void rtcSetOcclusionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform filter) {
  527. ispcSetOcclusionFilterFunction1(scene,geomID,filter);
  528. }
  529. void rtcSetOcclusionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying filter)
  530. {
  531. if (sizeof(varying float) == 16)
  532. ispcSetOcclusionFilterFunction4(scene,geomID,filter);
  533. else if (sizeof(varying float) == 32)
  534. ispcSetOcclusionFilterFunction8(scene,geomID,filter);
  535. else if (sizeof(varying float) == 64)
  536. ispcSetOcclusionFilterFunction16(scene,geomID,filter);
  537. }
  538. void rtcSetOcclusionFilterFunctionN (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncN filter) {
  539. ispcSetOcclusionFilterFunctionN(scene,geomID,filter);
  540. }
  541. void rtcSetDisplacementFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCDisplacementFunc func, uniform RTCBounds* uniform bounds) {
  542. ispcSetDisplacementFunction(scene,geomID,func,bounds);
  543. }
  544. void rtcSetDisplacementFunction2 (RTCScene scene, uniform unsigned int geomID, uniform RTCDisplacementFunc2 func, uniform RTCBounds* uniform bounds) {
  545. ispcSetDisplacementFunction2(scene,geomID,func,bounds);
  546. }
  547. void rtcInterpolate(RTCScene scene, uniform unsigned int geomID, varying unsigned int primID, varying float u, varying float v,
  548. uniform RTCBufferType buffer,
  549. varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv, uniform size_t numFloats)
  550. {
  551. varying bool mask = __mask;
  552. unmasked {
  553. varying int imask = mask ? -1 : 0;
  554. }
  555. ispcInterpolateN(scene,geomID,(const void* uniform)&imask,(const uniform unsigned int* uniform)&primID,
  556. (const uniform float* uniform)&u,(const uniform float* uniform)&v,sizeof(varying float)/4,buffer,
  557. (uniform float* uniform)P,(uniform float* uniform)dPdu,(uniform float* uniform)dPdv,numFloats);
  558. }
  559. void rtcInterpolate2(RTCScene scene, uniform unsigned int geomID, varying unsigned int primID, varying float u, varying float v,
  560. uniform RTCBufferType buffer,
  561. varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv,
  562. varying float* uniform ddPdudu, varying float* uniform ddPdvdv, varying float* uniform ddPdudv,
  563. uniform size_t numFloats)
  564. {
  565. varying bool mask = __mask;
  566. unmasked {
  567. varying int imask = mask ? -1 : 0;
  568. }
  569. ispcInterpolateN2(scene,geomID,(const void* uniform)&imask,(const uniform unsigned int* uniform)&primID,
  570. (const uniform float* uniform)&u,(const uniform float* uniform)&v,sizeof(varying float)/4,buffer,
  571. (uniform float* uniform)P,(uniform float* uniform)dPdu,(uniform float* uniform)dPdv,
  572. (uniform float* uniform)ddPdudu,(uniform float* uniform)ddPdvdv,(uniform float* uniform)ddPdudv,
  573. numFloats);
  574. }
  575. export void dummy_rtcore_ispc() {} // just to avoid compile warning "libembree.a(rtcore_ispc.dev.o) has no symbols" under MacOSX