// Copyright 2009-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #include "../../common/sys/platform.h" #include "../../common/sys/sysinfo.h" #include "../../common/sys/thread.h" #include "../../common/sys/alloc.h" #include "../../common/sys/ref.h" #include "../../common/sys/intrinsics.h" #include "../../common/sys/atomic.h" #include "../../common/sys/mutex.h" #include "../../common/sys/vector.h" #include "../../common/sys/array.h" #include "../../common/sys/string.h" #include "../../common/sys/regression.h" #include "../../common/sys/vector.h" #include "../../common/math/math.h" #include "../../common/math/transcendental.h" #include "../../common/simd/simd.h" #include "../../common/math/vec2.h" #include "../../common/math/vec3.h" #include "../../common/math/vec4.h" #include "../../common/math/vec2fa.h" #include "../../common/math/vec3fa.h" #include "../../common/math/interval.h" #include "../../common/math/bbox.h" #include "../../common/math/obbox.h" #include "../../common/math/lbbox.h" #include "../../common/math/linearspace2.h" #include "../../common/math/linearspace3.h" #include "../../common/math/affinespace.h" #include "../../common/math/range.h" #include "../../common/lexers/tokenstream.h" #include "../../common/tasking/taskscheduler.h" #define COMMA , #include "../config.h" #include "isa.h" #include "stat.h" #include "profile.h" #include "rtcore.h" #include "vector.h" #include "state.h" #include "instance_stack.h" #include #include #include #include #include #include #if !defined(_DEBUG) && defined(BUILD_IOS) #undef assert #define assert(_EXPR) #endif namespace embree { //////////////////////////////////////////////////////////////////////////////// /// Vec2 shortcuts //////////////////////////////////////////////////////////////////////////////// template using Vec2vf = Vec2>; template using Vec2vd = Vec2>; template using Vec2vr = Vec2>; template using Vec2vi = Vec2>; template using Vec2vl = Vec2>; template using Vec2vb = Vec2>; template using Vec2vbf = Vec2>; template using Vec2vbd = Vec2>; typedef Vec2 Vec2vf4; typedef Vec2 Vec2vd4; typedef Vec2 Vec2vr4; typedef Vec2 Vec2vi4; typedef Vec2 Vec2vl4; typedef Vec2 Vec2vb4; typedef Vec2 Vec2vbf4; typedef Vec2 Vec2vbd4; typedef Vec2 Vec2vf8; typedef Vec2 Vec2vd8; typedef Vec2 Vec2vr8; typedef Vec2 Vec2vi8; typedef Vec2 Vec2vl8; typedef Vec2 Vec2vb8; typedef Vec2 Vec2vbf8; typedef Vec2 Vec2vbd8; typedef Vec2 Vec2vf16; typedef Vec2 Vec2vd16; typedef Vec2 Vec2vr16; typedef Vec2 Vec2vi16; typedef Vec2 Vec2vl16; typedef Vec2 Vec2vb16; typedef Vec2 Vec2vbf16; typedef Vec2 Vec2vbd16; typedef Vec2 Vec2vfx; typedef Vec2 Vec2vdx; typedef Vec2 Vec2vrx; typedef Vec2 Vec2vix; typedef Vec2 Vec2vlx; typedef Vec2 Vec2vbx; typedef Vec2 Vec2vbfx; typedef Vec2 Vec2vbdx; //////////////////////////////////////////////////////////////////////////////// /// Vec3 shortcuts //////////////////////////////////////////////////////////////////////////////// template using Vec3vf = Vec3>; template using Vec3vd = Vec3>; template using Vec3vr = Vec3>; template using Vec3vi = Vec3>; template using Vec3vl = Vec3>; template using Vec3vb = Vec3>; template using Vec3vbf = Vec3>; template using Vec3vbd = Vec3>; typedef Vec3 Vec3vf4; typedef Vec3 Vec3vd4; typedef Vec3 Vec3vr4; typedef Vec3 Vec3vi4; typedef Vec3 Vec3vl4; typedef Vec3 Vec3vb4; typedef Vec3 Vec3vbf4; typedef Vec3 Vec3vbd4; typedef Vec3 Vec3vf8; typedef Vec3 Vec3vd8; typedef Vec3 Vec3vr8; typedef Vec3 Vec3vi8; typedef Vec3 Vec3vl8; typedef Vec3 Vec3vb8; typedef Vec3 Vec3vbf8; typedef Vec3 Vec3vbd8; typedef Vec3 Vec3vf16; typedef Vec3 Vec3vd16; typedef Vec3 Vec3vr16; typedef Vec3 Vec3vi16; typedef Vec3 Vec3vl16; typedef Vec3 Vec3vb16; typedef Vec3 Vec3vbf16; typedef Vec3 Vec3vbd16; typedef Vec3 Vec3vfx; typedef Vec3 Vec3vdx; typedef Vec3 Vec3vrx; typedef Vec3 Vec3vix; typedef Vec3 Vec3vlx; typedef Vec3 Vec3vbx; typedef Vec3 Vec3vbfx; typedef Vec3 Vec3vbdx; //////////////////////////////////////////////////////////////////////////////// /// Vec4 shortcuts //////////////////////////////////////////////////////////////////////////////// template using Vec4vf = Vec4>; template using Vec4vd = Vec4>; template using Vec4vr = Vec4>; template using Vec4vi = Vec4>; template using Vec4vl = Vec4>; template using Vec4vb = Vec4>; template using Vec4vbf = Vec4>; template using Vec4vbd = Vec4>; typedef Vec4 Vec4vf4; typedef Vec4 Vec4vd4; typedef Vec4 Vec4vr4; typedef Vec4 Vec4vi4; typedef Vec4 Vec4vl4; typedef Vec4 Vec4vb4; typedef Vec4 Vec4vbf4; typedef Vec4 Vec4vbd4; typedef Vec4 Vec4vf8; typedef Vec4 Vec4vd8; typedef Vec4 Vec4vr8; typedef Vec4 Vec4vi8; typedef Vec4 Vec4vl8; typedef Vec4 Vec4vb8; typedef Vec4 Vec4vbf8; typedef Vec4 Vec4vbd8; typedef Vec4 Vec4vf16; typedef Vec4 Vec4vd16; typedef Vec4 Vec4vr16; typedef Vec4 Vec4vi16; typedef Vec4 Vec4vl16; typedef Vec4 Vec4vb16; typedef Vec4 Vec4vbf16; typedef Vec4 Vec4vbd16; typedef Vec4 Vec4vfx; typedef Vec4 Vec4vdx; typedef Vec4 Vec4vrx; typedef Vec4 Vec4vix; typedef Vec4 Vec4vlx; typedef Vec4 Vec4vbx; typedef Vec4 Vec4vbfx; typedef Vec4 Vec4vbdx; //////////////////////////////////////////////////////////////////////////////// /// Other shortcuts //////////////////////////////////////////////////////////////////////////////// template using BBox3vf = BBox>; typedef BBox BBox3vf4; typedef BBox BBox3vf8; typedef BBox BBox3vf16; /* calculate time segment itime and fractional time ftime */ __forceinline int getTimeSegment(float time, float numTimeSegments, float& ftime) { const float timeScaled = time * numTimeSegments; const float itimef = clamp(floorf(timeScaled), 0.0f, numTimeSegments-1.0f); ftime = timeScaled - itimef; return int(itimef); } __forceinline int getTimeSegment(float time, float start_time, float end_time, float numTimeSegments, float& ftime) { const float timeScaled = (time-start_time)/(end_time-start_time) * numTimeSegments; const float itimef = clamp(floorf(timeScaled), 0.0f, numTimeSegments-1.0f); ftime = timeScaled - itimef; return int(itimef); } template __forceinline vint getTimeSegment(const vfloat& time, const vfloat& numTimeSegments, vfloat& ftime) { const vfloat timeScaled = time * numTimeSegments; const vfloat itimef = clamp(floor(timeScaled), vfloat(zero), numTimeSegments-1.0f); ftime = timeScaled - itimef; return vint(itimef); } template __forceinline vint getTimeSegment(const vfloat& time, const vfloat& start_time, const vfloat& end_time, const vfloat& numTimeSegments, vfloat& ftime) { const vfloat timeScaled = (time-start_time)/(end_time-start_time) * numTimeSegments; const vfloat itimef = clamp(floor(timeScaled), vfloat(zero), numTimeSegments-1.0f); ftime = timeScaled - itimef; return vint(itimef); } /* calculate overlapping time segment range */ __forceinline range getTimeSegmentRange(const BBox1f& time_range, float numTimeSegments) { const float round_up = 1.0f+2.0f*float(ulp); // corrects inaccuracies to precisely match time step const float round_down = 1.0f-2.0f*float(ulp); const int itime_lower = (int)max(floor(round_up *time_range.lower*numTimeSegments), 0.0f); const int itime_upper = (int)min(ceil (round_down*time_range.upper*numTimeSegments), numTimeSegments); return make_range(itime_lower, itime_upper); } /* calculate overlapping time segment range */ __forceinline range getTimeSegmentRange(const BBox1f& range, BBox1f time_range, float numTimeSegments) { const float lower = (range.lower-time_range.lower)/time_range.size(); const float upper = (range.upper-time_range.lower)/time_range.size(); return getTimeSegmentRange(BBox1f(lower,upper),numTimeSegments); } }