rtcore.cpp 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  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. #ifdef _WIN32
  17. # define RTCORE_API extern "C" __declspec(dllexport)
  18. #else
  19. # define RTCORE_API extern "C" __attribute__ ((visibility ("default")))
  20. #endif
  21. #include "default.h"
  22. #include "device.h"
  23. #include "scene.h"
  24. #include "context.h"
  25. #include "../../include/embree2/rtcore_ray.h"
  26. namespace embree
  27. {
  28. /* mutex to make API thread safe */
  29. static MutexSys g_mutex;
  30. RTCORE_API RTCDevice rtcNewDevice(const char* cfg)
  31. {
  32. RTCORE_CATCH_BEGIN;
  33. RTCORE_TRACE(rtcNewDevice);
  34. Lock<MutexSys> lock(g_mutex);
  35. return (RTCDevice) new Device(cfg,false);
  36. RTCORE_CATCH_END(nullptr);
  37. return (RTCDevice) nullptr;
  38. }
  39. RTCORE_API void rtcDeleteDevice(RTCDevice device)
  40. {
  41. RTCORE_CATCH_BEGIN;
  42. RTCORE_TRACE(rtcDeleteDevice);
  43. RTCORE_VERIFY_HANDLE(device);
  44. Lock<MutexSys> lock(g_mutex);
  45. delete (Device*) device;
  46. RTCORE_CATCH_END(nullptr);
  47. }
  48. /* global device for compatibility with old rtcInit / rtcExit scheme */
  49. static Device* g_device = nullptr;
  50. RTCORE_API void rtcInit(const char* cfg)
  51. {
  52. RTCORE_CATCH_BEGIN;
  53. RTCORE_TRACE(rtcInit);
  54. Lock<MutexSys> lock(g_mutex);
  55. if (g_device) throw_RTCError(RTC_INVALID_OPERATION,"already initialized");
  56. g_device = new Device(cfg,true);
  57. RTCORE_CATCH_END(g_device);
  58. }
  59. RTCORE_API void rtcExit()
  60. {
  61. RTCORE_CATCH_BEGIN;
  62. RTCORE_TRACE(rtcExit);
  63. Lock<MutexSys> lock(g_mutex);
  64. if (!g_device) throw_RTCError(RTC_INVALID_OPERATION,"rtcInit has to get called before rtcExit");
  65. delete g_device; g_device = nullptr;
  66. RTCORE_CATCH_END(g_device);
  67. }
  68. RTCORE_API void rtcSetParameter1i(const RTCParameter parm, ssize_t val)
  69. {
  70. RTCORE_CATCH_BEGIN;
  71. RTCORE_TRACE(rtcSetParameter1i);
  72. Lock<MutexSys> lock(g_mutex);
  73. if (g_device) g_device->setParameter1i(parm,val);
  74. RTCORE_CATCH_END(g_device);
  75. }
  76. RTCORE_API ssize_t rtcGetParameter1i(const RTCParameter parm)
  77. {
  78. RTCORE_CATCH_BEGIN;
  79. RTCORE_TRACE(rtcGetParameter1i);
  80. assert(g_device);
  81. Lock<MutexSys> lock(g_mutex);
  82. return g_device->getParameter1i(parm);
  83. RTCORE_CATCH_END(g_device);
  84. return 0;
  85. }
  86. RTCORE_API void rtcDeviceSetParameter1i(RTCDevice hdevice, const RTCParameter parm, ssize_t val)
  87. {
  88. Device* device = (Device*) hdevice;
  89. RTCORE_CATCH_BEGIN;
  90. RTCORE_TRACE(rtcDeviceSetParameter1i);
  91. const bool internal_parm = (size_t)parm >= 1000000 && (size_t)parm < 1000004;
  92. if (!internal_parm) RTCORE_VERIFY_HANDLE(hdevice); // allow NULL device for special internal settings
  93. Lock<MutexSys> lock(g_mutex);
  94. device->setParameter1i(parm,val);
  95. RTCORE_CATCH_END(device);
  96. }
  97. RTCORE_API ssize_t rtcDeviceGetParameter1i(RTCDevice hdevice, const RTCParameter parm)
  98. {
  99. Device* device = (Device*) hdevice;
  100. RTCORE_CATCH_BEGIN;
  101. RTCORE_TRACE(rtcDeviceGetParameter1i);
  102. RTCORE_VERIFY_HANDLE(hdevice);
  103. Lock<MutexSys> lock(g_mutex);
  104. return device->getParameter1i(parm);
  105. RTCORE_CATCH_END(device);
  106. return 0;
  107. }
  108. RTCORE_API RTCError rtcGetError()
  109. {
  110. RTCORE_CATCH_BEGIN;
  111. RTCORE_TRACE(rtcGetError);
  112. if (g_device == nullptr) return Device::getThreadErrorCode();
  113. else return g_device->getDeviceErrorCode();
  114. RTCORE_CATCH_END(g_device);
  115. return RTC_UNKNOWN_ERROR;
  116. }
  117. RTCORE_API RTCError rtcDeviceGetError(RTCDevice hdevice)
  118. {
  119. Device* device = (Device*) hdevice;
  120. RTCORE_CATCH_BEGIN;
  121. RTCORE_TRACE(rtcDeviceGetError);
  122. if (device == nullptr) return Device::getThreadErrorCode();
  123. else return device->getDeviceErrorCode();
  124. RTCORE_CATCH_END(device);
  125. return RTC_UNKNOWN_ERROR;
  126. }
  127. RTCORE_API void rtcSetErrorFunction(RTCErrorFunc func)
  128. {
  129. RTCORE_CATCH_BEGIN;
  130. RTCORE_TRACE(rtcSetErrorFunction);
  131. assert(g_device);
  132. if (g_device) g_device->setErrorFunction(func);
  133. RTCORE_CATCH_END(g_device);
  134. }
  135. RTCORE_API void rtcDeviceSetErrorFunction(RTCDevice hdevice, RTCErrorFunc func)
  136. {
  137. Device* device = (Device*) hdevice;
  138. RTCORE_CATCH_BEGIN;
  139. RTCORE_TRACE(rtcDeviceSetErrorFunction);
  140. RTCORE_VERIFY_HANDLE(hdevice);
  141. device->setErrorFunction(func);
  142. RTCORE_CATCH_END(device);
  143. }
  144. RTCORE_API void rtcDeviceSetErrorFunction2(RTCDevice hdevice, RTCErrorFunc2 func, void* userPtr)
  145. {
  146. Device* device = (Device*) hdevice;
  147. RTCORE_CATCH_BEGIN;
  148. RTCORE_TRACE(rtcDeviceSetErrorFunction2);
  149. RTCORE_VERIFY_HANDLE(hdevice);
  150. device->setErrorFunction(func,userPtr);
  151. RTCORE_CATCH_END(device);
  152. }
  153. RTCORE_API void rtcSetMemoryMonitorFunction(RTCMemoryMonitorFunc func)
  154. {
  155. RTCORE_CATCH_BEGIN;
  156. RTCORE_TRACE(rtcSetMemoryMonitorFunction);
  157. assert(g_device);
  158. if (g_device) g_device->setMemoryMonitorFunction(func);
  159. RTCORE_CATCH_END(g_device);
  160. }
  161. RTCORE_API void rtcDeviceSetMemoryMonitorFunction(RTCDevice hdevice, RTCMemoryMonitorFunc func)
  162. {
  163. Device* device = (Device*) hdevice;
  164. RTCORE_CATCH_BEGIN;
  165. RTCORE_TRACE(rtcDeviceSetMemoryMonitorFunction);
  166. device->setMemoryMonitorFunction(func);
  167. RTCORE_CATCH_END(device);
  168. }
  169. RTCORE_API void rtcDeviceSetMemoryMonitorFunction2(RTCDevice hdevice, RTCMemoryMonitorFunc2 func, void* userPtr)
  170. {
  171. Device* device = (Device*) hdevice;
  172. RTCORE_CATCH_BEGIN;
  173. RTCORE_TRACE(rtcDeviceSetMemoryMonitorFunction2);
  174. device->setMemoryMonitorFunction(func,userPtr);
  175. RTCORE_CATCH_END(device);
  176. }
  177. RTCORE_API void rtcDebug()
  178. {
  179. RTCORE_CATCH_BEGIN;
  180. RTCORE_TRACE(rtcDebug);
  181. #if defined(EMBREE_STAT_COUNTERS)
  182. Stat::print(std::cout);
  183. Stat::clear();
  184. #endif
  185. RTCORE_CATCH_END(g_device);
  186. }
  187. RTCORE_API RTCScene rtcNewScene (RTCSceneFlags flags, RTCAlgorithmFlags aflags)
  188. {
  189. RTCORE_CATCH_BEGIN;
  190. RTCORE_TRACE(rtcNewScene);
  191. assert(g_device);
  192. if (!isCoherent(flags) && !isIncoherent(flags)) flags = RTCSceneFlags(flags | RTC_SCENE_INCOHERENT);
  193. return (RTCScene) new Scene(g_device,flags,aflags);
  194. RTCORE_CATCH_END(g_device);
  195. return nullptr;
  196. }
  197. RTCORE_API RTCScene rtcDeviceNewScene (RTCDevice device, RTCSceneFlags flags, RTCAlgorithmFlags aflags)
  198. {
  199. RTCORE_CATCH_BEGIN;
  200. RTCORE_TRACE(rtcDeviceNewScene);
  201. RTCORE_VERIFY_HANDLE(device);
  202. if (!isCoherent(flags) && !isIncoherent(flags)) flags = RTCSceneFlags(flags | RTC_SCENE_INCOHERENT);
  203. return (RTCScene) new Scene((Device*)device,flags,aflags);
  204. RTCORE_CATCH_END((Device*)device);
  205. return nullptr;
  206. }
  207. RTCORE_API void rtcSetProgressMonitorFunction(RTCScene hscene, RTCProgressMonitorFunc func, void* ptr)
  208. {
  209. Scene* scene = (Scene*) hscene;
  210. RTCORE_CATCH_BEGIN;
  211. RTCORE_TRACE(rtcSetProgressMonitorFunction);
  212. RTCORE_VERIFY_HANDLE(hscene);
  213. scene->setProgressMonitorFunction(func,ptr);
  214. RTCORE_CATCH_END(scene->device);
  215. }
  216. RTCORE_API void rtcCommit (RTCScene hscene)
  217. {
  218. Scene* scene = (Scene*) hscene;
  219. RTCORE_CATCH_BEGIN;
  220. RTCORE_TRACE(rtcCommit);
  221. RTCORE_VERIFY_HANDLE(hscene);
  222. scene->commit(0,0,true);
  223. RTCORE_CATCH_END(scene->device);
  224. }
  225. RTCORE_API void rtcCommitJoin (RTCScene hscene)
  226. {
  227. Scene* scene = (Scene*) hscene;
  228. RTCORE_CATCH_BEGIN;
  229. RTCORE_TRACE(rtcCommitJoin);
  230. RTCORE_VERIFY_HANDLE(hscene);
  231. scene->commit(0,0,false);
  232. RTCORE_CATCH_END(scene->device);
  233. }
  234. RTCORE_API void rtcCommitThread(RTCScene hscene, unsigned int threadID, unsigned int numThreads)
  235. {
  236. Scene* scene = (Scene*) hscene;
  237. RTCORE_CATCH_BEGIN;
  238. RTCORE_TRACE(rtcCommitThread);
  239. RTCORE_VERIFY_HANDLE(hscene);
  240. if (unlikely(numThreads == 0))
  241. throw_RTCError(RTC_INVALID_OPERATION,"invalid number of threads specified");
  242. /* for best performance set FTZ and DAZ flags in the MXCSR control and status register */
  243. unsigned int mxcsr = _mm_getcsr();
  244. _mm_setcsr(mxcsr | /* FTZ */ (1<<15) | /* DAZ */ (1<<6));
  245. /* perform scene build */
  246. scene->commit(threadID,numThreads,false);
  247. /* reset MXCSR register again */
  248. _mm_setcsr(mxcsr);
  249. RTCORE_CATCH_END(scene->device);
  250. }
  251. RTCORE_API void rtcGetBounds(RTCScene hscene, RTCBounds& bounds_o)
  252. {
  253. Scene* scene = (Scene*) hscene;
  254. RTCORE_CATCH_BEGIN;
  255. RTCORE_TRACE(rtcGetBounds);
  256. RTCORE_VERIFY_HANDLE(hscene);
  257. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  258. BBox3fa bounds = scene->bounds.bounds();
  259. bounds_o.lower_x = bounds.lower.x;
  260. bounds_o.lower_y = bounds.lower.y;
  261. bounds_o.lower_z = bounds.lower.z;
  262. bounds_o.align0 = 0;
  263. bounds_o.upper_x = bounds.upper.x;
  264. bounds_o.upper_y = bounds.upper.y;
  265. bounds_o.upper_z = bounds.upper.z;
  266. bounds_o.align1 = 0;
  267. RTCORE_CATCH_END(scene->device);
  268. }
  269. RTCORE_API void rtcGetLinearBounds(RTCScene hscene, RTCBounds* bounds_o)
  270. {
  271. Scene* scene = (Scene*) hscene;
  272. RTCORE_CATCH_BEGIN;
  273. RTCORE_TRACE(rtcGetBounds);
  274. RTCORE_VERIFY_HANDLE(hscene);
  275. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  276. bounds_o[0].lower_x = scene->bounds.bounds0.lower.x;
  277. bounds_o[0].lower_y = scene->bounds.bounds0.lower.y;
  278. bounds_o[0].lower_z = scene->bounds.bounds0.lower.z;
  279. bounds_o[0].align0 = 0;
  280. bounds_o[0].upper_x = scene->bounds.bounds0.upper.x;
  281. bounds_o[0].upper_y = scene->bounds.bounds0.upper.y;
  282. bounds_o[0].upper_z = scene->bounds.bounds0.upper.z;
  283. bounds_o[0].align1 = 0;
  284. bounds_o[1].lower_x = scene->bounds.bounds1.lower.x;
  285. bounds_o[1].lower_y = scene->bounds.bounds1.lower.y;
  286. bounds_o[1].lower_z = scene->bounds.bounds1.lower.z;
  287. bounds_o[1].align0 = 0;
  288. bounds_o[1].upper_x = scene->bounds.bounds1.upper.x;
  289. bounds_o[1].upper_y = scene->bounds.bounds1.upper.y;
  290. bounds_o[1].upper_z = scene->bounds.bounds1.upper.z;
  291. bounds_o[1].align1 = 0;
  292. RTCORE_CATCH_END(scene->device);
  293. }
  294. RTCORE_API void rtcIntersect (RTCScene hscene, RTCRay& ray)
  295. {
  296. Scene* scene = (Scene*) hscene;
  297. RTCORE_CATCH_BEGIN;
  298. RTCORE_TRACE(rtcIntersect);
  299. #if defined(DEBUG)
  300. RTCORE_VERIFY_HANDLE(hscene);
  301. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  302. if (((size_t)&ray) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  303. #endif
  304. STAT3(normal.travs,1,1,1);
  305. IntersectContext context(scene,nullptr);
  306. scene->intersect(ray,&context);
  307. RTCORE_CATCH_END(scene->device);
  308. }
  309. RTCORE_API void rtcIntersect1Ex (RTCScene hscene, const RTCIntersectContext* user_context, RTCRay& ray)
  310. {
  311. Scene* scene = (Scene*) hscene;
  312. RTCORE_CATCH_BEGIN;
  313. RTCORE_TRACE(rtcIntersect1Ex);
  314. #if defined(DEBUG)
  315. RTCORE_VERIFY_HANDLE(hscene);
  316. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  317. if (((size_t)&ray) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  318. #endif
  319. STAT3(normal.travs,1,1,1);
  320. IntersectContext context(scene,user_context);
  321. scene->intersect(ray,&context);
  322. RTCORE_CATCH_END(scene->device);
  323. }
  324. RTCORE_API void rtcIntersect4 (const void* valid, RTCScene hscene, RTCRay4& ray)
  325. {
  326. Scene* scene = (Scene*) hscene;
  327. RTCORE_CATCH_BEGIN;
  328. RTCORE_TRACE(rtcIntersect4);
  329. #if defined(__TARGET_SIMD4__) && defined (EMBREE_RAY_PACKETS)
  330. #if defined(DEBUG)
  331. RTCORE_VERIFY_HANDLE(hscene);
  332. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  333. if (((size_t)valid) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
  334. if (((size_t)&ray ) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  335. #endif
  336. STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
  337. STAT3(normal.travs,1,cnt,4);
  338. IntersectContext context(scene,nullptr);
  339. scene->intersect4(valid,ray,&context);
  340. #else
  341. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect4 not supported");
  342. #endif
  343. RTCORE_CATCH_END(scene->device);
  344. }
  345. RTCORE_API void rtcIntersect4Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay4& ray)
  346. {
  347. Scene* scene = (Scene*) hscene;
  348. RTCORE_CATCH_BEGIN;
  349. RTCORE_TRACE(rtcIntersect4Ex);
  350. #if defined(__TARGET_SIMD4__) && defined (EMBREE_RAY_PACKETS)
  351. #if defined(DEBUG)
  352. RTCORE_VERIFY_HANDLE(hscene);
  353. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  354. if (((size_t)valid) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
  355. if (((size_t)&ray ) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  356. #endif
  357. STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
  358. STAT3(normal.travs,1,cnt,4);
  359. IntersectContext context(scene,user_context);
  360. scene->intersect4(valid,ray,&context);
  361. #else
  362. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect4Ex not supported");
  363. #endif
  364. RTCORE_CATCH_END(scene->device);
  365. }
  366. RTCORE_API void rtcIntersect8 (const void* valid, RTCScene hscene, RTCRay8& ray)
  367. {
  368. Scene* scene = (Scene*) hscene;
  369. RTCORE_CATCH_BEGIN;
  370. RTCORE_TRACE(rtcIntersect8);
  371. #if defined(__TARGET_SIMD8__) && defined (EMBREE_RAY_PACKETS)
  372. #if defined(DEBUG)
  373. RTCORE_VERIFY_HANDLE(hscene);
  374. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  375. if (((size_t)valid) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
  376. if (((size_t)&ray ) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 32 bytes");
  377. #endif
  378. STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
  379. STAT3(normal.travs,1,cnt,8);
  380. IntersectContext context(scene,nullptr);
  381. scene->intersect8(valid,ray,&context);
  382. #else
  383. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect8 not supported");
  384. #endif
  385. RTCORE_CATCH_END(scene->device);
  386. }
  387. RTCORE_API void rtcIntersect8Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay8& ray)
  388. {
  389. Scene* scene = (Scene*) hscene;
  390. RTCORE_CATCH_BEGIN;
  391. RTCORE_TRACE(rtcIntersect8Ex);
  392. #if defined(__TARGET_SIMD8__) && defined (EMBREE_RAY_PACKETS)
  393. #if defined(DEBUG)
  394. RTCORE_VERIFY_HANDLE(hscene);
  395. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  396. if (((size_t)valid) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
  397. if (((size_t)&ray ) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 32 bytes");
  398. #endif
  399. STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
  400. STAT3(normal.travs,1,cnt,8);
  401. IntersectContext context(scene,user_context);
  402. scene->intersect8(valid,ray,&context);
  403. #else
  404. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect8Ex not supported");
  405. #endif
  406. RTCORE_CATCH_END(scene->device);
  407. }
  408. RTCORE_API void rtcIntersect16 (const void* valid, RTCScene hscene, RTCRay16& ray)
  409. {
  410. Scene* scene = (Scene*) hscene;
  411. RTCORE_CATCH_BEGIN;
  412. RTCORE_TRACE(rtcIntersect16);
  413. #if defined(__TARGET_SIMD16__) && defined (EMBREE_RAY_PACKETS)
  414. #if defined(DEBUG)
  415. RTCORE_VERIFY_HANDLE(hscene);
  416. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  417. if (((size_t)valid) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
  418. if (((size_t)&ray ) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 64 bytes");
  419. #endif
  420. STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
  421. STAT3(normal.travs,1,cnt,16);
  422. IntersectContext context(scene,nullptr);
  423. scene->intersect16(valid,ray,&context);
  424. #else
  425. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect16 not supported");
  426. #endif
  427. RTCORE_CATCH_END(scene->device);
  428. }
  429. RTCORE_API void rtcIntersect16Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay16& ray)
  430. {
  431. Scene* scene = (Scene*) hscene;
  432. RTCORE_CATCH_BEGIN;
  433. RTCORE_TRACE(rtcIntersect16Ex);
  434. #if defined(__TARGET_SIMD16__) && defined (EMBREE_RAY_PACKETS)
  435. #if defined(DEBUG)
  436. RTCORE_VERIFY_HANDLE(hscene);
  437. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  438. if (((size_t)valid) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
  439. if (((size_t)&ray ) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 64 bytes");
  440. #endif
  441. STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
  442. STAT3(normal.travs,1,cnt,16);
  443. IntersectContext context(scene,user_context);
  444. scene->intersect16(valid,ray,&context);
  445. #else
  446. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect16Ex not supported");
  447. #endif
  448. RTCORE_CATCH_END(scene->device);
  449. }
  450. RTCORE_API void rtcIntersect1M (RTCScene hscene, const RTCIntersectContext* user_context, RTCRay* rays, const size_t M, const size_t stride)
  451. {
  452. Scene* scene = (Scene*) hscene;
  453. RTCORE_CATCH_BEGIN;
  454. RTCORE_TRACE(rtcIntersect1M);
  455. #if defined (EMBREE_RAY_PACKETS)
  456. #if defined(DEBUG)
  457. RTCORE_VERIFY_HANDLE(hscene);
  458. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  459. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  460. #endif
  461. STAT3(normal.travs,M,M,M);
  462. IntersectContext context(scene,user_context);
  463. /* fast codepath for single rays */
  464. if (likely(M == 1)) {
  465. if (likely(rays->tnear <= rays->tfar))
  466. scene->intersect(*rays,&context);
  467. }
  468. /* codepath for streams */
  469. else {
  470. scene->device->rayStreamFilters.filterAOS(scene,rays,M,stride,&context,true);
  471. }
  472. #else
  473. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect1M not supported");
  474. #endif
  475. RTCORE_CATCH_END(scene->device);
  476. }
  477. RTCORE_API void rtcIntersect1Mp (RTCScene hscene, const RTCIntersectContext* user_context, RTCRay** rays, const size_t M)
  478. {
  479. Scene* scene = (Scene*) hscene;
  480. RTCORE_CATCH_BEGIN;
  481. RTCORE_TRACE(rtcIntersect1Mp);
  482. #if defined (EMBREE_RAY_PACKETS)
  483. #if defined(DEBUG)
  484. RTCORE_VERIFY_HANDLE(hscene);
  485. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  486. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  487. #endif
  488. STAT3(normal.travs,M,M,M);
  489. IntersectContext context(scene,user_context);
  490. /* fast codepath for single rays */
  491. if (likely(M == 1)) {
  492. if (likely(rays[0]->tnear <= rays[0]->tfar))
  493. scene->intersect(*rays[0],&context);
  494. }
  495. /* codepath for streams */
  496. else {
  497. scene->device->rayStreamFilters.filterAOP(scene,rays,M,&context,true);
  498. }
  499. #else
  500. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect1Mp not supported");
  501. #endif
  502. RTCORE_CATCH_END(scene->device);
  503. }
  504. RTCORE_API void rtcIntersectNM (RTCScene hscene, const RTCIntersectContext* user_context, struct RTCRayN* rays, const size_t N, const size_t M, const size_t stride)
  505. {
  506. Scene* scene = (Scene*) hscene;
  507. RTCORE_CATCH_BEGIN;
  508. RTCORE_TRACE(rtcIntersectNM);
  509. #if defined (EMBREE_RAY_PACKETS)
  510. #if defined(DEBUG)
  511. RTCORE_VERIFY_HANDLE(hscene);
  512. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  513. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  514. #endif
  515. STAT3(normal.travs,N*M,N*M,N*M);
  516. IntersectContext context(scene,user_context);
  517. /* code path for single ray streams */
  518. if (likely(N == 1))
  519. {
  520. /* fast code path for streams of size 1 */
  521. if (likely(M == 1)) {
  522. if (likely(((RTCRay*)rays)->tnear <= ((RTCRay*)rays)->tfar))
  523. scene->intersect(*(RTCRay*)rays,&context);
  524. }
  525. /* normal codepath for single ray streams */
  526. else {
  527. scene->device->rayStreamFilters.filterAOS(scene,(RTCRay*)rays,M,stride,&context,true);
  528. }
  529. }
  530. /* code path for ray packet streams */
  531. else {
  532. scene->device->rayStreamFilters.filterSOA(scene,(char*)rays,N,M,stride,&context,true);
  533. }
  534. #else
  535. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersectNM not supported");
  536. #endif
  537. RTCORE_CATCH_END(scene->device);
  538. }
  539. RTCORE_API void rtcIntersectNp (RTCScene hscene, const RTCIntersectContext* user_context, const RTCRayNp& rays, const size_t N)
  540. {
  541. Scene* scene = (Scene*) hscene;
  542. RTCORE_CATCH_BEGIN;
  543. RTCORE_TRACE(rtcIntersectNp);
  544. #if defined (EMBREE_RAY_PACKETS)
  545. #if defined(DEBUG)
  546. RTCORE_VERIFY_HANDLE(hscene);
  547. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  548. if (((size_t)rays.orgx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgx not aligned to 4 bytes");
  549. if (((size_t)rays.orgy ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgy not aligned to 4 bytes");
  550. if (((size_t)rays.orgz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgz not aligned to 4 bytes");
  551. if (((size_t)rays.dirx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirx not aligned to 4 bytes");
  552. if (((size_t)rays.diry ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.diry not aligned to 4 bytes");
  553. if (((size_t)rays.dirz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirz not aligned to 4 bytes");
  554. if (((size_t)rays.tnear ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirx not aligned to 4 bytes");
  555. if (((size_t)rays.tfar ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.tnear not aligned to 4 bytes");
  556. if (((size_t)rays.time ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.time not aligned to 4 bytes");
  557. if (((size_t)rays.mask ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.mask not aligned to 4 bytes");
  558. if (((size_t)rays.Ngx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngx not aligned to 4 bytes");
  559. if (((size_t)rays.Ngy ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngy not aligned to 4 bytes");
  560. if (((size_t)rays.Ngz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngz not aligned to 4 bytes");
  561. if (((size_t)rays.u ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.u not aligned to 4 bytes");
  562. if (((size_t)rays.v ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.v not aligned to 4 bytes");
  563. if (((size_t)rays.geomID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.geomID not aligned to 4 bytes");
  564. if (((size_t)rays.primID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.primID not aligned to 4 bytes");
  565. if (((size_t)rays.instID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.instID not aligned to 4 bytes");
  566. #endif
  567. STAT3(normal.travs,N,N,N);
  568. IntersectContext context(scene,user_context);
  569. scene->device->rayStreamFilters.filterSOP(scene,rays,N,&context,true);
  570. #else
  571. throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersectNp not supported");
  572. #endif
  573. RTCORE_CATCH_END(scene->device);
  574. }
  575. RTCORE_API void rtcOccluded (RTCScene hscene, RTCRay& ray)
  576. {
  577. Scene* scene = (Scene*) hscene;
  578. RTCORE_CATCH_BEGIN;
  579. RTCORE_TRACE(rtcOccluded);
  580. STAT3(shadow.travs,1,1,1);
  581. #if defined(DEBUG)
  582. RTCORE_VERIFY_HANDLE(hscene);
  583. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  584. if (((size_t)&ray) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  585. #endif
  586. IntersectContext context(scene,nullptr);
  587. scene->occluded(ray,&context);
  588. RTCORE_CATCH_END(scene->device);
  589. }
  590. RTCORE_API void rtcOccluded1Ex (RTCScene hscene, const RTCIntersectContext* user_context, RTCRay& ray)
  591. {
  592. Scene* scene = (Scene*) hscene;
  593. RTCORE_CATCH_BEGIN;
  594. RTCORE_TRACE(rtcOccluded1Ex);
  595. STAT3(shadow.travs,1,1,1);
  596. #if defined(DEBUG)
  597. RTCORE_VERIFY_HANDLE(hscene);
  598. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  599. if (((size_t)&ray) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  600. #endif
  601. IntersectContext context(scene,user_context);
  602. scene->occluded(ray,&context);
  603. RTCORE_CATCH_END(scene->device);
  604. }
  605. RTCORE_API void rtcOccluded4 (const void* valid, RTCScene hscene, RTCRay4& ray)
  606. {
  607. Scene* scene = (Scene*) hscene;
  608. RTCORE_CATCH_BEGIN;
  609. RTCORE_TRACE(rtcOccluded4);
  610. #if defined(__TARGET_SIMD4__) && defined (EMBREE_RAY_PACKETS)
  611. #if defined(DEBUG)
  612. RTCORE_VERIFY_HANDLE(hscene);
  613. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  614. if (((size_t)valid) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
  615. if (((size_t)&ray ) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  616. #endif
  617. STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
  618. STAT3(shadow.travs,1,cnt,4);
  619. IntersectContext context(scene,nullptr);
  620. scene->occluded4(valid,ray,&context);
  621. #else
  622. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded4 not supported");
  623. #endif
  624. RTCORE_CATCH_END(scene->device);
  625. }
  626. RTCORE_API void rtcOccluded4Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay4& ray)
  627. {
  628. Scene* scene = (Scene*) hscene;
  629. RTCORE_CATCH_BEGIN;
  630. RTCORE_TRACE(rtcOccluded4Ex);
  631. #if defined(__TARGET_SIMD4__) && defined (EMBREE_RAY_PACKETS)
  632. #if defined(DEBUG)
  633. RTCORE_VERIFY_HANDLE(hscene);
  634. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  635. if (((size_t)valid) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 16 bytes");
  636. if (((size_t)&ray ) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes");
  637. #endif
  638. STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
  639. STAT3(shadow.travs,1,cnt,4);
  640. IntersectContext context(scene,user_context);
  641. scene->occluded4(valid,ray,&context);
  642. #else
  643. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded4Ex not supported");
  644. #endif
  645. RTCORE_CATCH_END(scene->device);
  646. }
  647. RTCORE_API void rtcOccluded8 (const void* valid, RTCScene hscene, RTCRay8& ray)
  648. {
  649. Scene* scene = (Scene*) hscene;
  650. RTCORE_CATCH_BEGIN;
  651. RTCORE_TRACE(rtcOccluded8);
  652. #if defined(__TARGET_SIMD8__) && defined (EMBREE_RAY_PACKETS)
  653. #if defined(DEBUG)
  654. RTCORE_VERIFY_HANDLE(hscene);
  655. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  656. if (((size_t)valid) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
  657. if (((size_t)&ray ) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 32 bytes");
  658. #endif
  659. STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
  660. STAT3(shadow.travs,1,cnt,8);
  661. IntersectContext context(scene,nullptr);
  662. scene->occluded8(valid,ray,&context);
  663. #else
  664. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded8 not supported");
  665. #endif
  666. RTCORE_CATCH_END(scene->device);
  667. }
  668. RTCORE_API void rtcOccluded8Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay8& ray)
  669. {
  670. Scene* scene = (Scene*) hscene;
  671. RTCORE_CATCH_BEGIN;
  672. RTCORE_TRACE(rtcOccluded8Ex);
  673. #if defined(__TARGET_SIMD8__) && defined (EMBREE_RAY_PACKETS)
  674. #if defined(DEBUG)
  675. RTCORE_VERIFY_HANDLE(hscene);
  676. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  677. if (((size_t)valid) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 32 bytes");
  678. if (((size_t)&ray ) & 0x1F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 32 bytes");
  679. #endif
  680. STAT(size_t cnt=0; for (size_t i=0; i<8; i++) cnt += ((int*)valid)[i] == -1;);
  681. STAT3(shadow.travs,1,cnt,8);
  682. IntersectContext context(scene,user_context);
  683. scene->occluded8(valid,ray,&context);
  684. #else
  685. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded8Ex not supported");
  686. #endif
  687. RTCORE_CATCH_END(scene->device);
  688. }
  689. RTCORE_API void rtcOccluded16 (const void* valid, RTCScene hscene, RTCRay16& ray)
  690. {
  691. Scene* scene = (Scene*) hscene;
  692. RTCORE_CATCH_BEGIN;
  693. RTCORE_TRACE(rtcOccluded16);
  694. #if defined(__TARGET_SIMD16__) && defined (EMBREE_RAY_PACKETS)
  695. #if defined(DEBUG)
  696. RTCORE_VERIFY_HANDLE(hscene);
  697. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  698. if (((size_t)valid) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
  699. if (((size_t)&ray ) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 64 bytes");
  700. #endif
  701. STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
  702. STAT3(shadow.travs,1,cnt,16);
  703. IntersectContext context(scene,nullptr);
  704. scene->occluded16(valid,ray,&context);
  705. #else
  706. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded16 not supported");
  707. #endif
  708. RTCORE_CATCH_END(scene->device);
  709. }
  710. RTCORE_API void rtcOccluded16Ex (const void* valid, RTCScene hscene, const RTCIntersectContext* user_context, RTCRay16& ray)
  711. {
  712. Scene* scene = (Scene*) hscene;
  713. RTCORE_CATCH_BEGIN;
  714. RTCORE_TRACE(rtcOccluded16Ex);
  715. #if defined(__TARGET_SIMD16__) && defined (EMBREE_RAY_PACKETS)
  716. #if defined(DEBUG)
  717. RTCORE_VERIFY_HANDLE(hscene);
  718. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  719. if (((size_t)valid) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 64 bytes");
  720. if (((size_t)&ray ) & 0x3F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 64 bytes");
  721. #endif
  722. STAT(size_t cnt=0; for (size_t i=0; i<16; i++) cnt += ((int*)valid)[i] == -1;);
  723. STAT3(shadow.travs,1,cnt,16);
  724. IntersectContext context(scene,user_context);
  725. scene->occluded16(valid,ray,&context);
  726. #else
  727. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded16Ex not supported");
  728. #endif
  729. RTCORE_CATCH_END(scene->device);
  730. }
  731. RTCORE_API void rtcOccluded1M(RTCScene hscene, const RTCIntersectContext* user_context, RTCRay* rays, const size_t M, const size_t stride)
  732. {
  733. Scene* scene = (Scene*) hscene;
  734. RTCORE_CATCH_BEGIN;
  735. RTCORE_TRACE(rtcOccluded1M);
  736. #if defined (EMBREE_RAY_PACKETS)
  737. #if defined(DEBUG)
  738. RTCORE_VERIFY_HANDLE(hscene);
  739. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  740. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  741. #endif
  742. STAT3(shadow.travs,M,M,M);
  743. IntersectContext context(scene,user_context);
  744. /* fast codepath for streams of size 1 */
  745. if (likely(M == 1)) {
  746. if (likely(rays->tnear <= rays->tfar))
  747. scene->occluded (*rays,&context);
  748. }
  749. /* codepath for normal streams */
  750. else {
  751. scene->device->rayStreamFilters.filterAOS(scene,rays,M,stride,&context,false);
  752. }
  753. #else
  754. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded1M not supported");
  755. #endif
  756. RTCORE_CATCH_END(scene->device);
  757. }
  758. RTCORE_API void rtcOccluded1Mp(RTCScene hscene, const RTCIntersectContext* user_context, RTCRay** rays, const size_t M)
  759. {
  760. Scene* scene = (Scene*) hscene;
  761. RTCORE_CATCH_BEGIN;
  762. RTCORE_TRACE(rtcOccluded1Mp);
  763. #if defined (EMBREE_RAY_PACKETS)
  764. #if defined(DEBUG)
  765. RTCORE_VERIFY_HANDLE(hscene);
  766. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  767. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  768. #endif
  769. STAT3(shadow.travs,M,M,M);
  770. IntersectContext context(scene,user_context);
  771. /* fast codepath for streams of size 1 */
  772. if (likely(M == 1)) {
  773. if (likely(rays[0]->tnear <= rays[0]->tfar))
  774. scene->occluded (*rays[0],&context);
  775. }
  776. /* codepath for normal streams */
  777. else {
  778. scene->device->rayStreamFilters.filterAOP(scene,rays,M,&context,false);
  779. }
  780. #else
  781. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccluded1Mp not supported");
  782. #endif
  783. RTCORE_CATCH_END(scene->device);
  784. }
  785. RTCORE_API void rtcOccludedNM(RTCScene hscene, const RTCIntersectContext* user_context, RTCRayN* rays, const size_t N, const size_t M, const size_t stride)
  786. {
  787. Scene* scene = (Scene*) hscene;
  788. RTCORE_CATCH_BEGIN;
  789. RTCORE_TRACE(rtcOccludedNM);
  790. #if defined (EMBREE_RAY_PACKETS)
  791. #if defined(DEBUG)
  792. RTCORE_VERIFY_HANDLE(hscene);
  793. if (stride < sizeof(RTCRay)) throw_RTCError(RTC_INVALID_OPERATION,"stride too small");
  794. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  795. if (((size_t)rays ) & 0x03) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 4 bytes");
  796. #endif
  797. STAT3(shadow.travs,N*M,N*N,N*N);
  798. IntersectContext context(scene,user_context);
  799. /* codepath for single rays */
  800. if (likely(N == 1))
  801. {
  802. /* fast path for streams of size 1 */
  803. if (likely(M == 1)) {
  804. if (likely(((RTCRay*)rays)->tnear <= ((RTCRay*)rays)->tfar))
  805. scene->occluded (*(RTCRay*)rays,&context);
  806. }
  807. /* codepath for normal ray streams */
  808. else {
  809. scene->device->rayStreamFilters.filterAOS(scene,(RTCRay*)rays,M,stride,&context,false);
  810. }
  811. }
  812. /* code path for ray packet streams */
  813. else {
  814. scene->device->rayStreamFilters.filterSOA(scene,(char*)rays,N,M,stride,&context,false);
  815. }
  816. #else
  817. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccludedNM not supported");
  818. #endif
  819. RTCORE_CATCH_END(scene->device);
  820. }
  821. RTCORE_API void rtcOccludedNp(RTCScene hscene, const RTCIntersectContext* user_context, const RTCRayNp& rays, const size_t N)
  822. {
  823. Scene* scene = (Scene*) hscene;
  824. RTCORE_CATCH_BEGIN;
  825. RTCORE_TRACE(rtcOccludedNp);
  826. #if defined (EMBREE_RAY_PACKETS)
  827. #if defined(DEBUG)
  828. RTCORE_VERIFY_HANDLE(hscene);
  829. if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed");
  830. if (((size_t)rays.orgx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgx not aligned to 4 bytes");
  831. if (((size_t)rays.orgy ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgy not aligned to 4 bytes");
  832. if (((size_t)rays.orgz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.orgz not aligned to 4 bytes");
  833. if (((size_t)rays.dirx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirx not aligned to 4 bytes");
  834. if (((size_t)rays.diry ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.diry not aligned to 4 bytes");
  835. if (((size_t)rays.dirz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirz not aligned to 4 bytes");
  836. if (((size_t)rays.tnear ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.dirx not aligned to 4 bytes");
  837. if (((size_t)rays.tfar ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.tnear not aligned to 4 bytes");
  838. if (((size_t)rays.time ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.time not aligned to 4 bytes");
  839. if (((size_t)rays.mask ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.mask not aligned to 4 bytes");
  840. if (((size_t)rays.Ngx ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngx not aligned to 4 bytes");
  841. if (((size_t)rays.Ngy ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngy not aligned to 4 bytes");
  842. if (((size_t)rays.Ngz ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.Ngz not aligned to 4 bytes");
  843. if (((size_t)rays.u ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.u not aligned to 4 bytes");
  844. if (((size_t)rays.v ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.v not aligned to 4 bytes");
  845. if (((size_t)rays.geomID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.geomID not aligned to 4 bytes");
  846. if (((size_t)rays.primID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.primID not aligned to 4 bytes");
  847. if (((size_t)rays.instID ) & 0x03 ) throw_RTCError(RTC_INVALID_ARGUMENT, "rays.instID not aligned to 4 bytes");
  848. #endif
  849. STAT3(shadow.travs,N,N,N);
  850. IntersectContext context(scene,user_context);
  851. scene->device->rayStreamFilters.filterSOP(scene,rays,N,&context,false);
  852. #else
  853. throw_RTCError(RTC_INVALID_OPERATION,"rtcOccludedNp not supported");
  854. #endif
  855. RTCORE_CATCH_END(scene->device);
  856. }
  857. RTCORE_API void rtcDeleteScene (RTCScene hscene)
  858. {
  859. Scene* scene = (Scene*) hscene;
  860. Device* device = scene ? scene->device : nullptr;
  861. RTCORE_CATCH_BEGIN;
  862. RTCORE_TRACE(rtcDeleteScene);
  863. RTCORE_VERIFY_HANDLE(hscene);
  864. delete scene;
  865. RTCORE_CATCH_END(device);
  866. }
  867. RTCORE_API unsigned rtcNewInstance (RTCScene htarget, RTCScene hsource)
  868. {
  869. Scene* target = (Scene*) htarget;
  870. RTCORE_CATCH_BEGIN;
  871. RTCORE_TRACE(rtcNewInstance);
  872. RTCORE_VERIFY_HANDLE(htarget);
  873. RTCORE_VERIFY_HANDLE(hsource);
  874. #if defined(EMBREE_GEOMETRY_USER)
  875. Scene* source = (Scene*) hsource;
  876. if (target->device != source->device) throw_RTCError(RTC_INVALID_OPERATION,"scenes do not belong to the same device");
  877. return target->newInstance(source,1);
  878. #else
  879. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewInstance is not supported");
  880. #endif
  881. RTCORE_CATCH_END(target->device);
  882. return -1;
  883. }
  884. RTCORE_API unsigned rtcNewInstance2 (RTCScene htarget, RTCScene hsource, size_t numTimeSteps)
  885. {
  886. Scene* target = (Scene*) htarget;
  887. Scene* source = (Scene*) hsource;
  888. RTCORE_CATCH_BEGIN;
  889. RTCORE_TRACE(rtcNewInstance2);
  890. RTCORE_VERIFY_HANDLE(htarget);
  891. RTCORE_VERIFY_HANDLE(hsource);
  892. #if defined(EMBREE_GEOMETRY_USER)
  893. if (target->device != source->device) throw_RTCError(RTC_INVALID_OPERATION,"scenes do not belong to the same device");
  894. return target->newInstance(source,numTimeSteps);
  895. #else
  896. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewInstance2 is not supported");
  897. #endif
  898. RTCORE_CATCH_END(target->device);
  899. return -1;
  900. }
  901. AffineSpace3fa convertTransform(RTCMatrixType layout, const float* xfm)
  902. {
  903. AffineSpace3fa transform = one;
  904. switch (layout)
  905. {
  906. case RTC_MATRIX_ROW_MAJOR:
  907. transform = AffineSpace3fa(Vec3fa(xfm[ 0],xfm[ 4],xfm[ 8]),
  908. Vec3fa(xfm[ 1],xfm[ 5],xfm[ 9]),
  909. Vec3fa(xfm[ 2],xfm[ 6],xfm[10]),
  910. Vec3fa(xfm[ 3],xfm[ 7],xfm[11]));
  911. break;
  912. case RTC_MATRIX_COLUMN_MAJOR:
  913. transform = AffineSpace3fa(Vec3fa(xfm[ 0],xfm[ 1],xfm[ 2]),
  914. Vec3fa(xfm[ 3],xfm[ 4],xfm[ 5]),
  915. Vec3fa(xfm[ 6],xfm[ 7],xfm[ 8]),
  916. Vec3fa(xfm[ 9],xfm[10],xfm[11]));
  917. break;
  918. case RTC_MATRIX_COLUMN_MAJOR_ALIGNED16:
  919. transform = AffineSpace3fa(Vec3fa(xfm[ 0],xfm[ 1],xfm[ 2]),
  920. Vec3fa(xfm[ 4],xfm[ 5],xfm[ 6]),
  921. Vec3fa(xfm[ 8],xfm[ 9],xfm[10]),
  922. Vec3fa(xfm[12],xfm[13],xfm[14]));
  923. break;
  924. default:
  925. throw_RTCError(RTC_INVALID_OPERATION,"Unknown matrix type");
  926. break;
  927. }
  928. return transform;
  929. }
  930. RTCORE_API void rtcSetTransform (RTCScene hscene, unsigned geomID, RTCMatrixType layout, const float* xfm)
  931. {
  932. Scene* scene = (Scene*) hscene;
  933. RTCORE_CATCH_BEGIN;
  934. RTCORE_TRACE(rtcSetTransform);
  935. RTCORE_VERIFY_HANDLE(hscene);
  936. RTCORE_VERIFY_GEOMID(geomID);
  937. RTCORE_VERIFY_HANDLE(xfm);
  938. const AffineSpace3fa transform = convertTransform(layout,xfm);
  939. ((Scene*) scene)->get_locked(geomID)->setTransform(transform,0);
  940. RTCORE_CATCH_END(scene->device);
  941. }
  942. RTCORE_API void rtcSetTransform2 (RTCScene hscene, unsigned geomID, RTCMatrixType layout, const float* xfm, size_t timeStep)
  943. {
  944. Scene* scene = (Scene*) hscene;
  945. RTCORE_CATCH_BEGIN;
  946. RTCORE_TRACE(rtcSetTransform);
  947. RTCORE_VERIFY_HANDLE(hscene);
  948. RTCORE_VERIFY_GEOMID(geomID);
  949. RTCORE_VERIFY_HANDLE(xfm);
  950. const AffineSpace3fa transform = convertTransform(layout,xfm);
  951. ((Scene*) scene)->get_locked(geomID)->setTransform(transform,timeStep);
  952. RTCORE_CATCH_END(scene->device);
  953. }
  954. RTCORE_API unsigned rtcNewUserGeometry (RTCScene hscene, size_t numItems)
  955. {
  956. Scene* scene = (Scene*) hscene;
  957. RTCORE_CATCH_BEGIN;
  958. RTCORE_TRACE(rtcNewUserGeometry);
  959. RTCORE_VERIFY_HANDLE(hscene);
  960. #if defined(EMBREE_GEOMETRY_USER)
  961. return scene->newUserGeometry(RTC_GEOMETRY_STATIC,numItems,1);
  962. #else
  963. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewUserGeometry is not supported");
  964. #endif
  965. RTCORE_CATCH_END(scene->device);
  966. return -1;
  967. }
  968. RTCORE_API unsigned rtcNewUserGeometry2 (RTCScene hscene, size_t numItems, size_t numTimeSteps)
  969. {
  970. Scene* scene = (Scene*) hscene;
  971. RTCORE_CATCH_BEGIN;
  972. RTCORE_TRACE(rtcNewUserGeometry2);
  973. RTCORE_VERIFY_HANDLE(hscene);
  974. #if defined(EMBREE_GEOMETRY_USER)
  975. return scene->newUserGeometry(RTC_GEOMETRY_STATIC,numItems,numTimeSteps);
  976. #else
  977. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewUserGeometry2 is not supported");
  978. #endif
  979. RTCORE_CATCH_END(scene->device);
  980. return -1;
  981. }
  982. RTCORE_API unsigned rtcNewUserGeometry3 (RTCScene hscene, RTCGeometryFlags gflags, size_t numItems, size_t numTimeSteps)
  983. {
  984. Scene* scene = (Scene*) hscene;
  985. RTCORE_CATCH_BEGIN;
  986. RTCORE_TRACE(rtcNewUserGeometry2);
  987. RTCORE_VERIFY_HANDLE(hscene);
  988. #if defined(EMBREE_GEOMETRY_USER)
  989. return scene->newUserGeometry(gflags,numItems,numTimeSteps);
  990. #else
  991. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewUserGeometry3 is not supported");
  992. #endif
  993. RTCORE_CATCH_END(scene->device);
  994. return -1;
  995. }
  996. RTCORE_API unsigned rtcNewTriangleMesh (RTCScene hscene, RTCGeometryFlags flags, size_t numTriangles, size_t numVertices, size_t numTimeSteps)
  997. {
  998. Scene* scene = (Scene*) hscene;
  999. RTCORE_CATCH_BEGIN;
  1000. RTCORE_TRACE(rtcNewTriangleMesh);
  1001. RTCORE_VERIFY_HANDLE(hscene);
  1002. #if defined(EMBREE_GEOMETRY_TRIANGLES)
  1003. return scene->newTriangleMesh(flags,numTriangles,numVertices,numTimeSteps);
  1004. #else
  1005. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewTriangleMesh is not supported");
  1006. #endif
  1007. RTCORE_CATCH_END(scene->device);
  1008. return -1;
  1009. }
  1010. RTCORE_API unsigned rtcNewQuadMesh (RTCScene hscene, RTCGeometryFlags flags, size_t numQuads, size_t numVertices, size_t numTimeSteps)
  1011. {
  1012. Scene* scene = (Scene*) hscene;
  1013. RTCORE_CATCH_BEGIN;
  1014. RTCORE_TRACE(rtcNewQuadMesh);
  1015. RTCORE_VERIFY_HANDLE(hscene);
  1016. #if defined(EMBREE_GEOMETRY_QUADS)
  1017. return scene->newQuadMesh(flags,numQuads,numVertices,numTimeSteps);
  1018. #else
  1019. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewQuadMesh is not supported");
  1020. #endif
  1021. RTCORE_CATCH_END(scene->device);
  1022. return -1;
  1023. }
  1024. RTCORE_API unsigned rtcNewHairGeometry (RTCScene hscene, RTCGeometryFlags flags, size_t numCurves, size_t numVertices, size_t numTimeSteps)
  1025. {
  1026. Scene* scene = (Scene*) hscene;
  1027. RTCORE_CATCH_BEGIN;
  1028. RTCORE_TRACE(rtcNewHairGeometry);
  1029. RTCORE_VERIFY_HANDLE(hscene);
  1030. #if defined(EMBREE_GEOMETRY_HAIR)
  1031. return scene->newCurves(NativeCurves::HAIR,NativeCurves::BEZIER,flags,numCurves,numVertices,numTimeSteps);
  1032. #else
  1033. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewHairGeometry is not supported");
  1034. #endif
  1035. RTCORE_CATCH_END(scene->device);
  1036. return -1;
  1037. }
  1038. RTCORE_API unsigned rtcNewBezierHairGeometry (RTCScene hscene, RTCGeometryFlags flags, unsigned int numCurves, unsigned int numVertices, unsigned int numTimeSteps)
  1039. {
  1040. Scene* scene = (Scene*) hscene;
  1041. RTCORE_CATCH_BEGIN;
  1042. RTCORE_TRACE(rtcNewBezierHairGeometry);
  1043. RTCORE_VERIFY_HANDLE(hscene);
  1044. #if defined(EMBREE_GEOMETRY_HAIR)
  1045. return scene->newCurves(NativeCurves::HAIR,NativeCurves::BEZIER,flags,numCurves,numVertices,numTimeSteps);
  1046. #else
  1047. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewBezierHairGeometry is not supported");
  1048. #endif
  1049. RTCORE_CATCH_END(scene->device);
  1050. return -1;
  1051. }
  1052. RTCORE_API unsigned rtcNewBSplineHairGeometry (RTCScene hscene, RTCGeometryFlags flags, unsigned int numCurves, unsigned int numVertices, unsigned int numTimeSteps)
  1053. {
  1054. Scene* scene = (Scene*) hscene;
  1055. RTCORE_CATCH_BEGIN;
  1056. RTCORE_TRACE(rtcNewBSplineHairGeometry);
  1057. RTCORE_VERIFY_HANDLE(hscene);
  1058. #if defined(EMBREE_GEOMETRY_HAIR)
  1059. return scene->newCurves(NativeCurves::HAIR,NativeCurves::BSPLINE,flags,numCurves,numVertices,numTimeSteps);
  1060. #else
  1061. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewBSplineHairGeometry is not supported");
  1062. #endif
  1063. RTCORE_CATCH_END(scene->device);
  1064. return -1;
  1065. }
  1066. RTCORE_API unsigned rtcNewCurveGeometry (RTCScene hscene, RTCGeometryFlags flags, size_t numCurves, size_t numVertices, size_t numTimeSteps)
  1067. {
  1068. Scene* scene = (Scene*) hscene;
  1069. RTCORE_CATCH_BEGIN;
  1070. RTCORE_TRACE(rtcNewCurveGeometry);
  1071. RTCORE_VERIFY_HANDLE(hscene);
  1072. #if defined(EMBREE_GEOMETRY_HAIR)
  1073. return scene->newCurves(NativeCurves::SURFACE,NativeCurves::BEZIER,flags,numCurves,numVertices,numTimeSteps);
  1074. #else
  1075. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewCurveGeometry is not supported");
  1076. #endif
  1077. RTCORE_CATCH_END(scene->device);
  1078. return -1;
  1079. }
  1080. RTCORE_API unsigned rtcNewBezierCurveGeometry (RTCScene hscene, RTCGeometryFlags flags, unsigned int numCurves, unsigned int numVertices, unsigned int numTimeSteps)
  1081. {
  1082. Scene* scene = (Scene*) hscene;
  1083. RTCORE_CATCH_BEGIN;
  1084. RTCORE_TRACE(rtcNewBezierCurveGeometry);
  1085. RTCORE_VERIFY_HANDLE(hscene);
  1086. #if defined(EMBREE_GEOMETRY_HAIR)
  1087. return scene->newCurves(NativeCurves::SURFACE,NativeCurves::BEZIER,flags,numCurves,numVertices,numTimeSteps);
  1088. #else
  1089. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewBezierCurveGeometry is not supported");
  1090. #endif
  1091. RTCORE_CATCH_END(scene->device);
  1092. return -1;
  1093. }
  1094. RTCORE_API unsigned rtcNewBSplineCurveGeometry (RTCScene hscene, RTCGeometryFlags flags, unsigned int numCurves, unsigned int numVertices, unsigned int numTimeSteps)
  1095. {
  1096. Scene* scene = (Scene*) hscene;
  1097. RTCORE_CATCH_BEGIN;
  1098. RTCORE_TRACE(rtcNewBSplineCurveGeometry);
  1099. RTCORE_VERIFY_HANDLE(hscene);
  1100. #if defined(EMBREE_GEOMETRY_HAIR)
  1101. return scene->newCurves(NativeCurves::SURFACE,NativeCurves::BSPLINE,flags,numCurves,numVertices,numTimeSteps);
  1102. #else
  1103. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewBSplineCurveGeometry is not supported");
  1104. #endif
  1105. RTCORE_CATCH_END(scene->device);
  1106. return -1;
  1107. }
  1108. RTCORE_API unsigned rtcNewLineSegments (RTCScene hscene, RTCGeometryFlags flags, size_t numSegments, size_t numVertices, size_t numTimeSteps)
  1109. {
  1110. Scene* scene = (Scene*) hscene;
  1111. RTCORE_CATCH_BEGIN;
  1112. RTCORE_TRACE(rtcNewLineSegments);
  1113. RTCORE_VERIFY_HANDLE(hscene);
  1114. #if defined(EMBREE_GEOMETRY_LINES)
  1115. return scene->newLineSegments(flags,numSegments,numVertices,numTimeSteps);
  1116. #else
  1117. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewLineSegments is not supported");
  1118. #endif
  1119. RTCORE_CATCH_END(scene->device);
  1120. return -1;
  1121. }
  1122. RTCORE_API unsigned rtcNewSubdivisionMesh (RTCScene hscene, RTCGeometryFlags flags, size_t numFaces, size_t numEdges, size_t numVertices,
  1123. size_t numEdgeCreases, size_t numVertexCreases, size_t numHoles, size_t numTimeSteps)
  1124. {
  1125. Scene* scene = (Scene*) hscene;
  1126. RTCORE_CATCH_BEGIN;
  1127. RTCORE_TRACE(rtcNewSubdivisionMesh);
  1128. RTCORE_VERIFY_HANDLE(hscene);
  1129. #if defined(EMBREE_GEOMETRY_SUBDIV)
  1130. return scene->newSubdivisionMesh(flags,numFaces,numEdges,numVertices,numEdgeCreases,numVertexCreases,numHoles,numTimeSteps);
  1131. #else
  1132. throw_RTCError(RTC_UNKNOWN_ERROR,"rtcNewSubdivisionMesh is not supported");
  1133. #endif
  1134. RTCORE_CATCH_END(scene->device);
  1135. return -1;
  1136. }
  1137. RTCORE_API void rtcSetMask (RTCScene hscene, unsigned geomID, int mask)
  1138. {
  1139. Scene* scene = (Scene*) hscene;
  1140. RTCORE_CATCH_BEGIN;
  1141. RTCORE_TRACE(rtcSetMask);
  1142. RTCORE_VERIFY_HANDLE(hscene);
  1143. RTCORE_VERIFY_GEOMID(geomID);
  1144. scene->get_locked(geomID)->setMask(mask);
  1145. RTCORE_CATCH_END(scene->device);
  1146. }
  1147. RTCORE_API void rtcSetBoundaryMode (RTCScene hscene, unsigned geomID, RTCBoundaryMode mode)
  1148. {
  1149. Scene* scene = (Scene*) hscene;
  1150. RTCORE_CATCH_BEGIN;
  1151. RTCORE_TRACE(rtcSetBoundaryMode);
  1152. RTCORE_VERIFY_HANDLE(hscene);
  1153. RTCORE_VERIFY_GEOMID(geomID);
  1154. scene->get_locked(geomID)->setSubdivisionMode(0,(RTCSubdivisionMode)mode);
  1155. RTCORE_CATCH_END(scene->device);
  1156. }
  1157. RTCORE_API void rtcSetSubdivisionMode (RTCScene hscene, unsigned geomID, unsigned topologyID, RTCSubdivisionMode mode)
  1158. {
  1159. Scene* scene = (Scene*) hscene;
  1160. RTCORE_CATCH_BEGIN;
  1161. RTCORE_TRACE(rtcSetSubdivisionMode);
  1162. RTCORE_VERIFY_HANDLE(hscene);
  1163. RTCORE_VERIFY_GEOMID(geomID);
  1164. scene->get_locked(geomID)->setSubdivisionMode(topologyID,mode);
  1165. RTCORE_CATCH_END(scene->device);
  1166. }
  1167. RTCORE_API void rtcSetIndexBuffer (RTCScene hscene, unsigned geomID, RTCBufferType vertexBuffer, RTCBufferType indexBuffer)
  1168. {
  1169. Scene* scene = (Scene*) hscene;
  1170. RTCORE_CATCH_BEGIN;
  1171. RTCORE_TRACE(rtcSetIndexBuffer);
  1172. RTCORE_VERIFY_HANDLE(hscene);
  1173. RTCORE_VERIFY_GEOMID(geomID);
  1174. scene->get_locked(geomID)->setIndexBuffer(vertexBuffer,indexBuffer);
  1175. RTCORE_CATCH_END(scene->device);
  1176. }
  1177. RTCORE_API void* rtcMapBuffer(RTCScene hscene, unsigned geomID, RTCBufferType type)
  1178. {
  1179. Scene* scene = (Scene*) hscene;
  1180. RTCORE_CATCH_BEGIN;
  1181. RTCORE_TRACE(rtcMapBuffer);
  1182. RTCORE_VERIFY_HANDLE(hscene);
  1183. RTCORE_VERIFY_GEOMID(geomID);
  1184. return scene->get_locked(geomID)->map(type);
  1185. RTCORE_CATCH_END(scene->device);
  1186. return nullptr;
  1187. }
  1188. RTCORE_API void rtcUnmapBuffer(RTCScene hscene, unsigned geomID, RTCBufferType type)
  1189. {
  1190. Scene* scene = (Scene*) hscene;
  1191. RTCORE_CATCH_BEGIN;
  1192. RTCORE_TRACE(rtcUnmapBuffer);
  1193. RTCORE_VERIFY_HANDLE(hscene);
  1194. RTCORE_VERIFY_GEOMID(geomID);
  1195. scene->get_locked(geomID)->unmap(type);
  1196. RTCORE_CATCH_END(scene->device);
  1197. }
  1198. RTCORE_API void rtcSetBuffer(RTCScene hscene, unsigned geomID, RTCBufferType type, const void* ptr, size_t offset, size_t stride)
  1199. {
  1200. Scene* scene = (Scene*) hscene;
  1201. RTCORE_CATCH_BEGIN;
  1202. RTCORE_TRACE(rtcSetBuffer);
  1203. RTCORE_VERIFY_HANDLE(hscene);
  1204. RTCORE_VERIFY_GEOMID(geomID);
  1205. scene->get_locked(geomID)->setBuffer(type,(void*)ptr,offset,stride,-1);
  1206. RTCORE_CATCH_END(scene->device);
  1207. }
  1208. RTCORE_API void rtcSetBuffer2(RTCScene hscene, unsigned geomID, RTCBufferType type, const void* ptr, size_t offset, size_t stride, size_t size)
  1209. {
  1210. Scene* scene = (Scene*) hscene;
  1211. RTCORE_CATCH_BEGIN;
  1212. RTCORE_TRACE(rtcSetBuffer2);
  1213. RTCORE_VERIFY_HANDLE(hscene);
  1214. RTCORE_VERIFY_GEOMID(geomID);
  1215. scene->get_locked(geomID)->setBuffer(type,(void*)ptr,offset,stride,size);
  1216. RTCORE_CATCH_END(scene->device);
  1217. }
  1218. RTCORE_API void rtcEnable (RTCScene hscene, unsigned geomID)
  1219. {
  1220. Scene* scene = (Scene*) hscene;
  1221. RTCORE_CATCH_BEGIN;
  1222. RTCORE_TRACE(rtcEnable);
  1223. RTCORE_VERIFY_HANDLE(hscene);
  1224. RTCORE_VERIFY_GEOMID(geomID);
  1225. scene->get_locked(geomID)->enable();
  1226. RTCORE_CATCH_END(scene->device);
  1227. }
  1228. RTCORE_API void rtcUpdate (RTCScene hscene, unsigned geomID)
  1229. {
  1230. Scene* scene = (Scene*) hscene;
  1231. RTCORE_CATCH_BEGIN;
  1232. RTCORE_TRACE(rtcUpdate);
  1233. RTCORE_VERIFY_HANDLE(hscene);
  1234. RTCORE_VERIFY_GEOMID(geomID);
  1235. scene->get_locked(geomID)->update();
  1236. RTCORE_CATCH_END(scene->device);
  1237. }
  1238. RTCORE_API void rtcUpdateBuffer (RTCScene hscene, unsigned geomID, RTCBufferType type)
  1239. {
  1240. Scene* scene = (Scene*) hscene;
  1241. RTCORE_CATCH_BEGIN;
  1242. RTCORE_TRACE(rtcUpdateBuffer);
  1243. RTCORE_VERIFY_HANDLE(hscene);
  1244. RTCORE_VERIFY_GEOMID(geomID);
  1245. scene->get_locked(geomID)->updateBuffer(type);
  1246. RTCORE_CATCH_END(scene->device);
  1247. }
  1248. RTCORE_API void rtcDisable (RTCScene hscene, unsigned geomID)
  1249. {
  1250. Scene* scene = (Scene*) hscene;
  1251. RTCORE_CATCH_BEGIN;
  1252. RTCORE_TRACE(rtcDisable);
  1253. RTCORE_VERIFY_HANDLE(hscene);
  1254. RTCORE_VERIFY_GEOMID(geomID);
  1255. scene->get_locked(geomID)->disable();
  1256. RTCORE_CATCH_END(scene->device);
  1257. }
  1258. RTCORE_API void rtcDeleteGeometry (RTCScene hscene, unsigned geomID)
  1259. {
  1260. Scene* scene = (Scene*) hscene;
  1261. RTCORE_CATCH_BEGIN;
  1262. RTCORE_TRACE(rtcDeleteGeometry);
  1263. RTCORE_VERIFY_HANDLE(hscene);
  1264. RTCORE_VERIFY_GEOMID(geomID);
  1265. scene->deleteGeometry(geomID);
  1266. RTCORE_CATCH_END(scene->device);
  1267. }
  1268. RTCORE_API void rtcSetTessellationRate (RTCScene hscene, unsigned geomID, float tessellationRate)
  1269. {
  1270. Scene* scene = (Scene*) hscene;
  1271. RTCORE_CATCH_BEGIN;
  1272. RTCORE_TRACE(rtcSetTessellationRate);
  1273. RTCORE_VERIFY_HANDLE(hscene);
  1274. RTCORE_VERIFY_GEOMID(geomID);
  1275. scene->get_locked(geomID)->setTessellationRate(tessellationRate);
  1276. RTCORE_CATCH_END(scene->device);
  1277. }
  1278. RTCORE_API void rtcSetUserData (RTCScene hscene, unsigned geomID, void* ptr)
  1279. {
  1280. Scene* scene = (Scene*) hscene;
  1281. RTCORE_CATCH_BEGIN;
  1282. RTCORE_TRACE(rtcSetUserData);
  1283. RTCORE_VERIFY_HANDLE(hscene);
  1284. RTCORE_VERIFY_GEOMID(geomID);
  1285. scene->get_locked(geomID)->setUserData(ptr);
  1286. RTCORE_CATCH_END(scene->device);
  1287. }
  1288. RTCORE_API void* rtcGetUserData (RTCScene hscene, unsigned geomID)
  1289. {
  1290. Scene* scene = (Scene*) hscene;
  1291. RTCORE_CATCH_BEGIN;
  1292. RTCORE_TRACE(rtcGetUserData);
  1293. RTCORE_VERIFY_HANDLE(hscene);
  1294. RTCORE_VERIFY_GEOMID(geomID);
  1295. return scene->get(geomID)->getUserData(); // this call is on purpose not thread safe
  1296. RTCORE_CATCH_END(scene->device);
  1297. return nullptr;
  1298. }
  1299. RTCORE_API void rtcSetBoundsFunction (RTCScene hscene, unsigned geomID, RTCBoundsFunc bounds)
  1300. {
  1301. Scene* scene = (Scene*) hscene;
  1302. RTCORE_CATCH_BEGIN;
  1303. RTCORE_TRACE(rtcSetBoundsFunction);
  1304. RTCORE_VERIFY_HANDLE(hscene);
  1305. RTCORE_VERIFY_GEOMID(geomID);
  1306. scene->get_locked(geomID)->setBoundsFunction(bounds);
  1307. RTCORE_CATCH_END(scene->device);
  1308. }
  1309. RTCORE_API void rtcSetBoundsFunction2 (RTCScene hscene, unsigned geomID, RTCBoundsFunc2 bounds, void* userPtr)
  1310. {
  1311. Scene* scene = (Scene*) hscene;
  1312. RTCORE_CATCH_BEGIN;
  1313. RTCORE_TRACE(rtcSetBoundsFunction2);
  1314. RTCORE_VERIFY_HANDLE(hscene);
  1315. RTCORE_VERIFY_GEOMID(geomID);
  1316. scene->get_locked(geomID)->setBoundsFunction2(bounds,userPtr);
  1317. RTCORE_CATCH_END(scene->device);
  1318. }
  1319. RTCORE_API void rtcSetBoundsFunction3 (RTCScene hscene, unsigned geomID, RTCBoundsFunc3 bounds, void* userPtr)
  1320. {
  1321. Scene* scene = (Scene*) hscene;
  1322. RTCORE_CATCH_BEGIN;
  1323. RTCORE_TRACE(rtcSetBoundsFunction3);
  1324. RTCORE_VERIFY_HANDLE(hscene);
  1325. RTCORE_VERIFY_GEOMID(geomID);
  1326. scene->get_locked(geomID)->setBoundsFunction3(bounds,userPtr);
  1327. RTCORE_CATCH_END(scene->device);
  1328. }
  1329. RTCORE_API void rtcSetDisplacementFunction (RTCScene hscene, unsigned geomID, RTCDisplacementFunc func, RTCBounds* bounds)
  1330. {
  1331. Scene* scene = (Scene*) hscene;
  1332. RTCORE_CATCH_BEGIN;
  1333. RTCORE_TRACE(rtcSetDisplacementFunction);
  1334. RTCORE_VERIFY_HANDLE(hscene);
  1335. RTCORE_VERIFY_GEOMID(geomID);
  1336. scene->get_locked(geomID)->setDisplacementFunction(func,bounds);
  1337. RTCORE_CATCH_END(scene->device);
  1338. }
  1339. RTCORE_API void rtcSetDisplacementFunction2 (RTCScene hscene, unsigned geomID, RTCDisplacementFunc2 func, RTCBounds* bounds)
  1340. {
  1341. Scene* scene = (Scene*) hscene;
  1342. RTCORE_CATCH_BEGIN;
  1343. RTCORE_TRACE(rtcSetDisplacementFunction2);
  1344. RTCORE_VERIFY_HANDLE(hscene);
  1345. RTCORE_VERIFY_GEOMID(geomID);
  1346. scene->get_locked(geomID)->setDisplacementFunction2(func,bounds);
  1347. RTCORE_CATCH_END(scene->device);
  1348. }
  1349. RTCORE_API void rtcSetIntersectFunction (RTCScene hscene, unsigned geomID, RTCIntersectFunc intersect)
  1350. {
  1351. Scene* scene = (Scene*) hscene;
  1352. RTCORE_CATCH_BEGIN;
  1353. RTCORE_TRACE(rtcSetIntersectFunction);
  1354. RTCORE_VERIFY_HANDLE(hscene);
  1355. RTCORE_VERIFY_GEOMID(geomID);
  1356. scene->get_locked(geomID)->setIntersectFunction(intersect);
  1357. RTCORE_CATCH_END(scene->device);
  1358. }
  1359. RTCORE_API void rtcSetIntersectFunction4 (RTCScene hscene, unsigned geomID, RTCIntersectFunc4 intersect4)
  1360. {
  1361. Scene* scene = (Scene*) hscene;
  1362. RTCORE_CATCH_BEGIN;
  1363. RTCORE_TRACE(rtcSetIntersectFunction4);
  1364. RTCORE_VERIFY_HANDLE(hscene);
  1365. RTCORE_VERIFY_GEOMID(geomID);
  1366. scene->get_locked(geomID)->setIntersectFunction4(intersect4);
  1367. RTCORE_CATCH_END(scene->device);
  1368. }
  1369. RTCORE_API void rtcSetIntersectFunction8 (RTCScene hscene, unsigned geomID, RTCIntersectFunc8 intersect8)
  1370. {
  1371. Scene* scene = (Scene*) hscene;
  1372. RTCORE_CATCH_BEGIN;
  1373. RTCORE_TRACE(rtcSetIntersectFunction8);
  1374. RTCORE_VERIFY_HANDLE(hscene);
  1375. RTCORE_VERIFY_GEOMID(geomID);
  1376. scene->get_locked(geomID)->setIntersectFunction8(intersect8);
  1377. RTCORE_CATCH_END(scene->device);
  1378. }
  1379. RTCORE_API void rtcSetIntersectFunction16 (RTCScene hscene, unsigned geomID, RTCIntersectFunc16 intersect16)
  1380. {
  1381. Scene* scene = (Scene*) hscene;
  1382. RTCORE_CATCH_BEGIN;
  1383. RTCORE_TRACE(rtcSetIntersectFunction16);
  1384. RTCORE_VERIFY_HANDLE(hscene);
  1385. RTCORE_VERIFY_GEOMID(geomID);
  1386. scene->get_locked(geomID)->setIntersectFunction16(intersect16);
  1387. RTCORE_CATCH_END(scene->device);
  1388. }
  1389. RTCORE_API void rtcSetIntersectFunction1Mp (RTCScene hscene, unsigned geomID, RTCIntersectFunc1Mp intersect)
  1390. {
  1391. Scene* scene = (Scene*) hscene;
  1392. RTCORE_CATCH_BEGIN;
  1393. RTCORE_TRACE(rtcSetIntersectFunction1Mp);
  1394. RTCORE_VERIFY_HANDLE(hscene);
  1395. RTCORE_VERIFY_GEOMID(geomID);
  1396. scene->get_locked(geomID)->setIntersectFunction1Mp(intersect);
  1397. RTCORE_CATCH_END(scene->device);
  1398. }
  1399. RTCORE_API void rtcSetIntersectFunctionN (RTCScene hscene, unsigned geomID, RTCIntersectFuncN intersect)
  1400. {
  1401. Scene* scene = (Scene*) hscene;
  1402. RTCORE_CATCH_BEGIN;
  1403. RTCORE_TRACE(rtcSetIntersectFunctionN);
  1404. RTCORE_VERIFY_HANDLE(hscene);
  1405. RTCORE_VERIFY_GEOMID(geomID);
  1406. scene->get_locked(geomID)->setIntersectFunctionN(intersect);
  1407. RTCORE_CATCH_END(scene->device);
  1408. }
  1409. RTCORE_API void rtcSetOccludedFunction (RTCScene hscene, unsigned geomID, RTCOccludedFunc occluded)
  1410. {
  1411. Scene* scene = (Scene*) hscene;
  1412. RTCORE_CATCH_BEGIN;
  1413. RTCORE_TRACE(rtcSetOccludedFunction);
  1414. RTCORE_VERIFY_HANDLE(hscene);
  1415. RTCORE_VERIFY_GEOMID(geomID);
  1416. scene->get_locked(geomID)->setOccludedFunction(occluded);
  1417. RTCORE_CATCH_END(scene->device);
  1418. }
  1419. RTCORE_API void rtcSetOccludedFunction4 (RTCScene hscene, unsigned geomID, RTCOccludedFunc4 occluded4)
  1420. {
  1421. Scene* scene = (Scene*) hscene;
  1422. RTCORE_CATCH_BEGIN;
  1423. RTCORE_TRACE(rtcSetOccludedFunction4);
  1424. RTCORE_VERIFY_HANDLE(hscene);
  1425. RTCORE_VERIFY_GEOMID(geomID);
  1426. scene->get_locked(geomID)->setOccludedFunction4(occluded4);
  1427. RTCORE_CATCH_END(scene->device);
  1428. }
  1429. RTCORE_API void rtcSetOccludedFunction8 (RTCScene hscene, unsigned geomID, RTCOccludedFunc8 occluded8)
  1430. {
  1431. Scene* scene = (Scene*) hscene;
  1432. RTCORE_CATCH_BEGIN;
  1433. RTCORE_TRACE(rtcSetOccludedFunction8);
  1434. RTCORE_VERIFY_HANDLE(hscene);
  1435. RTCORE_VERIFY_GEOMID(geomID);
  1436. scene->get_locked(geomID)->setOccludedFunction8(occluded8);
  1437. RTCORE_CATCH_END(scene->device);
  1438. }
  1439. RTCORE_API void rtcSetOccludedFunction16 (RTCScene hscene, unsigned geomID, RTCOccludedFunc16 occluded16)
  1440. {
  1441. Scene* scene = (Scene*) hscene;
  1442. RTCORE_CATCH_BEGIN;
  1443. RTCORE_TRACE(rtcSetOccludedFunction16);
  1444. RTCORE_VERIFY_HANDLE(hscene);
  1445. RTCORE_VERIFY_GEOMID(geomID);
  1446. scene->get_locked(geomID)->setOccludedFunction16(occluded16);
  1447. RTCORE_CATCH_END(scene->device);
  1448. }
  1449. RTCORE_API void rtcSetOccludedFunction1Mp (RTCScene hscene, unsigned geomID, RTCOccludedFunc1Mp occluded)
  1450. {
  1451. Scene* scene = (Scene*) hscene;
  1452. RTCORE_CATCH_BEGIN;
  1453. RTCORE_TRACE(rtcSetOccludedFunction1Mp);
  1454. RTCORE_VERIFY_HANDLE(hscene);
  1455. RTCORE_VERIFY_GEOMID(geomID);
  1456. scene->get_locked(geomID)->setOccludedFunction1Mp(occluded);
  1457. RTCORE_CATCH_END(scene->device);
  1458. }
  1459. RTCORE_API void rtcSetOccludedFunctionN (RTCScene hscene, unsigned geomID, RTCOccludedFuncN occluded)
  1460. {
  1461. Scene* scene = (Scene*) hscene;
  1462. RTCORE_CATCH_BEGIN;
  1463. RTCORE_TRACE(rtcSetOccludedFunctionN);
  1464. RTCORE_VERIFY_HANDLE(hscene);
  1465. RTCORE_VERIFY_GEOMID(geomID);
  1466. scene->get_locked(geomID)->setOccludedFunctionN(occluded);
  1467. RTCORE_CATCH_END(scene->device);
  1468. }
  1469. RTCORE_API void rtcSetIntersectionFilterFunction (RTCScene hscene, unsigned geomID, RTCFilterFunc intersect)
  1470. {
  1471. Scene* scene = (Scene*) hscene;
  1472. RTCORE_CATCH_BEGIN;
  1473. RTCORE_TRACE(rtcSetIntersectionFilterFunction);
  1474. RTCORE_VERIFY_HANDLE(hscene);
  1475. RTCORE_VERIFY_GEOMID(geomID);
  1476. scene->get_locked(geomID)->setIntersectionFilterFunction(intersect);
  1477. RTCORE_CATCH_END(scene->device);
  1478. }
  1479. RTCORE_API void rtcSetIntersectionFilterFunction4 (RTCScene hscene, unsigned geomID, RTCFilterFunc4 filter4)
  1480. {
  1481. Scene* scene = (Scene*) hscene;
  1482. RTCORE_CATCH_BEGIN;
  1483. RTCORE_TRACE(rtcSetIntersectionFilterFunction4);
  1484. RTCORE_VERIFY_HANDLE(hscene);
  1485. RTCORE_VERIFY_GEOMID(geomID);
  1486. scene->get_locked(geomID)->setIntersectionFilterFunction4(filter4);
  1487. RTCORE_CATCH_END(scene->device);
  1488. }
  1489. RTCORE_API void rtcSetIntersectionFilterFunction8 (RTCScene hscene, unsigned geomID, RTCFilterFunc8 filter8)
  1490. {
  1491. Scene* scene = (Scene*) hscene;
  1492. RTCORE_CATCH_BEGIN;
  1493. RTCORE_TRACE(rtcSetIntersectionFilterFunction8);
  1494. RTCORE_VERIFY_HANDLE(hscene);
  1495. RTCORE_VERIFY_GEOMID(geomID);
  1496. scene->get_locked(geomID)->setIntersectionFilterFunction8(filter8);
  1497. RTCORE_CATCH_END(scene->device);
  1498. }
  1499. RTCORE_API void rtcSetIntersectionFilterFunction16 (RTCScene hscene, unsigned geomID, RTCFilterFunc16 filter16)
  1500. {
  1501. Scene* scene = (Scene*) hscene;
  1502. RTCORE_CATCH_BEGIN;
  1503. RTCORE_TRACE(rtcSetIntersectionFilterFunction16);
  1504. RTCORE_VERIFY_HANDLE(hscene);
  1505. RTCORE_VERIFY_GEOMID(geomID);
  1506. scene->get_locked(geomID)->setIntersectionFilterFunction16(filter16);
  1507. RTCORE_CATCH_END(scene->device);
  1508. }
  1509. RTCORE_API void rtcSetIntersectionFilterFunctionN (RTCScene hscene, unsigned geomID, RTCFilterFuncN filterN)
  1510. {
  1511. Scene* scene = (Scene*) hscene;
  1512. RTCORE_CATCH_BEGIN;
  1513. RTCORE_TRACE(rtcSetIntersectionFilterFunctionN);
  1514. RTCORE_VERIFY_HANDLE(hscene);
  1515. RTCORE_VERIFY_GEOMID(geomID);
  1516. scene->get_locked(geomID)->setIntersectionFilterFunctionN(filterN);
  1517. RTCORE_CATCH_END(scene->device);
  1518. }
  1519. RTCORE_API void rtcSetOcclusionFilterFunction (RTCScene hscene, unsigned geomID, RTCFilterFunc intersect)
  1520. {
  1521. Scene* scene = (Scene*) hscene;
  1522. RTCORE_CATCH_BEGIN;
  1523. RTCORE_TRACE(rtcSetOcclusionFilterFunction);
  1524. RTCORE_VERIFY_HANDLE(hscene);
  1525. RTCORE_VERIFY_GEOMID(geomID);
  1526. scene->get_locked(geomID)->setOcclusionFilterFunction(intersect);
  1527. RTCORE_CATCH_END(scene->device);
  1528. }
  1529. RTCORE_API void rtcSetOcclusionFilterFunction4 (RTCScene hscene, unsigned geomID, RTCFilterFunc4 filter4)
  1530. {
  1531. Scene* scene = (Scene*) hscene;
  1532. RTCORE_CATCH_BEGIN;
  1533. RTCORE_TRACE(rtcSetOcclusionFilterFunction4);
  1534. RTCORE_VERIFY_HANDLE(hscene);
  1535. RTCORE_VERIFY_GEOMID(geomID);
  1536. scene->get_locked(geomID)->setOcclusionFilterFunction4(filter4);
  1537. RTCORE_CATCH_END(scene->device);
  1538. }
  1539. RTCORE_API void rtcSetOcclusionFilterFunction8 (RTCScene hscene, unsigned geomID, RTCFilterFunc8 filter8)
  1540. {
  1541. Scene* scene = (Scene*) hscene;
  1542. RTCORE_CATCH_BEGIN;
  1543. RTCORE_TRACE(rtcSetOcclusionFilterFunction8);
  1544. RTCORE_VERIFY_HANDLE(hscene);
  1545. RTCORE_VERIFY_GEOMID(geomID);
  1546. scene->get_locked(geomID)->setOcclusionFilterFunction8(filter8);
  1547. RTCORE_CATCH_END(scene->device);
  1548. }
  1549. RTCORE_API void rtcSetOcclusionFilterFunction16 (RTCScene hscene, unsigned geomID, RTCFilterFunc16 filter16)
  1550. {
  1551. Scene* scene = (Scene*) hscene;
  1552. RTCORE_CATCH_BEGIN;
  1553. RTCORE_TRACE(rtcSetOcclusionFilterFunction16);
  1554. RTCORE_VERIFY_HANDLE(hscene);
  1555. RTCORE_VERIFY_GEOMID(geomID);
  1556. scene->get_locked(geomID)->setOcclusionFilterFunction16(filter16);
  1557. RTCORE_CATCH_END(scene->device);
  1558. }
  1559. RTCORE_API void rtcSetOcclusionFilterFunctionN (RTCScene hscene, unsigned geomID, RTCFilterFuncN filterN)
  1560. {
  1561. Scene* scene = (Scene*) hscene;
  1562. RTCORE_CATCH_BEGIN;
  1563. RTCORE_TRACE(rtcSetOcclusionFilterFunctionN);
  1564. RTCORE_VERIFY_HANDLE(hscene);
  1565. RTCORE_VERIFY_GEOMID(geomID);
  1566. scene->get_locked(geomID)->setOcclusionFilterFunctionN(filterN);
  1567. RTCORE_CATCH_END(scene->device);
  1568. }
  1569. RTCORE_API void rtcInterpolate(RTCScene hscene, unsigned geomID, unsigned primID, float u, float v,
  1570. RTCBufferType buffer,
  1571. float* P, float* dPdu, float* dPdv, size_t numFloats)
  1572. {
  1573. Scene* scene = (Scene*) hscene;
  1574. RTCORE_CATCH_BEGIN;
  1575. RTCORE_TRACE(rtcInterpolate);
  1576. RTCORE_VERIFY_HANDLE(hscene);
  1577. RTCORE_VERIFY_GEOMID(geomID);
  1578. scene->get(geomID)->interpolate(primID,u,v,buffer,P,dPdu,dPdv,nullptr,nullptr,nullptr,numFloats); // this call is on purpose not thread safe
  1579. RTCORE_CATCH_END(scene->device);
  1580. }
  1581. RTCORE_API void rtcInterpolate2(RTCScene hscene, unsigned geomID, unsigned primID, float u, float v,
  1582. RTCBufferType buffer,
  1583. float* P, float* dPdu, float* dPdv,
  1584. float* ddPdudu, float* ddPdvdv, float* ddPdudv,
  1585. size_t numFloats)
  1586. {
  1587. Scene* scene = (Scene*) hscene;
  1588. RTCORE_CATCH_BEGIN;
  1589. RTCORE_TRACE(rtcInterpolate);
  1590. RTCORE_VERIFY_HANDLE(hscene);
  1591. RTCORE_VERIFY_GEOMID(geomID);
  1592. scene->get(geomID)->interpolate(primID,u,v,buffer,P,dPdu,dPdv,ddPdudu,ddPdvdv,ddPdudv,numFloats); // this call is on purpose not thread safe
  1593. RTCORE_CATCH_END(scene->device);
  1594. }
  1595. #if defined (EMBREE_RAY_PACKETS)
  1596. RTCORE_API void rtcInterpolateN(RTCScene hscene, unsigned geomID,
  1597. const void* valid_i, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
  1598. RTCBufferType buffer,
  1599. float* P, float* dPdu, float* dPdv, size_t numFloats)
  1600. {
  1601. Scene* scene = (Scene*) hscene;
  1602. RTCORE_CATCH_BEGIN;
  1603. RTCORE_TRACE(rtcInterpolateN);
  1604. RTCORE_VERIFY_HANDLE(hscene);
  1605. RTCORE_VERIFY_GEOMID(geomID);
  1606. scene->get(geomID)->interpolateN(valid_i,primIDs,u,v,numUVs,buffer,P,dPdu,dPdv,nullptr,nullptr,nullptr,numFloats); // this call is on purpose not thread safe
  1607. RTCORE_CATCH_END(scene->device);
  1608. }
  1609. #endif
  1610. #if defined (EMBREE_RAY_PACKETS)
  1611. RTCORE_API void rtcInterpolateN2(RTCScene hscene, unsigned geomID,
  1612. const void* valid_i, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
  1613. RTCBufferType buffer,
  1614. float* P, float* dPdu, float* dPdv,
  1615. float* ddPdudu, float* ddPdvdv, float* ddPdudv,
  1616. size_t numFloats)
  1617. {
  1618. Scene* scene = (Scene*) hscene;
  1619. RTCORE_CATCH_BEGIN;
  1620. RTCORE_TRACE(rtcInterpolateN);
  1621. RTCORE_VERIFY_HANDLE(hscene);
  1622. RTCORE_VERIFY_GEOMID(geomID);
  1623. scene->get(geomID)->interpolateN(valid_i,primIDs,u,v,numUVs,buffer,P,dPdu,dPdv,ddPdudu,ddPdvdv,ddPdudv,numFloats); // this call is on purpose not thread safe
  1624. RTCORE_CATCH_END(scene->device);
  1625. }
  1626. #endif
  1627. }