2021-05-20 12:49:33 +02:00
|
|
|
// Copyright 2009-2021 Intel Corporation
|
2020-12-19 14:50:20 +01:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../../include/embree3/rtcore.h"
|
|
|
|
RTC_NAMESPACE_USE
|
|
|
|
|
|
|
|
namespace embree
|
|
|
|
{
|
|
|
|
/*! decoding of intersection flags */
|
|
|
|
__forceinline bool isCoherent (RTCIntersectContextFlags flags) { return (flags & RTC_INTERSECT_CONTEXT_FLAG_COHERENT) == RTC_INTERSECT_CONTEXT_FLAG_COHERENT; }
|
|
|
|
__forceinline bool isIncoherent(RTCIntersectContextFlags flags) { return (flags & RTC_INTERSECT_CONTEXT_FLAG_COHERENT) == RTC_INTERSECT_CONTEXT_FLAG_INCOHERENT; }
|
|
|
|
|
|
|
|
#if defined(TASKING_TBB) && (TBB_INTERFACE_VERSION_MAJOR >= 8)
|
|
|
|
# define USE_TASK_ARENA 1
|
|
|
|
#else
|
|
|
|
# define USE_TASK_ARENA 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TASKING_TBB) && (TBB_INTERFACE_VERSION >= 11009) // TBB 2019 Update 9
|
|
|
|
# define TASKING_TBB_USE_TASK_ISOLATION 1
|
|
|
|
#else
|
|
|
|
# define TASKING_TBB_USE_TASK_ISOLATION 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*! Macros used in the rtcore API implementation */
|
2021-05-04 11:07:12 +02:00
|
|
|
// -- GODOT start --
|
|
|
|
// #define RTC_CATCH_BEGIN try {
|
|
|
|
#define RTC_CATCH_BEGIN
|
2020-12-19 14:50:20 +01:00
|
|
|
|
2021-05-04 11:07:12 +02:00
|
|
|
// #define RTC_CATCH_END(device) \
|
|
|
|
// } catch (std::bad_alloc&) { \
|
|
|
|
// Device::process_error(device,RTC_ERROR_OUT_OF_MEMORY,"out of memory"); \
|
|
|
|
// } catch (rtcore_error& e) { \
|
|
|
|
// Device::process_error(device,e.error,e.what()); \
|
|
|
|
// } catch (std::exception& e) { \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,e.what()); \
|
|
|
|
// } catch (...) { \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,"unknown exception caught"); \
|
|
|
|
// }
|
|
|
|
#define RTC_CATCH_END(device)
|
2020-12-19 14:50:20 +01:00
|
|
|
|
2021-05-04 11:07:12 +02:00
|
|
|
// #define RTC_CATCH_END2(scene) \
|
|
|
|
// } catch (std::bad_alloc&) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_OUT_OF_MEMORY,"out of memory"); \
|
|
|
|
// } catch (rtcore_error& e) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,e.error,e.what()); \
|
|
|
|
// } catch (std::exception& e) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,e.what()); \
|
|
|
|
// } catch (...) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,"unknown exception caught"); \
|
|
|
|
// }
|
|
|
|
#define RTC_CATCH_END2(scene)
|
2020-12-19 14:50:20 +01:00
|
|
|
|
2021-05-04 11:07:12 +02:00
|
|
|
// #define RTC_CATCH_END2_FALSE(scene) \
|
|
|
|
// } catch (std::bad_alloc&) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_OUT_OF_MEMORY,"out of memory"); \
|
|
|
|
// return false; \
|
|
|
|
// } catch (rtcore_error& e) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,e.error,e.what()); \
|
|
|
|
// return false; \
|
|
|
|
// } catch (std::exception& e) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,e.what()); \
|
|
|
|
// return false; \
|
|
|
|
// } catch (...) { \
|
|
|
|
// Device* device = scene ? scene->device : nullptr; \
|
|
|
|
// Device::process_error(device,RTC_ERROR_UNKNOWN,"unknown exception caught"); \
|
|
|
|
// return false; \
|
|
|
|
// }
|
|
|
|
#define RTC_CATCH_END2_FALSE(scene) return false;
|
|
|
|
// -- GODOT end --
|
2020-12-19 14:50:20 +01:00
|
|
|
|
|
|
|
#define RTC_VERIFY_HANDLE(handle) \
|
|
|
|
if (handle == nullptr) { \
|
|
|
|
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid argument"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RTC_VERIFY_GEOMID(id) \
|
|
|
|
if (id == RTC_INVALID_GEOMETRY_ID) { \
|
|
|
|
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid argument"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RTC_VERIFY_UPPER(id,upper) \
|
|
|
|
if (id > upper) { \
|
|
|
|
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid argument"); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RTC_VERIFY_RANGE(id,lower,upper) \
|
|
|
|
if (id < lower || id > upper) \
|
|
|
|
throw_RTCError(RTC_ERROR_INVALID_OPERATION,"argument out of bounds");
|
|
|
|
|
|
|
|
#if 0 // enable to debug print all API calls
|
|
|
|
#define RTC_TRACE(x) std::cout << #x << std::endl;
|
|
|
|
#else
|
|
|
|
#define RTC_TRACE(x)
|
|
|
|
#endif
|
|
|
|
|
2021-05-04 11:07:12 +02:00
|
|
|
// -- GODOT begin --
|
|
|
|
// /*! used to throw embree API errors */
|
|
|
|
// struct rtcore_error : public std::exception
|
|
|
|
// {
|
|
|
|
// __forceinline rtcore_error(RTCError error, const std::string& str)
|
|
|
|
// : error(error), str(str) {}
|
|
|
|
//
|
|
|
|
// ~rtcore_error() throw() {}
|
|
|
|
//
|
|
|
|
// const char* what () const throw () {
|
|
|
|
// return str.c_str();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// RTCError error;
|
|
|
|
// std::string str;
|
|
|
|
// };
|
|
|
|
// -- GODOT end --
|
2020-12-19 14:50:20 +01:00
|
|
|
|
|
|
|
#if defined(DEBUG) // only report file and line in debug mode
|
2021-05-04 11:07:12 +02:00
|
|
|
// -- GODOT begin --
|
|
|
|
// #define throw_RTCError(error,str) \
|
|
|
|
// throw rtcore_error(error,std::string(__FILE__) + " (" + toString(__LINE__) + "): " + std::string(str));
|
2020-12-19 14:50:20 +01:00
|
|
|
#define throw_RTCError(error,str) \
|
2021-11-22 18:05:24 +01:00
|
|
|
printf("%s (%d): %s", __FILE__, __LINE__, std::string(str).c_str()), abort();
|
2021-05-04 11:07:12 +02:00
|
|
|
// -- GODOT end --
|
2020-12-19 14:50:20 +01:00
|
|
|
#else
|
2021-05-04 11:07:12 +02:00
|
|
|
// -- GODOT begin --
|
|
|
|
// #define throw_RTCError(error,str) \
|
|
|
|
// throw rtcore_error(error,str);
|
2020-12-19 14:50:20 +01:00
|
|
|
#define throw_RTCError(error,str) \
|
2021-05-04 11:07:12 +02:00
|
|
|
abort();
|
|
|
|
// -- GODOT end --
|
2020-12-19 14:50:20 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define RTC_BUILD_ARGUMENTS_HAS(settings,member) \
|
|
|
|
(settings.byteSize > (offsetof(RTCBuildArguments,member)+sizeof(settings.member)))
|
|
|
|
}
|