mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Thirdparty: Harmonize patches to document downstream changes
This commit is contained in:
@@ -58,19 +58,15 @@ namespace embree
|
||||
const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
|
||||
[&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },
|
||||
reduction,context);
|
||||
// -- GODOT start --
|
||||
// if (context.is_group_execution_cancelled())
|
||||
// throw std::runtime_error("task cancelled");
|
||||
// -- GODOT end --
|
||||
//if (context.is_group_execution_cancelled())
|
||||
// throw std::runtime_error("task cancelled");
|
||||
return v;
|
||||
#else
|
||||
const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
|
||||
[&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },
|
||||
reduction);
|
||||
// -- GODOT start --
|
||||
// if (tbb::task::self().is_cancelled())
|
||||
// throw std::runtime_error("task cancelled");
|
||||
// -- GODOT end --
|
||||
//if (tbb::task::self().is_cancelled())
|
||||
// throw std::runtime_error("task cancelled");
|
||||
return v;
|
||||
#endif
|
||||
#else // TASKING_PPL
|
||||
|
||||
@@ -39,12 +39,10 @@ namespace embree
|
||||
std::vector<char> str; str.reserve(64);
|
||||
while (cin->peek() != EOF && !isSeparator(cin->peek())) {
|
||||
int c = cin->get();
|
||||
// -- GODOT start --
|
||||
// if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
|
||||
//if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
|
||||
if (!isValidChar(c)) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
str.push_back((char)c);
|
||||
}
|
||||
str.push_back(0);
|
||||
|
||||
6
thirdparty/embree/common/simd/arm/sse2neon.h
vendored
6
thirdparty/embree/common/simd/arm/sse2neon.h
vendored
@@ -102,9 +102,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// -- GODOT start --
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
// -- GODOT end --
|
||||
/* Definitions for _mm_{malloc,free} are provided by <malloc.h>
|
||||
* from both MinGW-w64 and MSVC.
|
||||
*/
|
||||
@@ -1890,13 +1888,11 @@ FORCE_INLINE __m128 _mm_div_ss(__m128 a, __m128 b)
|
||||
#if !defined(SSE2NEON_ALLOC_DEFINED)
|
||||
FORCE_INLINE void _mm_free(void *addr)
|
||||
{
|
||||
// -- GODOT start --
|
||||
#if defined(_WIN32)
|
||||
_aligned_free(addr);
|
||||
#else
|
||||
free(addr);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2088,7 +2084,6 @@ FORCE_INLINE void *_mm_malloc(size_t size, size_t align)
|
||||
return malloc(size);
|
||||
if (align == 2 || (sizeof(void *) == 8 && align == 4))
|
||||
align = sizeof(void *);
|
||||
// -- GODOT start --
|
||||
#if defined(_WIN32)
|
||||
ptr = _aligned_malloc(size, align);
|
||||
if (ptr)
|
||||
@@ -2097,7 +2092,6 @@ FORCE_INLINE void *_mm_malloc(size_t size, size_t align)
|
||||
if (!posix_memalign(&ptr, align, size))
|
||||
return ptr;
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
62
thirdparty/embree/common/sys/alloc.cpp
vendored
62
thirdparty/embree/common/sys/alloc.cpp
vendored
@@ -24,32 +24,28 @@ namespace embree
|
||||
|
||||
void enableUSMAllocEmbree(sycl::context* context, sycl::device* device)
|
||||
{
|
||||
// -- GODOT start --
|
||||
// if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
// if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
//if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
//if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
if (tls_context_embree != nullptr) {
|
||||
abort();
|
||||
}
|
||||
if (tls_device_embree != nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
tls_context_embree = context;
|
||||
tls_device_embree = device;
|
||||
}
|
||||
|
||||
void disableUSMAllocEmbree()
|
||||
{
|
||||
// -- GODOT start --
|
||||
// if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
// if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
//if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
//if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
if (tls_context_embree == nullptr) {
|
||||
abort();
|
||||
}
|
||||
if (tls_device_embree == nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
tls_context_embree = nullptr;
|
||||
tls_device_embree = nullptr;
|
||||
}
|
||||
@@ -64,16 +60,14 @@ namespace embree
|
||||
|
||||
void disableUSMAllocTutorial()
|
||||
{
|
||||
// -- GODOT start --
|
||||
// if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
// if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
//if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
//if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
if (tls_context_tutorial == nullptr) {
|
||||
abort();
|
||||
}
|
||||
if (tls_device_tutorial == nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
tls_context_tutorial = nullptr;
|
||||
tls_device_tutorial = nullptr;
|
||||
@@ -88,13 +82,11 @@ namespace embree
|
||||
|
||||
assert((align & (align-1)) == 0);
|
||||
void* ptr = _mm_malloc(size,align);
|
||||
// -- GODOT start --
|
||||
// if (size != 0 && ptr == nullptr)
|
||||
// throw std::bad_alloc();
|
||||
//if (size != 0 && ptr == nullptr)
|
||||
// throw std::bad_alloc();
|
||||
if (size != 0 && ptr == nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -123,13 +115,11 @@ namespace embree
|
||||
else
|
||||
ptr = sycl::aligned_alloc_shared(align,size,*device,*context);
|
||||
|
||||
// -- GODOT start --
|
||||
// if (size != 0 && ptr == nullptr)
|
||||
// throw std::bad_alloc();
|
||||
//if (size != 0 && ptr == nullptr)
|
||||
// throw std::bad_alloc();
|
||||
if (size != 0 && ptr == nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -275,12 +265,10 @@ namespace embree
|
||||
/* fall back to 4k pages */
|
||||
int flags = MEM_COMMIT | MEM_RESERVE;
|
||||
char* ptr = (char*) VirtualAlloc(nullptr,bytes,flags,PAGE_READWRITE);
|
||||
// -- GODOT start --
|
||||
// if (ptr == nullptr) throw std::bad_alloc();
|
||||
//if (ptr == nullptr) throw std::bad_alloc();
|
||||
if (ptr == nullptr) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
hugepages = false;
|
||||
return ptr;
|
||||
}
|
||||
@@ -296,13 +284,11 @@ namespace embree
|
||||
if (bytesNew >= bytesOld)
|
||||
return bytesOld;
|
||||
|
||||
// -- GODOT start --
|
||||
// if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
|
||||
// throw std::bad_alloc();
|
||||
//if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
|
||||
// throw std::bad_alloc();
|
||||
if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT)) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
return bytesNew;
|
||||
}
|
||||
@@ -312,13 +298,11 @@ namespace embree
|
||||
if (bytes == 0)
|
||||
return;
|
||||
|
||||
// -- GODOT start --
|
||||
// if (!VirtualFree(ptr,0,MEM_RELEASE))
|
||||
// throw std::bad_alloc();
|
||||
//if (!VirtualFree(ptr,0,MEM_RELEASE))
|
||||
// throw std::bad_alloc();
|
||||
if (!VirtualFree(ptr,0,MEM_RELEASE)) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
}
|
||||
|
||||
void os_advise(void *ptr, size_t bytes)
|
||||
@@ -422,12 +406,10 @@ namespace embree
|
||||
|
||||
/* fallback to 4k pages */
|
||||
void* ptr = (char*) mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
// -- GODOT start --
|
||||
// if (ptr == MAP_FAILED) throw std::bad_alloc();
|
||||
//if (ptr == MAP_FAILED) throw std::bad_alloc();
|
||||
if (ptr == MAP_FAILED) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
hugepages = false;
|
||||
|
||||
/* advise huge page hint for THP */
|
||||
@@ -443,13 +425,11 @@ namespace embree
|
||||
if (bytesNew >= bytesOld)
|
||||
return bytesOld;
|
||||
|
||||
// -- GODOT start --
|
||||
// if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
|
||||
// throw std::bad_alloc();
|
||||
//if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
|
||||
// throw std::bad_alloc();
|
||||
if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
return bytesNew;
|
||||
}
|
||||
@@ -462,13 +442,11 @@ namespace embree
|
||||
/* for hugepages we need to also align the size */
|
||||
const size_t pageSize = hugepages ? PAGE_SIZE_2M : PAGE_SIZE_4K;
|
||||
bytes = (bytes+pageSize-1) & ~(pageSize-1);
|
||||
// -- GODOT start --
|
||||
// if (munmap(ptr,bytes) == -1)
|
||||
// throw std::bad_alloc();
|
||||
//if (munmap(ptr,bytes) == -1)
|
||||
// throw std::bad_alloc();
|
||||
if (munmap(ptr,bytes) == -1) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
}
|
||||
|
||||
/* hint for transparent huge pages (THP) */
|
||||
|
||||
4
thirdparty/embree/common/sys/alloc.h
vendored
4
thirdparty/embree/common/sys/alloc.h
vendored
@@ -160,10 +160,8 @@ namespace embree
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
__forceinline pointer allocate( size_type n ) {
|
||||
// -- GODOT start --
|
||||
// throw std::runtime_error("no allocation supported");
|
||||
//throw std::runtime_error("no allocation supported");
|
||||
abort();
|
||||
// -- GODOT end --
|
||||
}
|
||||
|
||||
__forceinline void deallocate( pointer p, size_type n ) {
|
||||
|
||||
12
thirdparty/embree/common/sys/platform.h
vendored
12
thirdparty/embree/common/sys/platform.h
vendored
@@ -213,19 +213,15 @@
|
||||
#define UPRINT4(x,y,z,w) embree_cout_uniform << STRING(x) << " = " << (x) << ", " << STRING(y) << " = " << (y) << ", " << STRING(z) << " = " << (z) << ", " << STRING(w) << " = " << (w) << embree_endl
|
||||
|
||||
#if defined(DEBUG) // only report file and line in debug mode
|
||||
// -- GODOT start --
|
||||
// #define THROW_RUNTIME_ERROR(str) \
|
||||
// throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
//#define THROW_RUNTIME_ERROR(str) \
|
||||
// throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
#define THROW_RUNTIME_ERROR(str) \
|
||||
printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
|
||||
// -- GODOT end --
|
||||
#else
|
||||
// -- GODOT start --
|
||||
// #define THROW_RUNTIME_ERROR(str) \
|
||||
// throw std::runtime_error(str);
|
||||
//#define THROW_RUNTIME_ERROR(str) \
|
||||
// throw std::runtime_error(str);
|
||||
#define THROW_RUNTIME_ERROR(str) \
|
||||
abort();
|
||||
// -- GODOT end --
|
||||
#endif
|
||||
|
||||
#define FATAL(x) THROW_RUNTIME_ERROR(x)
|
||||
|
||||
21
thirdparty/embree/common/sys/sysinfo.cpp
vendored
21
thirdparty/embree/common/sys/sysinfo.cpp
vendored
@@ -647,11 +647,9 @@ namespace embree
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include <emscripten.h>
|
||||
|
||||
// -- GODOT start --
|
||||
extern "C" {
|
||||
extern int godot_js_os_hw_concurrency_get();
|
||||
}
|
||||
// -- GODOT end --
|
||||
#endif
|
||||
|
||||
namespace embree
|
||||
@@ -665,9 +663,24 @@ namespace embree
|
||||
nThreads = sysconf(_SC_NPROCESSORS_ONLN); // does not work in Linux LXC container
|
||||
assert(nThreads);
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
// -- GODOT start --
|
||||
nThreads = godot_js_os_hw_concurrency_get();
|
||||
// -- GODOT end --
|
||||
#if 0
|
||||
// WebAssembly supports pthreads, but not pthread_getaffinity_np. Get the number of logical
|
||||
// threads from the browser or Node.js using JavaScript.
|
||||
nThreads = MAIN_THREAD_EM_ASM_INT({
|
||||
const isBrowser = typeof window !== 'undefined';
|
||||
const isNode = typeof process !== 'undefined' && process.versions != null &&
|
||||
process.versions.node != null;
|
||||
if (isBrowser) {
|
||||
// Return 1 if the browser does not expose hardwareConcurrency.
|
||||
return window.navigator.hardwareConcurrency || 1;
|
||||
} else if (isNode) {
|
||||
return require('os').cpus().length;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
#endif
|
||||
#else
|
||||
cpu_set_t set;
|
||||
if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
|
||||
|
||||
@@ -48,15 +48,13 @@ namespace embree
|
||||
{
|
||||
Task* prevTask = thread.task;
|
||||
thread.task = this;
|
||||
// -- GODOT start --
|
||||
// try {
|
||||
// if (context->cancellingException == nullptr)
|
||||
//try {
|
||||
// if (context->cancellingException == nullptr)
|
||||
closure->execute();
|
||||
// } catch (...) {
|
||||
// if (context->cancellingException == nullptr)
|
||||
// context->cancellingException = std::current_exception();
|
||||
// }
|
||||
// -- GODOT end --
|
||||
//} catch (...) {
|
||||
// if (context->cancellingException == nullptr)
|
||||
// context->cancellingException = std::current_exception();
|
||||
//}
|
||||
thread.task = prevTask;
|
||||
add_dependencies(-1);
|
||||
}
|
||||
|
||||
@@ -130,13 +130,11 @@ namespace embree
|
||||
__forceinline void* alloc(size_t bytes, size_t align = 64)
|
||||
{
|
||||
size_t ofs = bytes + ((align - stackPtr) & (align-1));
|
||||
// -- GODOT start --
|
||||
// if (stackPtr + ofs > CLOSURE_STACK_SIZE)
|
||||
// throw std::runtime_error("closure stack overflow");
|
||||
//if (stackPtr + ofs > CLOSURE_STACK_SIZE)
|
||||
// throw std::runtime_error("closure stack overflow");
|
||||
if (stackPtr + ofs > CLOSURE_STACK_SIZE) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
stackPtr += ofs;
|
||||
return &stack[stackPtr-bytes];
|
||||
}
|
||||
@@ -144,13 +142,11 @@ namespace embree
|
||||
template<typename Closure>
|
||||
__forceinline void push_right(Thread& thread, const size_t size, const Closure& closure, TaskGroupContext* context)
|
||||
{
|
||||
// -- GODOT start --
|
||||
// if (right >= TASK_STACK_SIZE)
|
||||
// throw std::runtime_error("task stack overflow");
|
||||
//if (right >= TASK_STACK_SIZE)
|
||||
// throw std::runtime_error("task stack overflow");
|
||||
if (right >= TASK_STACK_SIZE) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
/* allocate new task on right side of stack */
|
||||
size_t oldStackPtr = stackPtr;
|
||||
|
||||
@@ -150,10 +150,8 @@ namespace embree
|
||||
}
|
||||
}
|
||||
else {
|
||||
// -- GODOT start --
|
||||
// throw std::runtime_error("not supported node type in bvh_statistics");
|
||||
//throw std::runtime_error("not supported node type in bvh_statistics");
|
||||
abort();
|
||||
// -- GODOT end --
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
12
thirdparty/embree/kernels/common/alloc.h
vendored
12
thirdparty/embree/kernels/common/alloc.h
vendored
@@ -189,13 +189,11 @@ namespace embree
|
||||
, atype(osAllocation ? EMBREE_OS_MALLOC : ALIGNED_MALLOC)
|
||||
, primrefarray(device,0)
|
||||
{
|
||||
// -- GODOT start --
|
||||
// if (osAllocation && useUSM)
|
||||
// throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
|
||||
//if (osAllocation && useUSM)
|
||||
// throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
|
||||
if (osAllocation && useUSM) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
|
||||
for (size_t i=0; i<MAX_THREAD_USED_BLOCK_SLOTS; i++)
|
||||
{
|
||||
@@ -507,13 +505,11 @@ namespace embree
|
||||
Block* myUsedBlocks = threadUsedBlocks[slot];
|
||||
if (myUsedBlocks) {
|
||||
void* ptr = myUsedBlocks->malloc(device,bytes,align,partial);
|
||||
// -- GODOT start --
|
||||
// if (ptr == nullptr && !blockAllocation)
|
||||
// throw std::bad_alloc();
|
||||
//if (ptr == nullptr && !blockAllocation)
|
||||
// throw std::bad_alloc();
|
||||
if (ptr == nullptr && !blockAllocation) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
if (ptr) return ptr;
|
||||
}
|
||||
|
||||
|
||||
22
thirdparty/embree/kernels/common/rtcore.cpp
vendored
22
thirdparty/embree/kernels/common/rtcore.cpp
vendored
@@ -257,17 +257,15 @@ RTC_NAMESPACE_BEGIN;
|
||||
RTC_TRACE(rtcSetSceneBuildQuality);
|
||||
RTC_VERIFY_HANDLE(hscene);
|
||||
RTC_ENTER_DEVICE(hscene);
|
||||
// -- GODOT start --
|
||||
// if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
// quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
// quality != RTC_BUILD_QUALITY_HIGH)
|
||||
// throw std::runtime_error("invalid build quality");
|
||||
//if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
// quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
// quality != RTC_BUILD_QUALITY_HIGH)
|
||||
// throw std::runtime_error("invalid build quality");
|
||||
if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
quality != RTC_BUILD_QUALITY_HIGH) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
scene->setBuildQuality(quality);
|
||||
RTC_CATCH_END2(scene);
|
||||
}
|
||||
@@ -1570,19 +1568,17 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
|
||||
RTC_TRACE(rtcSetGeometryBuildQuality);
|
||||
RTC_VERIFY_HANDLE(hgeometry);
|
||||
RTC_ENTER_DEVICE(hgeometry);
|
||||
// -- GODOT start --
|
||||
// if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
// quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
// quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
// quality != RTC_BUILD_QUALITY_REFIT)
|
||||
// throw std::runtime_error("invalid build quality");
|
||||
//if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
// quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
// quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
// quality != RTC_BUILD_QUALITY_REFIT)
|
||||
// throw std::runtime_error("invalid build quality");
|
||||
if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
quality != RTC_BUILD_QUALITY_REFIT) {
|
||||
abort();
|
||||
}
|
||||
// -- GODOT end --
|
||||
geometry->setBuildQuality(quality);
|
||||
RTC_CATCH_END2(geometry);
|
||||
}
|
||||
|
||||
20
thirdparty/embree/kernels/common/rtcore.h
vendored
20
thirdparty/embree/kernels/common/rtcore.h
vendored
@@ -13,13 +13,13 @@ namespace embree
|
||||
__forceinline bool isIncoherent(RTCRayQueryFlags flags) { return (flags & RTC_RAY_QUERY_FLAG_COHERENT) == RTC_RAY_QUERY_FLAG_INCOHERENT; }
|
||||
|
||||
/*! Macros used in the rtcore API implementation */
|
||||
// -- GODOT start --
|
||||
#define RTC_CATCH_BEGIN
|
||||
#define RTC_CATCH_END(device)
|
||||
#define RTC_CATCH_END2(scene)
|
||||
#define RTC_CATCH_END2_FALSE(scene) return false;
|
||||
#if 0
|
||||
// -- GODOT end --
|
||||
#if 1
|
||||
# define RTC_CATCH_BEGIN
|
||||
# define RTC_CATCH_END(device)
|
||||
# define RTC_CATCH_END2(scene)
|
||||
# define RTC_CATCH_END2_FALSE(scene) return false;
|
||||
#else
|
||||
|
||||
#define RTC_CATCH_BEGIN try {
|
||||
|
||||
#define RTC_CATCH_END(device) \
|
||||
@@ -94,7 +94,6 @@ namespace embree
|
||||
#define RTC_TRACE(x)
|
||||
#endif
|
||||
|
||||
// -- GODOT start --
|
||||
#if 0
|
||||
/*! used to throw embree API errors */
|
||||
struct rtcore_error : public std::exception
|
||||
@@ -116,13 +115,12 @@ namespace embree
|
||||
#if defined(DEBUG) // only report file and line in debug mode
|
||||
#define throw_RTCError(error,str) \
|
||||
printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
|
||||
// throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
//throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
#else
|
||||
#define throw_RTCError(error,str) \
|
||||
abort();
|
||||
// throw rtcore_error(error,str);
|
||||
//throw rtcore_error(error,str);
|
||||
#endif
|
||||
// -- GODOT end --
|
||||
|
||||
#define RTC_BUILD_ARGUMENTS_HAS(settings,member) \
|
||||
(settings.byteSize > (offsetof(RTCBuildArguments,member)+sizeof(settings.member)))
|
||||
|
||||
18
thirdparty/embree/kernels/common/scene.cpp
vendored
18
thirdparty/embree/kernels/common/scene.cpp
vendored
@@ -894,18 +894,16 @@ namespace embree
|
||||
}
|
||||
|
||||
/* initiate build */
|
||||
// -- GODOT start --
|
||||
// try {
|
||||
//try {
|
||||
TaskScheduler::TaskGroupContext context;
|
||||
scheduler->spawn_root([&]() { commit_task(); Lock<MutexSys> lock(taskGroup->schedulerMutex); taskGroup->scheduler = nullptr; }, &context, 1, !join);
|
||||
// }
|
||||
// catch (...) {
|
||||
// accels_clear();
|
||||
// Lock<MutexSys> lock(taskGroup->schedulerMutex);
|
||||
// taskGroup->scheduler = nullptr;
|
||||
// throw;
|
||||
// }
|
||||
// -- GODOT end --
|
||||
//}
|
||||
//catch (...) {
|
||||
// accels_clear();
|
||||
// Lock<MutexSys> lock(taskGroup->schedulerMutex);
|
||||
// taskGroup->scheduler = nullptr;
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
14
thirdparty/embree/kernels/common/state.cpp
vendored
14
thirdparty/embree/kernels/common/state.cpp
vendored
@@ -194,15 +194,13 @@ namespace embree
|
||||
bool State::parseFile(const FileName& fileName)
|
||||
{
|
||||
Ref<Stream<int> > file;
|
||||
// -- GODOT start --
|
||||
// try {
|
||||
//try {
|
||||
file = new FileStream(fileName);
|
||||
// }
|
||||
// catch (std::runtime_error& e) {
|
||||
// (void) e;
|
||||
// return false;
|
||||
// }
|
||||
// -- GODOT end --
|
||||
//}
|
||||
//catch (std::runtime_error& e) {
|
||||
// (void) e;
|
||||
// return false;
|
||||
//}
|
||||
|
||||
std::vector<std::string> syms;
|
||||
for (size_t i=0; i<sizeof(symbols)/sizeof(void*); i++)
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
diff --git a/thirdparty/embree/common/algorithms/parallel_reduce.h b/thirdparty/embree/common/algorithms/parallel_reduce.h
|
||||
index b52b1e2e13..51ec0a6405 100644
|
||||
index b52b1e2e13..fbff38f660 100644
|
||||
--- a/thirdparty/embree/common/algorithms/parallel_reduce.h
|
||||
+++ b/thirdparty/embree/common/algorithms/parallel_reduce.h
|
||||
@@ -58,15 +58,19 @@ namespace embree
|
||||
@@ -58,15 +58,15 @@ namespace embree
|
||||
const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
|
||||
[&](const tbb::blocked_range<Index>& r, const Value& start) { return reduction(start,func(range<Index>(r.begin(),r.end()))); },
|
||||
reduction,context);
|
||||
- if (context.is_group_execution_cancelled())
|
||||
- throw std::runtime_error("task cancelled");
|
||||
+ // -- GODOT start --
|
||||
+ // if (context.is_group_execution_cancelled())
|
||||
+ // throw std::runtime_error("task cancelled");
|
||||
+ // -- GODOT end --
|
||||
+ //if (context.is_group_execution_cancelled())
|
||||
+ // throw std::runtime_error("task cancelled");
|
||||
return v;
|
||||
#else
|
||||
const Value v = tbb::parallel_reduce(tbb::blocked_range<Index>(first,last,minStepSize),identity,
|
||||
@@ -19,51 +17,45 @@ index b52b1e2e13..51ec0a6405 100644
|
||||
reduction);
|
||||
- if (tbb::task::self().is_cancelled())
|
||||
- throw std::runtime_error("task cancelled");
|
||||
+ // -- GODOT start --
|
||||
+ // if (tbb::task::self().is_cancelled())
|
||||
+ // throw std::runtime_error("task cancelled");
|
||||
+ // -- GODOT end --
|
||||
+ //if (tbb::task::self().is_cancelled())
|
||||
+ // throw std::runtime_error("task cancelled");
|
||||
return v;
|
||||
#endif
|
||||
#else // TASKING_PPL
|
||||
diff --git a/thirdparty/embree/common/lexers/stringstream.cpp b/thirdparty/embree/common/lexers/stringstream.cpp
|
||||
index 42ffb10176..c93da0b420 100644
|
||||
index 42ffb10176..fa4266d0b9 100644
|
||||
--- a/thirdparty/embree/common/lexers/stringstream.cpp
|
||||
+++ b/thirdparty/embree/common/lexers/stringstream.cpp
|
||||
@@ -39,7 +39,12 @@ namespace embree
|
||||
@@ -39,7 +39,10 @@ namespace embree
|
||||
std::vector<char> str; str.reserve(64);
|
||||
while (cin->peek() != EOF && !isSeparator(cin->peek())) {
|
||||
int c = cin->get();
|
||||
- if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
|
||||
+ // -- GODOT start --
|
||||
+ // if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
|
||||
+ //if (!isValidChar(c)) throw std::runtime_error("invalid character "+std::string(1,c)+" in input");
|
||||
+ if (!isValidChar(c)) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
str.push_back((char)c);
|
||||
}
|
||||
str.push_back(0);
|
||||
diff --git a/thirdparty/embree/common/sys/alloc.cpp b/thirdparty/embree/common/sys/alloc.cpp
|
||||
index de225fafc6..71616a3982 100644
|
||||
index de225fafc6..8e83646031 100644
|
||||
--- a/thirdparty/embree/common/sys/alloc.cpp
|
||||
+++ b/thirdparty/embree/common/sys/alloc.cpp
|
||||
@@ -24,16 +24,32 @@ namespace embree
|
||||
@@ -24,16 +24,28 @@ namespace embree
|
||||
|
||||
void enableUSMAllocEmbree(sycl::context* context, sycl::device* device)
|
||||
{
|
||||
- if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
- if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
+ // -- GODOT start --
|
||||
+ // if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
+ // if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
+ //if (tls_context_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
+ //if (tls_device_embree != nullptr) throw std::runtime_error("USM allocation already enabled");
|
||||
+ if (tls_context_embree != nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ if (tls_device_embree != nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
tls_context_embree = context;
|
||||
tls_device_embree = device;
|
||||
}
|
||||
@@ -72,331 +64,292 @@ index de225fafc6..71616a3982 100644
|
||||
{
|
||||
- if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
- if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ // -- GODOT start --
|
||||
+ // if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ // if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ //if (tls_context_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ //if (tls_device_embree == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ if (tls_context_embree == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ if (tls_device_embree == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
tls_context_embree = nullptr;
|
||||
tls_device_embree = nullptr;
|
||||
}
|
||||
@@ -48,8 +64,16 @@ namespace embree
|
||||
@@ -48,8 +60,14 @@ namespace embree
|
||||
|
||||
void disableUSMAllocTutorial()
|
||||
{
|
||||
- if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
- if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ // -- GODOT start --
|
||||
+ // if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ // if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ //if (tls_context_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ //if (tls_device_tutorial == nullptr) throw std::runtime_error("USM allocation not enabled");
|
||||
+ if (tls_context_tutorial == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ if (tls_device_tutorial == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
tls_context_tutorial = nullptr;
|
||||
tls_device_tutorial = nullptr;
|
||||
@@ -64,8 +88,13 @@ namespace embree
|
||||
@@ -64,8 +82,11 @@ namespace embree
|
||||
|
||||
assert((align & (align-1)) == 0);
|
||||
void* ptr = _mm_malloc(size,align);
|
||||
- if (size != 0 && ptr == nullptr)
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (size != 0 && ptr == nullptr)
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (size != 0 && ptr == nullptr)
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (size != 0 && ptr == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -94,8 +123,13 @@ namespace embree
|
||||
@@ -94,8 +115,11 @@ namespace embree
|
||||
else
|
||||
ptr = sycl::aligned_alloc_shared(align,size,*device,*context);
|
||||
|
||||
- if (size != 0 && ptr == nullptr)
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (size != 0 && ptr == nullptr)
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (size != 0 && ptr == nullptr)
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (size != 0 && ptr == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -241,7 +275,12 @@ namespace embree
|
||||
@@ -241,7 +265,10 @@ namespace embree
|
||||
/* fall back to 4k pages */
|
||||
int flags = MEM_COMMIT | MEM_RESERVE;
|
||||
char* ptr = (char*) VirtualAlloc(nullptr,bytes,flags,PAGE_READWRITE);
|
||||
- if (ptr == nullptr) throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (ptr == nullptr) throw std::bad_alloc();
|
||||
+ //if (ptr == nullptr) throw std::bad_alloc();
|
||||
+ if (ptr == nullptr) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
hugepages = false;
|
||||
return ptr;
|
||||
}
|
||||
@@ -257,8 +296,13 @@ namespace embree
|
||||
@@ -257,8 +284,11 @@ namespace embree
|
||||
if (bytesNew >= bytesOld)
|
||||
return bytesOld;
|
||||
|
||||
- if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT))
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (!VirtualFree((char*)ptr+bytesNew,bytesOld-bytesNew,MEM_DECOMMIT)) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
return bytesNew;
|
||||
}
|
||||
@@ -268,8 +312,13 @@ namespace embree
|
||||
@@ -268,8 +298,11 @@ namespace embree
|
||||
if (bytes == 0)
|
||||
return;
|
||||
|
||||
- if (!VirtualFree(ptr,0,MEM_RELEASE))
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (!VirtualFree(ptr,0,MEM_RELEASE))
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (!VirtualFree(ptr,0,MEM_RELEASE))
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (!VirtualFree(ptr,0,MEM_RELEASE)) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
}
|
||||
|
||||
void os_advise(void *ptr, size_t bytes)
|
||||
@@ -373,7 +422,12 @@ namespace embree
|
||||
@@ -373,7 +406,10 @@ namespace embree
|
||||
|
||||
/* fallback to 4k pages */
|
||||
void* ptr = (char*) mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
- if (ptr == MAP_FAILED) throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (ptr == MAP_FAILED) throw std::bad_alloc();
|
||||
+ //if (ptr == MAP_FAILED) throw std::bad_alloc();
|
||||
+ if (ptr == MAP_FAILED) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
hugepages = false;
|
||||
|
||||
/* advise huge page hint for THP */
|
||||
@@ -389,8 +443,13 @@ namespace embree
|
||||
@@ -389,8 +425,11 @@ namespace embree
|
||||
if (bytesNew >= bytesOld)
|
||||
return bytesOld;
|
||||
|
||||
- if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1)
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (munmap((char*)ptr+bytesNew,bytesOld-bytesNew) == -1) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
return bytesNew;
|
||||
}
|
||||
@@ -403,8 +462,13 @@ namespace embree
|
||||
@@ -403,8 +442,11 @@ namespace embree
|
||||
/* for hugepages we need to also align the size */
|
||||
const size_t pageSize = hugepages ? PAGE_SIZE_2M : PAGE_SIZE_4K;
|
||||
bytes = (bytes+pageSize-1) & ~(pageSize-1);
|
||||
- if (munmap(ptr,bytes) == -1)
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (munmap(ptr,bytes) == -1)
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (munmap(ptr,bytes) == -1)
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (munmap(ptr,bytes) == -1) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
}
|
||||
|
||||
/* hint for transparent huge pages (THP) */
|
||||
diff --git a/thirdparty/embree/common/sys/alloc.h b/thirdparty/embree/common/sys/alloc.h
|
||||
index e19c2c221a..28b17f988d 100644
|
||||
index e19c2c221a..e2c942049a 100644
|
||||
--- a/thirdparty/embree/common/sys/alloc.h
|
||||
+++ b/thirdparty/embree/common/sys/alloc.h
|
||||
@@ -160,7 +160,10 @@ namespace embree
|
||||
@@ -160,7 +160,8 @@ namespace embree
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
__forceinline pointer allocate( size_type n ) {
|
||||
- throw std::runtime_error("no allocation supported");
|
||||
+ // -- GODOT start --
|
||||
+ // throw std::runtime_error("no allocation supported");
|
||||
+ //throw std::runtime_error("no allocation supported");
|
||||
+ abort();
|
||||
+ // -- GODOT end --
|
||||
}
|
||||
|
||||
__forceinline void deallocate( pointer p, size_type n ) {
|
||||
diff --git a/thirdparty/embree/common/sys/platform.h b/thirdparty/embree/common/sys/platform.h
|
||||
index 6dc0cf3318..d4a9b9e119 100644
|
||||
index 6dc0cf3318..9f08cd1516 100644
|
||||
--- a/thirdparty/embree/common/sys/platform.h
|
||||
+++ b/thirdparty/embree/common/sys/platform.h
|
||||
@@ -213,11 +213,19 @@
|
||||
@@ -213,11 +213,15 @@
|
||||
#define UPRINT4(x,y,z,w) embree_cout_uniform << STRING(x) << " = " << (x) << ", " << STRING(y) << " = " << (y) << ", " << STRING(z) << " = " << (z) << ", " << STRING(w) << " = " << (w) << embree_endl
|
||||
|
||||
#if defined(DEBUG) // only report file and line in debug mode
|
||||
+ // -- GODOT start --
|
||||
+ // #define THROW_RUNTIME_ERROR(str) \
|
||||
+ // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
+ //#define THROW_RUNTIME_ERROR(str) \
|
||||
+ // throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
#define THROW_RUNTIME_ERROR(str) \
|
||||
- throw std::runtime_error(std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
|
||||
+ // -- GODOT end --
|
||||
#else
|
||||
+ // -- GODOT start --
|
||||
+ // #define THROW_RUNTIME_ERROR(str) \
|
||||
+ // throw std::runtime_error(str);
|
||||
+ //#define THROW_RUNTIME_ERROR(str) \
|
||||
+ // throw std::runtime_error(str);
|
||||
#define THROW_RUNTIME_ERROR(str) \
|
||||
- throw std::runtime_error(str);
|
||||
+ abort();
|
||||
+ // -- GODOT end --
|
||||
#endif
|
||||
|
||||
#define FATAL(x) THROW_RUNTIME_ERROR(x)
|
||||
diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
|
||||
index 83ead95122..88b88a30ec 100644
|
||||
index 83ead95122..e89ae04f8b 100644
|
||||
--- a/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
|
||||
+++ b/thirdparty/embree/common/tasking/taskschedulerinternal.cpp
|
||||
@@ -48,13 +48,15 @@ namespace embree
|
||||
@@ -48,13 +48,13 @@ namespace embree
|
||||
{
|
||||
Task* prevTask = thread.task;
|
||||
thread.task = this;
|
||||
- try {
|
||||
- if (context->cancellingException == nullptr)
|
||||
+ // -- GODOT start --
|
||||
+ // try {
|
||||
+ // if (context->cancellingException == nullptr)
|
||||
+ //try {
|
||||
+ // if (context->cancellingException == nullptr)
|
||||
closure->execute();
|
||||
- } catch (...) {
|
||||
- if (context->cancellingException == nullptr)
|
||||
- context->cancellingException = std::current_exception();
|
||||
- }
|
||||
+ // } catch (...) {
|
||||
+ // if (context->cancellingException == nullptr)
|
||||
+ // context->cancellingException = std::current_exception();
|
||||
+ // }
|
||||
+ // -- GODOT end --
|
||||
+ //} catch (...) {
|
||||
+ // if (context->cancellingException == nullptr)
|
||||
+ // context->cancellingException = std::current_exception();
|
||||
+ //}
|
||||
thread.task = prevTask;
|
||||
add_dependencies(-1);
|
||||
}
|
||||
diff --git a/thirdparty/embree/common/tasking/taskschedulerinternal.h b/thirdparty/embree/common/tasking/taskschedulerinternal.h
|
||||
index 355648b3f8..e72d3b72ba 100644
|
||||
index b01bebf7c3..4a04323b80 100644
|
||||
--- a/thirdparty/embree/common/tasking/taskschedulerinternal.h
|
||||
+++ b/thirdparty/embree/common/tasking/taskschedulerinternal.h
|
||||
@@ -130,8 +130,13 @@ namespace embree
|
||||
@@ -130,8 +130,11 @@ namespace embree
|
||||
__forceinline void* alloc(size_t bytes, size_t align = 64)
|
||||
{
|
||||
size_t ofs = bytes + ((align - stackPtr) & (align-1));
|
||||
- if (stackPtr + ofs > CLOSURE_STACK_SIZE)
|
||||
- throw std::runtime_error("closure stack overflow");
|
||||
+ // -- GODOT start --
|
||||
+ // if (stackPtr + ofs > CLOSURE_STACK_SIZE)
|
||||
+ // throw std::runtime_error("closure stack overflow");
|
||||
+ //if (stackPtr + ofs > CLOSURE_STACK_SIZE)
|
||||
+ // throw std::runtime_error("closure stack overflow");
|
||||
+ if (stackPtr + ofs > CLOSURE_STACK_SIZE) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
stackPtr += ofs;
|
||||
return &stack[stackPtr-bytes];
|
||||
}
|
||||
@@ -139,8 +144,13 @@ namespace embree
|
||||
@@ -139,8 +142,11 @@ namespace embree
|
||||
template<typename Closure>
|
||||
__forceinline void push_right(Thread& thread, const size_t size, const Closure& closure, TaskGroupContext* context)
|
||||
{
|
||||
- if (right >= TASK_STACK_SIZE)
|
||||
- throw std::runtime_error("task stack overflow");
|
||||
+ // -- GODOT start --
|
||||
+ // if (right >= TASK_STACK_SIZE)
|
||||
+ // throw std::runtime_error("task stack overflow");
|
||||
+ //if (right >= TASK_STACK_SIZE)
|
||||
+ // throw std::runtime_error("task stack overflow");
|
||||
+ if (right >= TASK_STACK_SIZE) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
/* allocate new task on right side of stack */
|
||||
size_t oldStackPtr = stackPtr;
|
||||
diff --git a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
|
||||
index 40f9043736..57f75bfd7e 100644
|
||||
index 40f9043736..7ea9736c5c 100644
|
||||
--- a/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
|
||||
+++ b/thirdparty/embree/kernels/bvh/bvh_statistics.cpp
|
||||
@@ -150,7 +150,10 @@ namespace embree
|
||||
@@ -150,7 +150,8 @@ namespace embree
|
||||
}
|
||||
}
|
||||
else {
|
||||
- throw std::runtime_error("not supported node type in bvh_statistics");
|
||||
+ // -- GODOT start --
|
||||
+ // throw std::runtime_error("not supported node type in bvh_statistics");
|
||||
+ //throw std::runtime_error("not supported node type in bvh_statistics");
|
||||
+ abort();
|
||||
+ // -- GODOT end --
|
||||
}
|
||||
return s;
|
||||
}
|
||||
diff --git a/thirdparty/embree/kernels/common/alloc.h b/thirdparty/embree/kernels/common/alloc.h
|
||||
index 2bd292de4d..840d48c327 100644
|
||||
index 2bd292de4d..8ac22e53ec 100644
|
||||
--- a/thirdparty/embree/kernels/common/alloc.h
|
||||
+++ b/thirdparty/embree/kernels/common/alloc.h
|
||||
@@ -189,8 +189,13 @@ namespace embree
|
||||
@@ -189,8 +189,11 @@ namespace embree
|
||||
, atype(osAllocation ? EMBREE_OS_MALLOC : ALIGNED_MALLOC)
|
||||
, primrefarray(device,0)
|
||||
{
|
||||
- if (osAllocation && useUSM)
|
||||
- throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
|
||||
+ // -- GODOT start --
|
||||
+ // if (osAllocation && useUSM)
|
||||
+ // throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
|
||||
+ //if (osAllocation && useUSM)
|
||||
+ // throw std::runtime_error("USM allocation cannot be combined with OS allocation.");
|
||||
+ if (osAllocation && useUSM) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
|
||||
for (size_t i=0; i<MAX_THREAD_USED_BLOCK_SLOTS; i++)
|
||||
{
|
||||
@@ -502,8 +507,13 @@ namespace embree
|
||||
@@ -502,8 +505,11 @@ namespace embree
|
||||
Block* myUsedBlocks = threadUsedBlocks[slot];
|
||||
if (myUsedBlocks) {
|
||||
void* ptr = myUsedBlocks->malloc(device,bytes,align,partial);
|
||||
- if (ptr == nullptr && !blockAllocation)
|
||||
- throw std::bad_alloc();
|
||||
+ // -- GODOT start --
|
||||
+ // if (ptr == nullptr && !blockAllocation)
|
||||
+ // throw std::bad_alloc();
|
||||
+ //if (ptr == nullptr && !blockAllocation)
|
||||
+ // throw std::bad_alloc();
|
||||
+ if (ptr == nullptr && !blockAllocation) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
if (ptr) return ptr;
|
||||
}
|
||||
|
||||
diff --git a/thirdparty/embree/kernels/common/rtcore.cpp b/thirdparty/embree/kernels/common/rtcore.cpp
|
||||
index 8dc5d7045b..eb8d2c0a58 100644
|
||||
index 8dc5d7045b..e19c243bf6 100644
|
||||
--- a/thirdparty/embree/kernels/common/rtcore.cpp
|
||||
+++ b/thirdparty/embree/kernels/common/rtcore.cpp
|
||||
@@ -257,10 +257,17 @@ RTC_NAMESPACE_BEGIN;
|
||||
@@ -257,10 +257,15 @@ RTC_NAMESPACE_BEGIN;
|
||||
RTC_TRACE(rtcSetSceneBuildQuality);
|
||||
RTC_VERIFY_HANDLE(hscene);
|
||||
RTC_ENTER_DEVICE(hscene);
|
||||
+ // -- GODOT start --
|
||||
+ // if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
+ // quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
+ // quality != RTC_BUILD_QUALITY_HIGH)
|
||||
+ // throw std::runtime_error("invalid build quality");
|
||||
+ //if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
+ // quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
+ // quality != RTC_BUILD_QUALITY_HIGH)
|
||||
+ // throw std::runtime_error("invalid build quality");
|
||||
if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
- quality != RTC_BUILD_QUALITY_HIGH)
|
||||
@@ -404,20 +357,18 @@ index 8dc5d7045b..eb8d2c0a58 100644
|
||||
+ quality != RTC_BUILD_QUALITY_HIGH) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
scene->setBuildQuality(quality);
|
||||
RTC_CATCH_END2(scene);
|
||||
}
|
||||
@@ -1563,11 +1570,19 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
|
||||
@@ -1563,11 +1568,17 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
|
||||
RTC_TRACE(rtcSetGeometryBuildQuality);
|
||||
RTC_VERIFY_HANDLE(hgeometry);
|
||||
RTC_ENTER_DEVICE(hgeometry);
|
||||
+ // -- GODOT start --
|
||||
+ // if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
+ // quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
+ // quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
+ // quality != RTC_BUILD_QUALITY_REFIT)
|
||||
+ // throw std::runtime_error("invalid build quality");
|
||||
+ //if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
+ // quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
+ // quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
+ // quality != RTC_BUILD_QUALITY_REFIT)
|
||||
+ // throw std::runtime_error("invalid build quality");
|
||||
if (quality != RTC_BUILD_QUALITY_LOW &&
|
||||
quality != RTC_BUILD_QUALITY_MEDIUM &&
|
||||
quality != RTC_BUILD_QUALITY_HIGH &&
|
||||
@@ -426,44 +377,31 @@ index 8dc5d7045b..eb8d2c0a58 100644
|
||||
+ quality != RTC_BUILD_QUALITY_REFIT) {
|
||||
+ abort();
|
||||
+ }
|
||||
+ // -- GODOT end --
|
||||
geometry->setBuildQuality(quality);
|
||||
RTC_CATCH_END2(geometry);
|
||||
}
|
||||
diff --git a/thirdparty/embree/kernels/common/rtcore.h b/thirdparty/embree/kernels/common/rtcore.h
|
||||
index 73a061de11..47526482c1 100644
|
||||
index 73a061de11..cd7a6f4395 100644
|
||||
--- a/thirdparty/embree/kernels/common/rtcore.h
|
||||
+++ b/thirdparty/embree/kernels/common/rtcore.h
|
||||
@@ -13,13 +13,13 @@ namespace embree
|
||||
@@ -13,7 +13,7 @@ namespace embree
|
||||
__forceinline bool isIncoherent(RTCRayQueryFlags flags) { return (flags & RTC_RAY_QUERY_FLAG_COHERENT) == RTC_RAY_QUERY_FLAG_INCOHERENT; }
|
||||
|
||||
/*! Macros used in the rtcore API implementation */
|
||||
+// -- GODOT start --
|
||||
+#define RTC_CATCH_BEGIN
|
||||
+#define RTC_CATCH_END(device)
|
||||
+#define RTC_CATCH_END2(scene)
|
||||
+#define RTC_CATCH_END2_FALSE(scene) return false;
|
||||
#if 0
|
||||
-# define RTC_CATCH_BEGIN
|
||||
-# define RTC_CATCH_END(device)
|
||||
-# define RTC_CATCH_END2(scene)
|
||||
-# define RTC_CATCH_END2_FALSE(scene) return false;
|
||||
-#else
|
||||
-
|
||||
+// -- GODOT end --
|
||||
#define RTC_CATCH_BEGIN try {
|
||||
|
||||
#define RTC_CATCH_END(device) \
|
||||
@@ -94,6 +94,8 @@ namespace embree
|
||||
-#if 0
|
||||
+#if 1
|
||||
# define RTC_CATCH_BEGIN
|
||||
# define RTC_CATCH_END(device)
|
||||
# define RTC_CATCH_END2(scene)
|
||||
@@ -94,6 +94,7 @@ namespace embree
|
||||
#define RTC_TRACE(x)
|
||||
#endif
|
||||
|
||||
+// -- GODOT start --
|
||||
+#if 0
|
||||
/*! used to throw embree API errors */
|
||||
struct rtcore_error : public std::exception
|
||||
{
|
||||
@@ -109,14 +111,18 @@ namespace embree
|
||||
@@ -109,13 +110,16 @@ namespace embree
|
||||
RTCError error;
|
||||
std::string str;
|
||||
};
|
||||
@@ -473,28 +411,25 @@ index 73a061de11..47526482c1 100644
|
||||
#define throw_RTCError(error,str) \
|
||||
- throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
+ printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
|
||||
+ // throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
+ //throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
||||
#else
|
||||
#define throw_RTCError(error,str) \
|
||||
- throw rtcore_error(error,str);
|
||||
+ abort();
|
||||
+ // throw rtcore_error(error,str);
|
||||
+ //throw rtcore_error(error,str);
|
||||
#endif
|
||||
+// -- GODOT end --
|
||||
|
||||
#define RTC_BUILD_ARGUMENTS_HAS(settings,member) \
|
||||
(settings.byteSize > (offsetof(RTCBuildArguments,member)+sizeof(settings.member)))
|
||||
diff --git a/thirdparty/embree/kernels/common/scene.cpp b/thirdparty/embree/kernels/common/scene.cpp
|
||||
index fda8dd938a..10cb3c4bec 100644
|
||||
index fda8dd938a..706cc512df 100644
|
||||
--- a/thirdparty/embree/kernels/common/scene.cpp
|
||||
+++ b/thirdparty/embree/kernels/common/scene.cpp
|
||||
@@ -894,16 +894,18 @@ namespace embree
|
||||
@@ -894,16 +894,16 @@ namespace embree
|
||||
}
|
||||
|
||||
/* initiate build */
|
||||
- try {
|
||||
+ // -- GODOT start --
|
||||
+ // try {
|
||||
+ //try {
|
||||
TaskScheduler::TaskGroupContext context;
|
||||
scheduler->spawn_root([&]() { commit_task(); Lock<MutexSys> lock(taskGroup->schedulerMutex); taskGroup->scheduler = nullptr; }, &context, 1, !join);
|
||||
- }
|
||||
@@ -504,40 +439,37 @@ index fda8dd938a..10cb3c4bec 100644
|
||||
- taskGroup->scheduler = nullptr;
|
||||
- throw;
|
||||
- }
|
||||
+ // }
|
||||
+ // catch (...) {
|
||||
+ // accels_clear();
|
||||
+ // Lock<MutexSys> lock(taskGroup->schedulerMutex);
|
||||
+ // taskGroup->scheduler = nullptr;
|
||||
+ // throw;
|
||||
+ // }
|
||||
+ // -- GODOT end --
|
||||
+ //}
|
||||
+ //catch (...) {
|
||||
+ // accels_clear();
|
||||
+ // Lock<MutexSys> lock(taskGroup->schedulerMutex);
|
||||
+ // taskGroup->scheduler = nullptr;
|
||||
+ // throw;
|
||||
+ //}
|
||||
}
|
||||
|
||||
#endif
|
||||
diff --git a/thirdparty/embree/kernels/common/state.cpp b/thirdparty/embree/kernels/common/state.cpp
|
||||
index 4e3ab6ddfb..1d73ae9629 100644
|
||||
index 4e3ab6ddfb..8e83c95bd7 100644
|
||||
--- a/thirdparty/embree/kernels/common/state.cpp
|
||||
+++ b/thirdparty/embree/kernels/common/state.cpp
|
||||
@@ -194,13 +194,15 @@ namespace embree
|
||||
@@ -194,13 +194,13 @@ namespace embree
|
||||
bool State::parseFile(const FileName& fileName)
|
||||
{
|
||||
Ref<Stream<int> > file;
|
||||
- try {
|
||||
+ // -- GODOT start --
|
||||
+ // try {
|
||||
+ //try {
|
||||
file = new FileStream(fileName);
|
||||
- }
|
||||
- catch (std::runtime_error& e) {
|
||||
- (void) e;
|
||||
- return false;
|
||||
- }
|
||||
+ // }
|
||||
+ // catch (std::runtime_error& e) {
|
||||
+ // (void) e;
|
||||
+ // return false;
|
||||
+ // }
|
||||
+ // -- GODOT end --
|
||||
+ //}
|
||||
+ //catch (std::runtime_error& e) {
|
||||
+ // (void) e;
|
||||
+ // return false;
|
||||
+ //}
|
||||
|
||||
std::vector<std::string> syms;
|
||||
for (size_t i=0; i<sizeof(symbols)/sizeof(void*); i++)
|
||||
32
thirdparty/embree/patches/0003-emscripten-nthreads.patch
vendored
Normal file
32
thirdparty/embree/patches/0003-emscripten-nthreads.patch
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
index 61256b34f2..4583e49b1c 100644
|
||||
--- a/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
+++ b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
@@ -646,6 +646,10 @@ namespace embree
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include <emscripten.h>
|
||||
+
|
||||
+extern "C" {
|
||||
+extern int godot_js_os_hw_concurrency_get();
|
||||
+}
|
||||
#endif
|
||||
|
||||
namespace embree
|
||||
@@ -659,6 +663,8 @@ namespace embree
|
||||
nThreads = sysconf(_SC_NPROCESSORS_ONLN); // does not work in Linux LXC container
|
||||
assert(nThreads);
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
+ nThreads = godot_js_os_hw_concurrency_get();
|
||||
+#if 0
|
||||
// WebAssembly supports pthreads, but not pthread_getaffinity_np. Get the number of logical
|
||||
// threads from the browser or Node.js using JavaScript.
|
||||
nThreads = MAIN_THREAD_EM_ASM_INT({
|
||||
@@ -674,6 +680,7 @@ namespace embree
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
+#endif
|
||||
#else
|
||||
cpu_set_t set;
|
||||
if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
index d01eab3c9d..4ecab05265 100644
|
||||
index d5b653fe5a..4583e49b1c 100644
|
||||
--- a/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
+++ b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
@@ -295,7 +295,7 @@ namespace embree
|
||||
@@ -1,46 +1,40 @@
|
||||
diff --git a/thirdparty/embree/common/simd/arm/sse2neon.h b/thirdparty/embree/common/simd/arm/sse2neon.h
|
||||
index b18d41e783..c54d0b7951 100644
|
||||
index b18d41e783..5a75ccff20 100644
|
||||
--- a/thirdparty/embree/common/simd/arm/sse2neon.h
|
||||
+++ b/thirdparty/embree/common/simd/arm/sse2neon.h
|
||||
@@ -102,7 +102,9 @@
|
||||
@@ -102,7 +102,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
-#if defined(_WIN32)
|
||||
+// -- GODOT start --
|
||||
+#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
+// -- GODOT end --
|
||||
/* Definitions for _mm_{malloc,free} are provided by <malloc.h>
|
||||
* from both MinGW-w64 and MSVC.
|
||||
*/
|
||||
@@ -2080,8 +2082,16 @@ FORCE_INLINE void *_mm_malloc(size_t size, size_t align)
|
||||
return malloc(size);
|
||||
if (align == 2 || (sizeof(void *) == 8 && align == 4))
|
||||
align = sizeof(void *);
|
||||
- if (!posix_memalign(&ptr, align, size))
|
||||
+// -- GODOT start --
|
||||
+#if defined(_WIN32)
|
||||
+ ptr = _aligned_malloc(size, align);
|
||||
+ if (ptr)
|
||||
return ptr;
|
||||
+#else
|
||||
+ if (!posix_memalign(&ptr, align, size))
|
||||
+ return ptr;
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@@ -1890,7 +1890,13 @@ FORCE_INLINE __m128 _mm_div_ss(__m128 a, __m128 b)
|
||||
@@ -1888,7 +1888,11 @@ FORCE_INLINE __m128 _mm_div_ss(__m128 a, __m128 b)
|
||||
#if !defined(SSE2NEON_ALLOC_DEFINED)
|
||||
FORCE_INLINE void _mm_free(void *addr)
|
||||
{
|
||||
+// -- GODOT start --
|
||||
+#if defined(_WIN32)
|
||||
+ _aligned_free(addr);
|
||||
+#else
|
||||
free(addr);
|
||||
+#endif
|
||||
+// -- GODOT end --
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2080,8 +2084,14 @@ FORCE_INLINE void *_mm_malloc(size_t size, size_t align)
|
||||
return malloc(size);
|
||||
if (align == 2 || (sizeof(void *) == 8 && align == 4))
|
||||
align = sizeof(void *);
|
||||
+#if defined(_WIN32)
|
||||
+ ptr = _aligned_malloc(size, align);
|
||||
+ if (ptr)
|
||||
+ return ptr;
|
||||
+#else
|
||||
if (!posix_memalign(&ptr, align, size))
|
||||
return ptr;
|
||||
+#endif
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@@ -1,42 +0,0 @@
|
||||
diff --git a/thirdparty/embree/common/sys/sysinfo.cpp b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
index c98f61fa53..7f7a009a1e 100644
|
||||
--- a/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
+++ b/thirdparty/embree/common/sys/sysinfo.cpp
|
||||
@@ -640,6 +640,12 @@ namespace embree
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include <emscripten.h>
|
||||
+
|
||||
+// -- GODOT start --
|
||||
+extern "C" {
|
||||
+extern int godot_js_os_hw_concurrency_get();
|
||||
+}
|
||||
+// -- GODOT end --
|
||||
#endif
|
||||
|
||||
namespace embree
|
||||
@@ -653,21 +659,9 @@ namespace embree
|
||||
nThreads = sysconf(_SC_NPROCESSORS_ONLN); // does not work in Linux LXC container
|
||||
assert(nThreads);
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
- // WebAssembly supports pthreads, but not pthread_getaffinity_np. Get the number of logical
|
||||
- // threads from the browser or Node.js using JavaScript.
|
||||
- nThreads = MAIN_THREAD_EM_ASM_INT({
|
||||
- const isBrowser = typeof window !== 'undefined';
|
||||
- const isNode = typeof process !== 'undefined' && process.versions != null &&
|
||||
- process.versions.node != null;
|
||||
- if (isBrowser) {
|
||||
- // Return 1 if the browser does not expose hardwareConcurrency.
|
||||
- return window.navigator.hardwareConcurrency || 1;
|
||||
- } else if (isNode) {
|
||||
- return require('os').cpus().length;
|
||||
- } else {
|
||||
- return 1;
|
||||
- }
|
||||
- });
|
||||
+ // -- GODOT start --
|
||||
+ nThreads = godot_js_os_hw_concurrency_get();
|
||||
+ // -- GODOT end --
|
||||
#else
|
||||
cpu_set_t set;
|
||||
if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
|
||||
Reference in New Issue
Block a user