RTCORE_API void rtcCommitThread(RTCScene hscene, unsigned int threadID, unsigned int numThreads) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcCommitThread); RTCORE_VERIFY_HANDLE(hscene); if (unlikely(numThreads == 0)) throw_RTCError(RTC_INVALID_OPERATION,"invalid number of threads specified"); #if defined(__MIC__) if (unlikely(numThreads % 4 != 0 && numThreads != 1)) throw_RTCError(RTC_INVALID_OPERATION,"MIC requires numThreads % 4 == 0 in rtcCommitThread"); #endif /* for best performance set FTZ and DAZ flags in the MXCSR control and status register */ #if !defined(__MIC__) unsigned int mxcsr = _mm_getcsr(); _mm_setcsr(mxcsr | /* FTZ */ (1<<15) | /* DAZ */ (1<<6)); #endif /* perform scene build */ scene->build(threadID,numThreads); /* reset MXCSR register again */ #if !defined(__MIC__) _mm_setcsr(mxcsr); #endif RTCORE_CATCH_END(scene->device); }
RTCORE_API void rtcSetErrorFunction(RTCErrorFunc func) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetErrorFunction); assert(g_device); if (g_device) g_device->error_function = func; RTCORE_CATCH_END(g_device); }
RTCORE_API void rtcSetParameter1i(const RTCParameter parm, ssize_t val) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetParameter1i); Lock<MutexSys> lock(g_mutex); if (g_device) g_device->setParameter1i(parm,val); RTCORE_CATCH_END(g_device); }
RTCORE_API void rtcDeviceSetMemoryMonitorFunction(RTCDevice hdevice, RTCMemoryMonitorFunc func) { Device* device = (Device*) hdevice; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeviceSetMemoryMonitorFunction); device->memory_monitor_function = func; RTCORE_CATCH_END(device); }
RTCORE_API void rtcSetMemoryMonitorFunction(RTCMemoryMonitorFunc func) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetMemoryMonitorFunction); assert(g_device); if (g_device) g_device->memory_monitor_function = func; RTCORE_CATCH_END(g_device); }
RTCORE_API void rtcInit(const char* cfg) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcInit); Lock<MutexSys> lock(g_mutex); if (g_device) throw_RTCError(RTC_INVALID_OPERATION,"already initialized"); g_device = new Device(cfg,true); RTCORE_CATCH_END(g_device); }
RTCORE_API void rtcDeleteDevice(RTCDevice device) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeleteDevice); RTCORE_VERIFY_HANDLE(device); Lock<MutexSys> lock(g_mutex); delete (Device*) device; RTCORE_CATCH_END_NOREPORT; }
RTCORE_API void rtcSetProgressMonitorFunction(RTCScene hscene, RTCProgressMonitorFunc func, void* ptr) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetProgressMonitorFunction); RTCORE_VERIFY_HANDLE(hscene); scene->setProgressMonitorFunction(func,ptr); RTCORE_CATCH_END(scene->device); }
RTCORE_API void rtcDeviceSetErrorFunction(RTCDevice hdevice, RTCErrorFunc func) { Device* device = (Device*) hdevice; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeviceSetErrorFunction); RTCORE_VERIFY_HANDLE(hdevice); device->error_function = func; RTCORE_CATCH_END(device); }
RTCORE_API void rtcExit() { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcExit); Lock<MutexSys> lock(g_mutex); if (!g_device) throw_RTCError(RTC_INVALID_OPERATION,"rtcInit has to get called before rtcExit"); delete g_device; g_device = nullptr; RTCORE_CATCH_END(g_device); }
extern "C" void ispcSetIntersectFunction16 (RTCScene hscene, unsigned geomID, RTCIntersectFunc16 intersect) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetIntersectFunction16); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); ((Scene*)scene)->get_locked(geomID)->setIntersectFunction16(intersect,true); RTCORE_CATCH_END(scene->device); }
extern "C" void ispcSetOccludedFunction8 (RTCScene hscene, unsigned geomID, RTCOccludedFunc8 occluded) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetOccludedFunction8); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); ((Scene*)scene)->get_locked(geomID)->setOccludedFunction8(occluded,true); RTCORE_CATCH_END(scene->device); }
RTCORE_API RTCScene rtcDeviceNewScene (RTCDevice device, RTCSceneFlags flags, RTCAlgorithmFlags aflags) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeviceNewScene); RTCORE_VERIFY_HANDLE(device); if (!isCoherent(flags) && !isIncoherent(flags)) flags = RTCSceneFlags(flags | RTC_SCENE_INCOHERENT); return (RTCScene) new Scene((Device*)device,flags,aflags); RTCORE_CATCH_END((Device*)device); return nullptr; }
RTCORE_API RTCScene rtcNewScene (RTCSceneFlags flags, RTCAlgorithmFlags aflags) { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcNewScene); assert(g_device); if (!isCoherent(flags) && !isIncoherent(flags)) flags = RTCSceneFlags(flags | RTC_SCENE_INCOHERENT); return (RTCScene) new Scene(g_device,flags,aflags); RTCORE_CATCH_END(g_device); return nullptr; }
extern "C" void ispcSetOcclusionFilterFunction16 (RTCScene hscene, unsigned geomID, RTCFilterFunc16 filter) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetOcclusionFilterFunction16); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); ((Scene*)scene)->get_locked(geomID)->setOcclusionFilterFunction16(filter,true); RTCORE_CATCH_END(scene->device); }
extern "C" void ispcSetUserData (RTCScene hscene, unsigned geomID, void* ptr) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetUserData); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); scene->get_locked(geomID)->setUserData(ptr); RTCORE_CATCH_END(scene->device); }
extern "C" void ispcSetDisplacementFunction (RTCScene hscene, unsigned int geomID, void* func, RTCBounds* bounds) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetDisplacementFunction); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); ((Scene*)scene)->get_locked(geomID)->setDisplacementFunction((RTCDisplacementFunc)func,bounds); RTCORE_CATCH_END(scene->device); }
RTCORE_API void rtcDeviceSetParameter1i(RTCDevice hdevice, const RTCParameter parm, ssize_t val) { Device* device = (Device*) hdevice; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeviceSetParameter1i); RTCORE_VERIFY_HANDLE(hdevice); Lock<MutexSys> lock(g_mutex); device->setParameter1i(parm,val); RTCORE_CATCH_END(device); }
extern "C" void* ispcGetUserData (RTCScene hscene, unsigned geomID) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcSetUserData); RTCORE_VERIFY_HANDLE(scene); RTCORE_VERIFY_GEOMID(geomID); return scene->get(geomID)->getUserData(); // this call is on purpose not thread safe RTCORE_CATCH_END(scene->device); return nullptr; }
RTCORE_API RTCError rtcGetError() { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcGetError); if (g_device == nullptr) return RTC_UNKNOWN_ERROR; RTCError* stored_error = g_device->error(); RTCError error = *stored_error; *stored_error = RTC_NO_ERROR; return error; RTCORE_CATCH_END(g_device); return RTC_UNKNOWN_ERROR; }
RTCORE_API RTCError rtcDeviceGetError(RTCDevice hdevice) { Device* device = (Device*) hdevice; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDeviceGetError); RTCORE_VERIFY_HANDLE(hdevice); RTCError* stored_error = device->error(); RTCError error = *stored_error; *stored_error = RTC_NO_ERROR; return error; RTCORE_CATCH_END(device); return RTC_UNKNOWN_ERROR; }
RTCORE_API void rtcIntersect4 (const void* valid, RTCScene hscene, RTCRay4& ray) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcIntersect4); #if !defined(__TARGET_SIMD4__) throw_RTCError(RTC_INVALID_OPERATION,"rtcIntersect4 not supported"); #else #if defined(DEBUG) RTCORE_VERIFY_HANDLE(hscene); if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed"); if (((size_t)valid) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "mask not aligned to 16 bytes"); if (((size_t)&ray ) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes"); #endif STAT(size_t cnt=0; for (size_t i=0; i<4; i++) cnt += ((int*)valid)[i] == -1;);
RTCORE_API void rtcCommit (RTCScene hscene) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcCommit); RTCORE_VERIFY_HANDLE(hscene); #if defined(RTCORE_ENABLE_RAYSTREAM_LOGGER) RayStreamLogger::rayStreamLogger.dumpGeometry(scene); #endif /* perform scene build */ scene->build(0,0); RTCORE_CATCH_END(scene->device); }
RTCORE_API void rtcDebug() { RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcDebug); #if defined(RTCORE_STAT_COUNTERS) Stat::print(std::cout); Stat::clear(); #endif #if defined(DEBUG) && 1 extern void printTessCacheStats(); printTessCacheStats(); #endif RTCORE_CATCH_END(g_device); }
RTCORE_API void rtcIntersect (RTCScene hscene, RTCRay& ray) { Scene* scene = (Scene*) hscene; RTCORE_CATCH_BEGIN; RTCORE_TRACE(rtcIntersect); #if defined(DEBUG) RTCORE_VERIFY_HANDLE(hscene); if (scene->isModified()) throw_RTCError(RTC_INVALID_OPERATION,"scene got not committed"); if (((size_t)&ray) & 0x0F ) throw_RTCError(RTC_INVALID_ARGUMENT, "ray not aligned to 16 bytes"); #endif #if defined(RTCORE_ENABLE_RAYSTREAM_LOGGER) RTCRay old_ray = ray; #endif STAT3(normal.travs,1,1,1); scene->intersect(ray); #if defined(RTCORE_ENABLE_RAYSTREAM_LOGGER) RayStreamLogger::rayStreamLogger.logRay1Intersect(scene,old_ray,ray); #endif RTCORE_CATCH_END(scene->device); }