Path: blob/master/thirdparty/embree/patches/0001-disable-exceptions.patch
9903 views
diff --git a/thirdparty/embree/common/algorithms/parallel_reduce.h b/thirdparty/embree/common/algorithms/parallel_reduce.h1index b52b1e2e13..fbff38f660 1006442--- a/thirdparty/embree/common/algorithms/parallel_reduce.h3+++ b/thirdparty/embree/common/algorithms/parallel_reduce.h4@@ -58,15 +58,15 @@ namespace embree5const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,6[&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },7reduction,context);8- if (context.is_group_execution_cancelled())9- throw std::runtime_error("task cancelled");10+ //if (context.is_group_execution_cancelled())11+ // throw std::runtime_error("task cancelled");12return v;13#else14const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,15[&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },16reduction);17- if (tbb::task::self().is_cancelled())18- throw std::runtime_error("task cancelled");19+ //if (tbb::task::self().is_cancelled())20+ // throw std::runtime_error("task cancelled");21return v;22#endif23#else // TASKING_PPL24diff --git a/thirdparty/embree/common/lexers/stringstream.cpp b/thirdparty/embree/common/lexers/stringstream.cpp25index 42ffb10176..9779fc74c7 10064426--- a/thirdparty/embree/common/lexers/stringstream.cpp27+++ b/thirdparty/embree/common/lexers/stringstream.cpp28@@ -39,7 +39,7 @@ namespace embree29std::vector<char> str; str.reserve(64);30while (cin->peek() != EOF && !isSeparator(cin->peek())) {31int c = cin->get();32- if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");33+ if (!isValidChar(c)) abort(); //throw std::runtime_error("invalid character "+std::string(1,c)+" in input");34str.push_back((char)c);35}36str.push_back(0);37diff --git a/thirdparty/embree/common/sys/alloc.cpp b/thirdparty/embree/common/sys/alloc.cpp38index c92bb99ece..2288df76ef 10064439--- a/thirdparty/embree/common/sys/alloc.cpp40+++ b/thirdparty/embree/common/sys/alloc.cpp41@@ -20,7 +20,7 @@ namespace embree42assert((align & (align-1)) == 0);43void* ptr = _mm_malloc(size,align);44if (size != 0 && ptr == nullptr)45- throw std::bad_alloc();46+ abort(); //throw std::bad_alloc();47return ptr;48}4950@@ -50,7 +50,7 @@ namespace embree51ptr = sycl::aligned_alloc_shared(align,size,*device,*context);5253if (size != 0 && ptr == nullptr)54- throw std::bad_alloc();55+ abort(); //throw std::bad_alloc();5657return ptr;58}59@@ -83,7 +83,7 @@ namespace embree60}6162if (size != 0 && ptr == nullptr)63- throw std::bad_alloc();64+ abort(); //throw std::bad_alloc();6566return ptr;67}68@@ -199,7 +199,7 @@ namespace embree69/* fall back to 4k pages */70int flags = MEM_COMMIT | MEM_RESERVE;71char* ptr = (char*) VirtualAlloc(nullptr,bytes,flags,PAGE_READWRITE);72- if (ptr == nullptr) throw std::bad_alloc();73+ if (ptr == nullptr) abort(); //throw std::bad_alloc();74hugepages = false;75return ptr;76}77@@ -216,7 +216,7 @@ namespace embree78return bytesOld;7980if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))81- throw std::bad_alloc();82+ abort(); //throw std::bad_alloc();8384return bytesNew;85}86@@ -227,7 +227,7 @@ namespace embree87return;8889if (!VirtualFree(ptr,0,MEM_RELEASE))90- throw std::bad_alloc();91+ abort(); //throw std::bad_alloc();92}9394void os_advise(void *ptr, size_t bytes)95@@ -331,7 +331,7 @@ namespace embree9697/* fallback to 4k pages */98void* ptr = (char*) mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);99- if (ptr == MAP_FAILED) throw std::bad_alloc();100+ if (ptr == MAP_FAILED) abort(); //throw std::bad_alloc();101hugepages = false;102103/* advise huge page hint for THP */104@@ -348,7 +348,7 @@ namespace embree105return bytesOld;106107if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)108- throw std::bad_alloc();109+ abort(); //throw std::bad_alloc();110111return bytesNew;112}113@@ -362,7 +362,7 @@ namespace embree114const size_t pageSize = hugepages ? PAGE_SIZE_2M : PAGE_SIZE_4K;115bytes = (bytes+pageSize-1) & ~(pageSize-1);116if (munmap(ptr,bytes) == -1)117- throw std::bad_alloc();118+ abort(); //throw std::bad_alloc();119}120121/* hint for transparent huge pages (THP) */122diff --git a/thirdparty/embree/common/sys/alloc.h b/thirdparty/embree/common/sys/alloc.h123index 5c63d0bfaf..1f6f230ed3 100644124--- a/thirdparty/embree/common/sys/alloc.h125+++ b/thirdparty/embree/common/sys/alloc.h126@@ -131,7 +131,7 @@ namespace embree127typedef std::ptrdiff_t difference_type;128129__forceinline pointer allocate( size_type n ) {130- throw std::runtime_error("no allocation supported");131+ abort(); //throw std::runtime_error("no allocation supported");132}133134__forceinline void deallocate( pointer p, size_type n ) {135diff --git a/thirdparty/embree/common/sys/platform.h b/thirdparty/embree/common/sys/platform.h136index 6dc0cf3318..1e5b02550e 100644137--- a/thirdparty/embree/common/sys/platform.h138+++ b/thirdparty/embree/common/sys/platform.h139@@ -214,10 +214,11 @@140141#if defined(DEBUG) // only report file and line in debug mode142#define THROW_RUNTIME_ERROR(str) \143- throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));144+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();145+ //throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));146#else147#define THROW_RUNTIME_ERROR(str) \148- throw std::runtime_error(str);149+ abort(); //throw std::runtime_error(str);150#endif151152#define FATAL(x) THROW_RUNTIME_ERROR(x)153diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp154index 83ead95122..e89ae04f8b 100644155--- a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp156+++ b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp157@@ -48,13 +48,13 @@ namespace embree158{159Task* prevTask = thread.task;160thread.task = this;161- try {162- if (context->cancellingException == nullptr)163+ //try {164+ // if (context->cancellingException == nullptr)165closure->execute();166- } catch (...) {167- if (context->cancellingException == nullptr)168- context->cancellingException = std::current_exception();169- }170+ //} catch (...) {171+ // if (context->cancellingException == nullptr)172+ // context->cancellingException = std::current_exception();173+ //}174thread.task = prevTask;175add_dependencies(-1);176}177diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.h b/thirdparty/embree/common/tasking/taskschedulerinternal.h178index b01bebf7c3..d4e0c7386b 100644179--- a/thirdparty/embree/common/tasking/taskschedulerinternal.h180+++ b/thirdparty/embree/common/tasking/taskschedulerinternal.h181@@ -131,7 +131,7 @@ namespace embree182{183size_t ofs = bytes + ((align - stackPtr) & (align-1));184if (stackPtr + ofs > CLOSURE_STACK_SIZE)185- throw std::runtime_error("closure stack overflow");186+ abort(); //throw std::runtime_error("closure stack overflow");187stackPtr += ofs;188return &stack[stackPtr-bytes];189}190@@ -140,7 +140,7 @@ namespace embree191__forceinline void push_right(Thread& thread, const size_t size, const Closure& closure, TaskGroupContext* context)192{193if (right >= TASK_STACK_SIZE)194- throw std::runtime_error("task stack overflow");195+ abort(); //throw std::runtime_error("task stack overflow");196197/* allocate new task on right side of stack */198size_t oldStackPtr = stackPtr;199diff --git a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp200index 40f9043736..f3b93e5925 100644201--- a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp202+++ b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp203@@ -150,7 +150,7 @@ namespace embree204}205}206else {207- throw std::runtime_error("not supported node type in bvh_statistics");208+ abort(); //throw std::runtime_error("not supported node type in bvh_statistics");209}210return s;211}212diff --git a/thirdparty/embree/kernels/common/alloc.h b/thirdparty/embree/kernels/common/alloc.h213index 2bd292de4d..10f629a244 100644214--- a/thirdparty/embree/kernels/common/alloc.h215+++ b/thirdparty/embree/kernels/common/alloc.h216@@ -190,7 +190,7 @@ namespace embree217, primrefarray(device,0)218{219if (osAllocation && useUSM)220- throw std::runtime_error("USM allocation cannot be combined with OS allocation.");221+ abort(); //throw std::runtime_error("USM allocation cannot be combined with OS allocation.");222223for (size_t i=0; i<MAX_THREAD_USED_BLOCK_SLOTS; i++)224{225@@ -503,7 +503,7 @@ namespace embree226if (myUsedBlocks) {227void* ptr = myUsedBlocks->malloc(device,bytes,align,partial);228if (ptr == nullptr && !blockAllocation)229- throw std::bad_alloc();230+ abort(); //throw std::bad_alloc();231if (ptr) return ptr;232}233234diff --git a/thirdparty/embree/kernels/common/rtcore.cpp b/thirdparty/embree/kernels/common/rtcore.cpp235index 8da5c9d86c..a34eb2a0c4 100644236--- a/thirdparty/embree/kernels/common/rtcore.cpp237+++ b/thirdparty/embree/kernels/common/rtcore.cpp238@@ -358,7 +358,7 @@ RTC_NAMESPACE_BEGIN;239if (quality != RTC_BUILD_QUALITY_LOW &&240quality != RTC_BUILD_QUALITY_MEDIUM &&241quality != RTC_BUILD_QUALITY_HIGH)242- throw std::runtime_error("invalid build quality");243+ abort(); //throw std::runtime_error("invalid build quality");244scene->setBuildQuality(quality);245RTC_CATCH_END2(scene);246}247@@ -1831,7 +1831,7 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte248quality != RTC_BUILD_QUALITY_MEDIUM &&249quality != RTC_BUILD_QUALITY_HIGH &&250quality != RTC_BUILD_QUALITY_REFIT)251- throw std::runtime_error("invalid build quality");252+ abort(); //throw std::runtime_error("invalid build quality");253geometry->setBuildQuality(quality);254RTC_CATCH_END2(geometry);255}256diff --git a/thirdparty/embree/kernels/common/rtcore.h b/thirdparty/embree/kernels/common/rtcore.h257index 73a061de11..cd7a6f4395 100644258--- a/thirdparty/embree/kernels/common/rtcore.h259+++ b/thirdparty/embree/kernels/common/rtcore.h260@@ -13,7 +13,7 @@ namespace embree261__forceinline bool isIncoherent(RTCRayQueryFlags flags) { return (flags & RTC_RAY_QUERY_FLAG_COHERENT) == RTC_RAY_QUERY_FLAG_INCOHERENT; }262263/*! Macros used in the rtcore API implementation */264-#if 0265+#if 1266# define RTC_CATCH_BEGIN267# define RTC_CATCH_END(device)268# define RTC_CATCH_END2(scene)269@@ -94,6 +94,7 @@ namespace embree270#define RTC_TRACE(x)271#endif272273+#if 0274/*! used to throw embree API errors */275struct rtcore_error : public std::exception276{277@@ -109,13 +110,16 @@ namespace embree278RTCError error;279std::string str;280};281+#endif282283#if defined(DEBUG) // only report file and line in debug mode284#define throw_RTCError(error,str) \285- throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));286+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();287+ //throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));288#else289#define throw_RTCError(error,str) \290- throw rtcore_error(error,str);291+ abort();292+ //throw rtcore_error(error,str);293#endif294295#define RTC_BUILD_ARGUMENTS_HAS(settings,member) \296diff --git a/thirdparty/embree/kernels/common/scene.cpp b/thirdparty/embree/kernels/common/scene.cpp297index 84a84f8c69..3bfcebd298 100644298--- a/thirdparty/embree/kernels/common/scene.cpp299+++ b/thirdparty/embree/kernels/common/scene.cpp300@@ -962,16 +962,16 @@ namespace embree301}302303/* initiate build */304- try {305+ //try {306TaskScheduler::TaskGroupContext context;307scheduler->spawn_root([&]() { commit_task(); Lock<MutexSys> lock(taskGroup->schedulerMutex); taskGroup->scheduler = nullptr; }, &context, 1, !join);308- }309- catch (...) {310- accels_clear();311- Lock<MutexSys> lock(taskGroup->schedulerMutex);312- taskGroup->scheduler = nullptr;313- throw;314- }315+ //}316+ //catch (...) {317+ // accels_clear();318+ // Lock<MutexSys> lock(taskGroup->schedulerMutex);319+ // taskGroup->scheduler = nullptr;320+ // throw;321+ //}322}323324#endif325diff --git a/thirdparty/embree/kernels/common/state.cpp b/thirdparty/embree/kernels/common/state.cpp326index cce5eafce1..509dbc7120 100644327--- a/thirdparty/embree/kernels/common/state.cpp328+++ b/thirdparty/embree/kernels/common/state.cpp329@@ -199,13 +199,13 @@ namespace embree330bool State::parseFile(const FileName& fileName)331{332Ref<Stream<int> > file;333- try {334+ //try {335file = new FileStream(fileName);336- }337- catch (std::runtime_error& e) {338- (void) e;339- return false;340- }341+ //}342+ //catch (std::runtime_error& e) {343+ // (void) e;344+ // return false;345+ //}346347std::vector<std::string> syms;348for (size_t i=0; i<sizeof(symbols)/sizeof(void*); i++)349350351