├── .gitattributes ├── test ├── kitchen.ply ├── embree │ ├── sys │ │ ├── sync │ │ │ ├── condition.cpp │ │ │ ├── condition.h │ │ │ ├── barrier.h │ │ │ ├── event.h │ │ │ ├── mutex.h │ │ │ └── atomic.h │ │ ├── stl │ │ │ ├── string.h │ │ │ ├── string.cpp │ │ │ └── array2d.h │ │ ├── library.h │ │ ├── sysinfo.h │ │ ├── taskscheduler_mic.h │ │ ├── taskscheduler_sys.h │ │ ├── sys.vcxproj.filters │ │ ├── thread.h │ │ ├── filename.h │ │ └── library.cpp │ ├── math │ │ ├── color.h │ │ ├── permutation.h │ │ ├── random.h │ │ ├── col3.h │ │ └── col4.h │ ├── common │ │ ├── accel.cpp │ │ ├── alloc.cpp │ │ ├── registry_intersector.h │ │ ├── accel.h │ │ ├── registry_accel.h │ │ ├── registry_builder.h │ │ ├── stat.h │ │ ├── default.h │ │ ├── ray4.h │ │ ├── ray8.h │ │ ├── ray16.h │ │ ├── ray.h │ │ └── registry_builder.cpp │ ├── simd │ │ ├── sse_mic.h │ │ ├── simd.h │ │ ├── mic_f.cpp │ │ ├── avx.h │ │ └── mic_i.cpp │ ├── builders │ │ ├── splitter_fallback.h │ │ ├── primref.h │ │ ├── splitter.h │ │ ├── heuristics.h │ │ ├── primrefblock.h │ │ ├── bvh_sort.h │ │ └── primrefgen.h │ ├── bvh4aos │ │ ├── builder │ │ │ ├── bvh4aos_globals.h │ │ │ ├── bvh4aos_task_scheduler.h │ │ │ └── bvh4aos_builder.h │ │ ├── bvh4aos_intersector1.h │ │ ├── bvh4aos_triangle1_intersector16_single.h │ │ ├── bvh4aos_intersector16_chunk.h │ │ ├── bvh4aos_triangle1_intersector1_ref.h │ │ ├── bvh4aos_triangle1_intersector16_chunk.h │ │ ├── bvh4aos_triangle1_intersector16_chunk_ref.h │ │ └── bvh4aos_triangle1_intersector16_hybrid_ref.h │ ├── bvh2 │ │ ├── bvh2_intersector1.h │ │ ├── bvh2_intersector4.h │ │ └── bvh2_intersector8.h │ ├── bvh4mb │ │ ├── bvh4mb_intersector1.h │ │ ├── bvh4mb_intersector8.h │ │ └── bvh4mb_intersector4.h │ ├── bvh4 │ │ ├── bvh4_intersector4_chunk.h │ │ ├── bvh4_intersector8_chunk.h │ │ ├── bvh4_intersector8_single.h │ │ ├── bvh4_intersector4_single.h │ │ ├── bvh4_intersector1_avx.h │ │ ├── bvh4_intersector8_hybrid.h │ │ ├── bvh4_intersector4_hybrid.h │ │ └── bvh4_intersector8_hybrid_stream.h │ ├── bvh8 │ │ └── bvh8_intersector1.h │ ├── bvh4i │ │ └── bvh4i_intersector1.h │ ├── geometry │ │ ├── triangles.h │ │ └── triangle.h │ └── include │ │ ├── intersector1.h │ │ └── intersector_stream.h ├── EmbreeHooks.h ├── build │ └── msvc2013 │ │ └── BRayTest.vcxproj.filters └── EmbreeHooks.cpp ├── BRay ├── src │ ├── Tracer.cpp │ ├── Tracer_Occlusion.cpp │ ├── Malloc.h │ ├── TRTTypes.h │ ├── Types.h │ ├── Tracer.h │ ├── Malloc.cpp │ ├── PoolAllocator.h │ └── Accelerator.h ├── build │ └── msvc2013 │ │ └── BRay.vcxproj.filters └── include │ └── BRay.h ├── .gitmodules ├── README.txt └── BRay.sln /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ply binary -------------------------------------------------------------------------------- /test/kitchen.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbarczak/BRay/HEAD/test/kitchen.ply -------------------------------------------------------------------------------- /BRay/src/Tracer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbarczak/BRay/HEAD/BRay/src/Tracer.cpp -------------------------------------------------------------------------------- /BRay/src/Tracer_Occlusion.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbarczak/BRay/HEAD/BRay/src/Tracer_Occlusion.cpp -------------------------------------------------------------------------------- /test/embree/sys/sync/condition.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbarczak/BRay/HEAD/test/embree/sys/sync/condition.cpp -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/Simpleton"] 2 | path = test/Simpleton 3 | url = http://github.com/jbarczak/Simpleton 4 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | B-Ray is an AVX-Optimized ray tracing library which is geared towards bulk tracing of incoherent ray streams. 2 | 3 | -------------------------------------------------------------------------------- /test/EmbreeHooks.h: -------------------------------------------------------------------------------- 1 | #ifndef _EMBREE_H_ 2 | #define _EMBREE_H_ 3 | 4 | 5 | typedef unsigned int uint; 6 | struct RayStream; 7 | void CreateEmbreeScene( uint nTris, uint nVerts, float* pVerts, uint* pIndices ); 8 | void ShootEmbreeRays( BRay::RayData* pRays, BRay::RayHitInfo* pHits, uint nRays ); 9 | double GetEmbreeTime(); 10 | 11 | #endif -------------------------------------------------------------------------------- /BRay/src/Malloc.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // Malloc.h 4 | // 5 | // Internal malloc used by B-Ray 6 | // 7 | // Copyright 2015 Joshua Barczak 8 | // 9 | // LICENSE: This source code is distributed under the terms of the GNU GPL 10 | // 11 | // 12 | //===================================================================================================================== 13 | 14 | #ifndef _MALLOC_H_ 15 | #define _MALLOC_H_ 16 | 17 | namespace BRay{ 18 | class Allocator; 19 | namespace _INTERNAL{ 20 | 21 | void InitMalloc( Allocator* pAlloc ); 22 | void ShutdownMalloc(); 23 | void* Malloc( size_t bytes, size_t align ); 24 | void Free( void* bytes ); 25 | 26 | }} 27 | 28 | #endif -------------------------------------------------------------------------------- /BRay/src/TRTTypes.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // TRTTypes.h 4 | // 5 | // Type definitions 6 | // 7 | // Part of the TinyRT Raytracing Library. 8 | // Author: Joshua Barczak 9 | // 10 | // Copyright 2008 Joshua Barczak. All rights reserved. 11 | // See Doc/LICENSE.txt for terms and conditions. 12 | // 13 | //===================================================================================================================== 14 | 15 | #ifndef _TRT_TYPES_H_ 16 | #define _TRT_TYPES_H_ 17 | 18 | 19 | #include "TRTVec2.h" 20 | #include "TRTVec3.h" 21 | 22 | namespace TinyRT 23 | { 24 | // define aliases for integral types of specific sizes 25 | typedef unsigned char uint8; 26 | typedef unsigned short uint16; 27 | typedef unsigned int uint32; 28 | typedef char int8; 29 | typedef short int16; 30 | typedef int int32; 31 | typedef void* Handle; 32 | 33 | typedef unsigned int uint; 34 | 35 | typedef Vec3 Vec3f; 36 | typedef Vec2 Vec2f; 37 | } 38 | 39 | 40 | #endif // _TRT_TYPES_H_ 41 | -------------------------------------------------------------------------------- /test/build/msvc2013/BRayTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /BRay/src/Types.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // Types.h 4 | // 5 | // Internal data structures and constants used by B-Ray 6 | // 7 | // Copyright 2015 Joshua Barczak 8 | // 9 | // LICENSE: This source code is distributed under the terms of the GNU GPL 10 | // 11 | // 12 | //===================================================================================================================== 13 | 14 | #ifndef _TYPES_H_ 15 | #define _TYPES_H_ 16 | 17 | #include "BRay.h" 18 | 19 | #define BRAY_MEM_ALIGNMENT 32 20 | 21 | namespace BRay{ 22 | typedef unsigned char uint8; 23 | typedef unsigned short uint16; 24 | typedef unsigned __int64 uint64; 25 | typedef unsigned int uint32; 26 | typedef int int32; 27 | 28 | static_assert( sizeof(uint8) == 1 && 29 | sizeof(uint16) == 2 && 30 | sizeof(uint32) == 4 && 31 | sizeof(int32) == 4 && 32 | sizeof(uint64) == 8, "Your compiler disagrees with our assumptions"); 33 | 34 | namespace _INTERNAL{ 35 | 36 | typedef size_t uint; 37 | 38 | struct __declspec(align(BRAY_MEM_ALIGNMENT)) Object 39 | { 40 | virtual ~Object(){} 41 | Object* pNext; 42 | Object* pPrev; 43 | }; 44 | 45 | 46 | 47 | }} 48 | 49 | 50 | #endif -------------------------------------------------------------------------------- /BRay/src/Tracer.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "Types.h" 4 | 5 | namespace BRay{ 6 | namespace _INTERNAL{ 7 | 8 | struct BVHNode; 9 | 10 | struct Ray 11 | { 12 | float ox; 13 | float oy; 14 | float oz; 15 | float tmax; 16 | float dx; 17 | float dy; 18 | float dz; 19 | uint32 offset; ///< Byte offset of this ray from start of stream 20 | }; 21 | 22 | 23 | struct PreprocessedTri 24 | { 25 | uint32 nID; 26 | float P0[3]; 27 | float v10[3]; 28 | float v02[3]; 29 | float v10x02[3]; 30 | }; 31 | 32 | struct StackEntry 33 | { 34 | BVHNode* pNode; 35 | size_t nRayPop; 36 | size_t nGroups; 37 | }; 38 | 39 | 40 | struct Tracer : public Object 41 | { 42 | Accelerator* pAccelerator; 43 | uint32 nMaxRays; 44 | 45 | Ray* pRays; 46 | BVHNode* pBVHRoot; 47 | StackEntry* pTraversalStack; 48 | 49 | uint32 nRays; 50 | uint16 pOctantCounts[8]; 51 | uint8* pRayOctants; 52 | 53 | }; 54 | 55 | struct PreprocessedTri; 56 | void AssembleTri( PreprocessedTri* __restrict pTri, uint32 nID, const float* P0, const float* P1, const float* P2 ); 57 | 58 | void DoTrace( Tracer* p, BRay::RayHitInfo* pHitsOut ); 59 | 60 | void DoOcclusionTrace( Tracer* p, unsigned char* pOcclusionOut ); 61 | }}; -------------------------------------------------------------------------------- /BRay/src/Malloc.cpp: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // Malloc.cpp 4 | // 5 | // Internal malloc used by B-Ray 6 | // 7 | // Copyright 2015 Joshua Barczak 8 | // 9 | // LICENSE: This source code is distributed under the terms of the GNU GPL 10 | // 11 | // 12 | //===================================================================================================================== 13 | 14 | #include "BRay.h" 15 | #include 16 | 17 | namespace BRay{ 18 | namespace _INTERNAL{ 19 | 20 | static Allocator* g_pAlloc=0; 21 | 22 | class DefaultAllocator : public Allocator 23 | { 24 | public: 25 | virtual void* Malloc( size_t nBytes, size_t nAlign ) { return _aligned_malloc(nBytes,nAlign); } 26 | virtual void Free( void* pBytes ) { return _aligned_free(pBytes); } 27 | }; 28 | 29 | static DefaultAllocator g_DefaultAlloc; 30 | 31 | void InitMalloc( Allocator* p ) 32 | { 33 | if( !p ) 34 | p = &g_DefaultAlloc; 35 | g_pAlloc = p; 36 | } 37 | 38 | void ShutdownMalloc() 39 | { 40 | g_pAlloc=0; 41 | } 42 | 43 | void* Malloc( size_t bytes, size_t align ) 44 | { 45 | return g_pAlloc->Malloc(bytes,align); 46 | } 47 | 48 | void Free( void* bytes ) 49 | { 50 | g_pAlloc->Free(bytes); 51 | } 52 | 53 | }} -------------------------------------------------------------------------------- /test/embree/math/color.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_COLOR_H__ 18 | #define __EMBREE_COLOR_H__ 19 | 20 | #if defined (__MIC__) 21 | # include "color_scalar.h" 22 | #elif 1//defined (__X86_64__) 23 | # include "color_sse.h" 24 | #else 25 | # include "color_scalar.h" 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /test/embree/sys/sync/condition.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_CONDITION_H__ 18 | #define __EMBREE_CONDITION_H__ 19 | 20 | #include "mutex.h" 21 | 22 | namespace embree 23 | { 24 | class ConditionSys 25 | { 26 | public: 27 | ConditionSys( void ); 28 | ~ConditionSys( void ); 29 | void wait( class MutexSys& mutex ); 30 | void broadcast( void ); 31 | 32 | protected: 33 | void* cond; 34 | }; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test/embree/common/accel.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "accel.h" 18 | #include "../geometry/geometry.h" 19 | 20 | namespace embree 21 | { 22 | Accel::Accel (RTCGeometry* geom, const TriangleType& trity) 23 | : geom(geom), trity(trity), vertices(NULL), numVertices(0) 24 | { 25 | if (trity.needVertices) { 26 | this->vertices = (Vec3fa*) geom->getVertices(); 27 | this->numVertices = geom->getNumVertices(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/embree/sys/stl/string.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_STRING_H__ 18 | #define __EMBREE_STRING_H__ 19 | 20 | #include "../platform.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace std 29 | { 30 | string strlwr(const string& s); 31 | string strupr(const string& s); 32 | 33 | template __forceinline string stringOf( T const& v) { 34 | stringstream s; s << v; return s.str(); 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /test/embree/sys/stl/string.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include 18 | #include 19 | #include "string.h" 20 | 21 | namespace std 22 | { 23 | char to_lower(char c) { return char(tolower(int(c))); } 24 | char to_upper(char c) { return char(toupper(int(c))); } 25 | string strlwr(const string& s) { string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_lower); return dst; } 26 | string strupr(const string& s) { string dst(s); std::transform(dst.begin(), dst.end(), dst.begin(), to_upper); return dst; } 27 | } 28 | -------------------------------------------------------------------------------- /test/embree/sys/library.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_LIBRARY_H__ 18 | #define __EMBREE_LIBRARY_H__ 19 | 20 | #include "platform.h" 21 | 22 | namespace embree 23 | { 24 | /*! type for shared library */ 25 | typedef struct opaque_lib_t* lib_t; 26 | 27 | /*! loads a shared library */ 28 | lib_t openLibrary(const std::string& file); 29 | 30 | /*! returns address of a symbol from the library */ 31 | void* getSymbol(lib_t lib, const std::string& sym); 32 | 33 | /*! unloads a shared library */ 34 | void closeLibrary(lib_t lib); 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test/embree/simd/sse_mic.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SSE_MIC_H__ 18 | #define __EMBREE_SSE_MIC_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "sys/intrinsics.h" 22 | 23 | #include 24 | 25 | namespace embree { 26 | struct sseb_t; 27 | struct ssei_t; 28 | struct ssef_t; 29 | struct sseb_m; 30 | struct ssei_m; 31 | struct ssef_m; 32 | } 33 | 34 | #include "simd/sseb_mic.h" 35 | #include "simd/ssei_mic.h" 36 | #include "simd/ssef_mic.h" 37 | 38 | namespace embree { 39 | typedef sseb_t sseb; 40 | typedef ssei_t ssei; 41 | typedef ssef_t ssef; 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /test/embree/simd/simd.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SIMD_H__ 18 | #define __EMBREE_SIMD_H__ 19 | 20 | #include "math/math.h" 21 | 22 | /* include SSE wrapper classes */ 23 | #if defined(__SSE__) 24 | # include "simd/sse.h" 25 | #endif 26 | 27 | #if defined (__MIC__) 28 | #include "simd/sse_mic.h" 29 | #endif 30 | 31 | /* include AVX wrapper classes */ 32 | #if defined(__AVX__) 33 | #include "simd/avx.h" 34 | #endif 35 | 36 | /* include MIC wrapper classes */ 37 | #if defined(__MIC__) 38 | #include "simd/mic.h" 39 | #endif 40 | 41 | #if defined (__AVX__) 42 | #define AVX_ZERO_UPPER() _mm256_zeroupper() 43 | #else 44 | #define AVX_ZERO_UPPER() 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /test/embree/sys/sysinfo.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SYSINFO_H__ 18 | #define __EMBREE_SYSINFO_H__ 19 | 20 | #include "sys/platform.h" 21 | 22 | namespace embree 23 | { 24 | enum CPUModel { 25 | CPU_UNKNOWN, 26 | CPU_CORE1, 27 | CPU_CORE2, 28 | CPU_CORE_NEHALEM, 29 | CPU_CORE_SANDYBRIDGE 30 | }; 31 | 32 | /*! get the full path to the running executable */ 33 | std::string getExecutableFileName(); 34 | 35 | /*! return platform name */ 36 | std::string getPlatformName(); 37 | 38 | /*! return the name of the CPU */ 39 | std::string getCPUVendor(); 40 | 41 | /*! get microprocessor model */ 42 | CPUModel getCPUModel(); 43 | 44 | /*! return the number of logical threads of the system */ 45 | size_t getNumberOfLogicalThreads(); 46 | 47 | /*! returns the size of the terminal window in characters */ 48 | int getTerminalWidth(); 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/common/alloc.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "alloc.h" 18 | 19 | namespace embree 20 | { 21 | Alloc Alloc::global; 22 | 23 | Alloc::Alloc () { 24 | blocks.reserve(1024); 25 | } 26 | 27 | Alloc::~Alloc () { 28 | } 29 | 30 | size_t Alloc::size() const { 31 | return size_t(blockSize)*blocks.size(); 32 | } 33 | 34 | void Alloc::clear() 35 | { 36 | Lock lock(mutex); 37 | for (size_t i=0; i lock(mutex); 45 | if (blocks.size()) { 46 | void* ptr = blocks.back(); 47 | blocks.pop_back(); 48 | return ptr; 49 | } 50 | return alignedMalloc(blockSize,64); 51 | } 52 | 53 | void Alloc::free(void* ptr) 54 | { 55 | Lock lock(mutex); 56 | blocks.push_back(ptr); 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /test/embree/sys/sync/barrier.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BARRIER_H__ 18 | #define __EMBREE_BARRIER_H__ 19 | 20 | #include "condition.h" 21 | 22 | namespace embree 23 | { 24 | /*! system barrier using operating system */ 25 | class BarrierSys 26 | { 27 | public: 28 | 29 | void init(size_t count) { 30 | this->count = 0; 31 | this->full_size = count; 32 | } 33 | 34 | int wait() 35 | { 36 | count_mutex.lock(); 37 | count++; 38 | 39 | if (count == full_size) { 40 | count = 0; 41 | cond.broadcast(); 42 | count_mutex.unlock(); 43 | return 1; 44 | } 45 | 46 | cond.wait(count_mutex); 47 | count_mutex.unlock(); 48 | return 0; 49 | } 50 | 51 | protected: 52 | size_t count, full_size; 53 | MutexSys count_mutex; 54 | ConditionSys cond; 55 | }; 56 | 57 | /* default barrier type */ 58 | class Barrier : public BarrierSys {}; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /test/embree/builders/splitter_fallback.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPLITTER_FALLBACK_H__ 18 | #define __EMBREE_SPLITTER_FALLBACK_H__ 19 | 20 | #include "../geometry/geometry.h" 21 | #include "primrefalloc.h" 22 | #include "primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | /*! Splits a list of build primitives into two arbitrary lists. */ 27 | template 28 | class FallBackSplitter 29 | { 30 | typedef typename Heuristic::Split Split; 31 | typedef typename Heuristic::PrimInfo PrimInfo; 32 | 33 | public: 34 | 35 | /*! enforce some object median split */ 36 | static void split(size_t threadIndex, PrimRefAlloc* alloc, const RTCGeometry* geom, 37 | PrimRefBlockList& prims, const PrimInfo& pinfo, 38 | PrimRefBlockList& lprims_o, PrimInfo& linfo_o, Split& lsplit_o, 39 | PrimRefBlockList& rprims_o, PrimInfo& rinfo_o, Split& rsplit_o); 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/builder/bvh4aos_globals.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_MIC_GLOBALS_H__ 18 | #define __EMBREE_BVH4AOS_MIC_GLOBALS_H__ 19 | 20 | #include 21 | #include "simd/mic.h" 22 | #include "simd/mic_f.h" 23 | #include "simd/mic_i.h" 24 | #include "simd/mic_m.h" 25 | 26 | #include "math/vec3.h" 27 | 28 | #define MAX_MIC_THREADS 256 29 | #define MAX_MIC_CORES MAX_MIC_THREADS/4 30 | #define CACHELINE_SIZE 64 31 | 32 | #define COMPILER_MEMORY_FENCE __asm__ __volatile__("" ::: "memory") 33 | 34 | #define __ALIGN(x) __declspec(align(x)) 35 | #define _INLINE __forceinline 36 | const float float_infinity = INFINITY; 37 | const float float_minus_infinity = -INFINITY; 38 | const float float_flt_max = FLT_MAX; 39 | const float float_minus_flt_max = -FLT_MAX; 40 | 41 | 42 | #define FATAL(x) { std::cout << "FATAL error in " << __PRETTY_FUNCTION__ << " : " << x << std::endl << std::flush; exit(0); } 43 | #define DBG_PRINT(x) std::cout << #x << " = " << (x) << std::endl << std::flush 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /test/embree/sys/sync/event.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_EVENT_H__ 18 | #define __EMBREE_EVENT_H__ 19 | 20 | #include "mutex.h" 21 | #include "condition.h" 22 | 23 | namespace embree 24 | { 25 | 26 | class EventSys 27 | { 28 | public: 29 | EventSys() 30 | : event(false) {} 31 | 32 | void reset() { 33 | event = false; 34 | } 35 | 36 | void signal() { 37 | #if defined(__MIC__) 38 | event = true; 39 | #else 40 | mutex.lock(); 41 | event = true; 42 | condition.broadcast(); // this broadcast has to be protected! 43 | mutex.unlock(); 44 | #endif 45 | } 46 | 47 | void wait() { 48 | #if defined(__MIC__) 49 | while (!event) __pause(1024); 50 | #else 51 | mutex.lock(); 52 | while (!event) condition.wait(mutex); 53 | mutex.unlock(); 54 | #endif 55 | 56 | } 57 | 58 | protected: 59 | __align(64) volatile bool event; 60 | #if !defined(__MIC__) 61 | MutexSys mutex; 62 | ConditionSys condition; 63 | #endif 64 | }; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /test/embree/sys/taskscheduler_mic.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TASKSCHEDULER_MIC_H__ 18 | #define __EMBREE_TASKSCHEDULER_MIC_H__ 19 | 20 | #include "taskscheduler.h" 21 | #include "sys/sync/mutex.h" 22 | 23 | namespace embree 24 | { 25 | /*! Task scheduler using active synchronization. */ 26 | class TaskSchedulerMIC : public TaskScheduler 27 | { 28 | public: 29 | 30 | enum { NUM_TASKS = 4*1024 }; 31 | 32 | /*! construction */ 33 | TaskSchedulerMIC(); 34 | 35 | private: 36 | 37 | /*! adds a task to the specified task queue */ 38 | void add(ssize_t threadIndex, QUEUE queue, Task* task); 39 | 40 | /*! thread function */ 41 | void run(size_t threadIndex, size_t threadCount); 42 | 43 | /*! sets the terminate thread variable */ 44 | void terminate(); 45 | 46 | private: 47 | Atomic nextScheduleIndex; /*! next index in the task queue where we'll insert a live task */ 48 | Task* volatile tasks[NUM_TASKS]; //!< queue of tasks 49 | volatile atomic_t locks[NUM_TASKS]; 50 | }; 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /test/embree/sys/stl/array2d.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ARRAY2D_H__ 18 | #define __EMBREE_ARRAY2D_H__ 19 | 20 | #include "../platform.h" 21 | 22 | namespace embree 23 | { 24 | template 25 | class Array2D 26 | { 27 | public: 28 | Array2D() : sizeX(0), sizeY(0), data(NULL) {} 29 | 30 | Array2D(size_t sizeX, size_t sizeY) : sizeX(sizeX), sizeY(sizeY) { 31 | data = new T*[sizeX]; 32 | for (size_t x = 0; x < sizeX; x++) 33 | data[x] = new T[sizeY]; 34 | } 35 | 36 | ~Array2D() { 37 | for (size_t x = 0; x < sizeX; x++) 38 | delete[] data[x]; 39 | delete[] data; 40 | } 41 | 42 | operator const T**() const { return const_cast(data); } 43 | operator T**() { return data; } 44 | const T& get(const size_t x, const size_t y) const { return data[x][y]; } 45 | T& get(const size_t x, const size_t y) { return data[x][y]; } 46 | void set(const size_t x, const size_t y, const T& value) { data[x][y] = value; } 47 | 48 | private: 49 | size_t sizeX; 50 | size_t sizeY; 51 | T** data; 52 | }; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /test/embree/sys/taskscheduler_sys.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_TASKSCHEDULER_SYS_H__ 18 | #define __EMBREE_TASKSCHEDULER_SYS_H__ 19 | 20 | #include "taskscheduler.h" 21 | #include "sys/sync/mutex.h" 22 | #include "sys/sync/condition.h" 23 | 24 | namespace embree 25 | { 26 | /*! Task scheduler implementing a stack of tasks. */ 27 | class TaskSchedulerSys : public TaskScheduler 28 | { 29 | public: 30 | 31 | /*! construction */ 32 | TaskSchedulerSys(); 33 | 34 | private: 35 | 36 | /*! only a single initial task can be added from the main thread */ 37 | void add(ssize_t threadIndex, QUEUE queue, Task* task); 38 | 39 | /*! thread function */ 40 | void run(size_t threadIndex, size_t threadCount); 41 | 42 | /*! sets the terminate thread variable */ 43 | void terminate(); 44 | 45 | private: 46 | MutexSys mutex; //!< mutex to protect access to task list 47 | ConditionSys condition; //!< condition to signal new tasks 48 | size_t begin,end; //!< current range of tasks 49 | std::vector tasks; //!< queue of tasks 50 | }; 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /test/embree/bvh2/bvh2_intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH2_INTERSECTOR1_H__ 18 | #define __EMBREE_BVH2_INTERSECTOR1_H__ 19 | 20 | #include "bvh2.h" 21 | #include "../include/intersector1.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH2 Traverser. Single ray traversal implementation for a binary BVH. */ 26 | template 27 | class BVH2Intersector1 : public Intersector1 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH2::NodeRef NodeRef; 32 | typedef typename BVH2::Node Node; 33 | 34 | public: 35 | 36 | BVH2Intersector1 (const BVH2* bvh) 37 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector1* create(const Accel* bvh) { 40 | return new BVH2Intersector1((const BVH2*)bvh); 41 | } 42 | 43 | static void intersect(const BVH2Intersector1* This, Ray& ray); 44 | static bool occluded (const BVH2Intersector1* This, Ray& ray); 45 | 46 | private: 47 | const BVH2* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh4mb/bvh4mb_intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4MB_INTERSECTOR1_H__ 18 | #define __EMBREE_BVH4MB_INTERSECTOR1_H__ 19 | 20 | #include "bvh4mb.h" 21 | #include "../include/intersector1.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4MB Traverser. Single ray traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4MBIntersector1 : public Intersector1 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4MB::Base Base; 32 | typedef typename BVH4MB::Node Node; 33 | 34 | public: 35 | BVH4MBIntersector1 (const BVH4MB* bvh) 36 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector1* create(const Accel* bvh) { 39 | return new BVH4MBIntersector1((const BVH4MB*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4MBIntersector1* This, Ray& ray); 43 | static bool occluded (const BVH4MBIntersector1* This, Ray& ray); 44 | 45 | private: 46 | const BVH4MB* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_INTERSECTOR1_H__ 18 | #define __EMBREE_BVH4AOS_INTERSECTOR1_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../include/intersector1.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4AOS Traverser. Single ray traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4AOSIntersector1 : public Intersector1 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4AOS::NodeRef NodeRef; 32 | typedef typename BVH4AOS::Node Node; 33 | 34 | public: 35 | BVH4AOSIntersector1 (const BVH4AOS* bvh) 36 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector1* create(const Accel* bvh) { 39 | return new BVH4AOSIntersector1((const BVH4AOS*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4AOSIntersector1* This, Ray& ray); 43 | static bool occluded (const BVH4AOSIntersector1* This, Ray& ray); 44 | 45 | private: 46 | const BVH4AOS* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector4_chunk.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR4_CHUNK_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR4_CHUNK_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector4.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector4Chunk : public Intersector4 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4::NodeRef NodeRef; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | BVH4Intersector4Chunk (const BVH4* bvh) 36 | : Intersector4((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector4* create(const Accel* bvh) { 39 | return new BVH4Intersector4Chunk((const BVH4*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4Intersector4Chunk* This, Ray4& ray, const __m128 valid); 43 | static __m128 occluded (const BVH4Intersector4Chunk* This, Ray4& ray, const __m128 valid); 44 | 45 | private: 46 | const BVH4* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector8_chunk.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR8_CHUNK_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR8_CHUNK_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector8.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector8Chunk : public Intersector8 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4::NodeRef NodeRef; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | BVH4Intersector8Chunk (const BVH4* bvh) 36 | : Intersector8((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector8* create(const Accel* bvh) { 39 | return new BVH4Intersector8Chunk((const BVH4*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4Intersector8Chunk* This, Ray8& ray, const __m256 valid); 43 | static __m256 occluded (const BVH4Intersector8Chunk* This, Ray8& ray, const __m256 valid); 44 | 45 | private: 46 | const BVH4* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh8/bvh8_intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH8_INTERSECTOR1_H__ 18 | #define __EMBREE_BVH8_INTERSECTOR1_H__ 19 | 20 | #include "bvh8.h" 21 | #include "../include/intersector1.h" 22 | #include "../common/stack_item.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH8 Traverser. Single ray traversal implementation for a Quad BVH. */ 27 | template 28 | class BVH8Intersector1 : public Intersector1 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef typename TriangleIntersector::Triangle Triangle; 32 | typedef typename BVH8::NodeRef NodeRef; 33 | typedef typename BVH8::Node Node; 34 | typedef StackItemT StackItem; 35 | 36 | public: 37 | BVH8Intersector1 (const BVH8* bvh) 38 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 39 | 40 | static Intersector1* create(const Accel* bvh) { 41 | return new BVH8Intersector1((const BVH8*)bvh); 42 | } 43 | 44 | static void intersect(const BVH8Intersector1* This, Ray& ray); 45 | static bool occluded (const BVH8Intersector1* This, Ray& ray); 46 | 47 | private: 48 | const BVH8* bvh; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /test/embree/bvh2/bvh2_intersector4.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH2_INTERSECTOR4_CHUNK_H__ 18 | #define __EMBREE_BVH2_INTERSECTOR4_CHUNK_H__ 19 | 20 | #include "bvh2.h" 21 | #include "../include/intersector4.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH2 Traverser. Packet traversal implementation for a binary BVH. */ 26 | template 27 | class BVH2Intersector4Chunk : public Intersector4 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH2::NodeRef NodeRef; 32 | typedef typename BVH2::Node Node; 33 | 34 | public: 35 | 36 | BVH2Intersector4Chunk (const BVH2* bvh) 37 | : Intersector4((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector4* create(const Accel* bvh) { 40 | return new BVH2Intersector4Chunk((const BVH2*)bvh); 41 | } 42 | 43 | static void intersect(const BVH2Intersector4Chunk* This, Ray4& ray, const __m128 valid); 44 | static __m128 occluded (const BVH2Intersector4Chunk* This, Ray4& ray, const __m128 valid); 45 | 46 | private: 47 | const BVH2* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh2/bvh2_intersector8.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH2_INTERSECTOR8_CHUNK_H__ 18 | #define __EMBREE_BVH2_INTERSECTOR8_CHUNK_H__ 19 | 20 | #include "bvh2.h" 21 | #include "../include/intersector8.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH2 Traverser. Packet traversal implementation for a binary BVH. */ 26 | template 27 | class BVH2Intersector8Chunk : public Intersector8 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH2::NodeRef NodeRef; 32 | typedef typename BVH2::Node Node; 33 | 34 | public: 35 | 36 | BVH2Intersector8Chunk (const BVH2* bvh) 37 | : Intersector8((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector8* create(const Accel* bvh) { 40 | return new BVH2Intersector8Chunk((const BVH2*)bvh); 41 | } 42 | 43 | static void intersect(const BVH2Intersector8Chunk* This, Ray8& ray, const __m256 valid); 44 | static __m256 occluded (const BVH2Intersector8Chunk* This, Ray8& ray, const __m256 valid); 45 | 46 | private: 47 | const BVH2* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector8_single.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR8_SINGLE_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR8_SINGLE_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector8.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector8Single : public Intersector8 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector1::Triangle Triangle; 31 | typedef typename BVH4::NodeRef NodeRef; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | BVH4Intersector8Single (const BVH4* bvh) 36 | : Intersector8((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector8* create(const Accel* bvh) { 39 | return new BVH4Intersector8Single((const BVH4*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4Intersector8Single* This, Ray8& ray, const __m256 valid); 43 | static __m256 occluded (const BVH4Intersector8Single* This, Ray8& ray, const __m256 valid); 44 | 45 | private: 46 | const BVH4* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector4_single.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR4_SINGLE_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR4_SINGLE_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector4.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector4Single : public Intersector4 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector1::Triangle Triangle; 31 | typedef typename BVH4::NodeRef NodeRef; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | 36 | BVH4Intersector4Single (const BVH4* bvh) 37 | : Intersector4((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector4* create(const Accel* bvh) { 40 | return new BVH4Intersector4Single((const BVH4*)bvh); 41 | } 42 | 43 | static void intersect(const BVH4Intersector4Single* This, Ray4& ray, const __m128 valid); 44 | static __m128 occluded (const BVH4Intersector4Single* This, Ray4& ray, const __m128 valid); 45 | 46 | private: 47 | const BVH4* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh4mb/bvh4mb_intersector8.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4MB_INTERSECTOR8_CHUNK_H__ 18 | #define __EMBREE_BVH4MB_INTERSECTOR8_CHUNK_H__ 19 | 20 | #include "bvh4mb.h" 21 | #include "../include/intersector8.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4MB Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4MBIntersector8Chunk : public Intersector8 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4MB::Base Base; 32 | typedef typename BVH4MB::Node Node; 33 | 34 | public: 35 | BVH4MBIntersector8Chunk (const BVH4MB* bvh) 36 | : Intersector8((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector8* create(const Accel* bvh) { 39 | return new BVH4MBIntersector8Chunk((const BVH4MB*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4MBIntersector8Chunk* This, Ray8& ray, const __m256 valid); 43 | static __m256 occluded (const BVH4MBIntersector8Chunk* This, Ray8& ray, const __m256 valid); 44 | 45 | private: 46 | const BVH4MB* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4i/bvh4i_intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4I_INTERSECTOR1_H__ 18 | #define __EMBREE_BVH4I_INTERSECTOR1_H__ 19 | 20 | #include "bvh4i.h" 21 | #include "../include/intersector1.h" 22 | #include "../common/stack_item.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH4i Traverser. Single ray traversal implementation for a Quad BVH. */ 27 | template 28 | class BVH4iIntersector1 : public Intersector1 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef typename TriangleIntersector::Triangle Triangle; 32 | typedef typename BVH4i::NodeRef NodeRef; 33 | typedef typename BVH4i::Node Node; 34 | typedef StackItemT StackItem; 35 | 36 | public: 37 | BVH4iIntersector1 (const BVH4i* bvh) 38 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 39 | 40 | static Intersector1* create(const Accel* bvh) { 41 | return new BVH4iIntersector1((const BVH4i*)bvh); 42 | } 43 | 44 | static void intersect(const BVH4iIntersector1* This, Ray& ray); 45 | static bool occluded (const BVH4iIntersector1* This, Ray& ray); 46 | 47 | private: 48 | const BVH4i* bvh; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector1_avx.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR1_AVX_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR1_AVX_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector1.h" 22 | #include "../common/stack_item.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH4 Traverser. Single ray traversal implementation for a Quad BVH. */ 27 | template 28 | class BVH4Intersector1AVX : public Intersector1 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef typename TriangleIntersector::Triangle Triangle; 32 | typedef typename BVH4::NodeRef NodeRef; 33 | typedef typename BVH4::Node Node; 34 | typedef StackItemT StackItem; 35 | 36 | public: 37 | BVH4Intersector1AVX (const BVH4* bvh) 38 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 39 | 40 | static Intersector1* create(const Accel* bvh) { 41 | return new BVH4Intersector1AVX((const BVH4*)bvh); 42 | } 43 | 44 | static void intersect(const BVH4Intersector1AVX* This, Ray& ray); 45 | static bool occluded (const BVH4Intersector1AVX* This, Ray& ray); 46 | 47 | private: 48 | const BVH4* bvh; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /test/embree/bvh4mb/bvh4mb_intersector4.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4MB_INTERSECTOR4_CHUNK_H__ 18 | #define __EMBREE_BVH4MB_INTERSECTOR4_CHUNK_H__ 19 | 20 | #include "bvh4mb.h" 21 | #include "../include/intersector4.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4MB Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4MBIntersector4Chunk : public Intersector4 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector::Triangle Triangle; 31 | typedef typename BVH4MB::Base Base; 32 | typedef typename BVH4MB::Node Node; 33 | 34 | public: 35 | BVH4MBIntersector4Chunk (const BVH4MB* bvh) 36 | : Intersector4((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector4* create(const Accel* bvh) { 39 | return new BVH4MBIntersector4Chunk((const BVH4MB*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4MBIntersector4Chunk* This, Ray4& ray, const __m128 valid); 43 | static __m128 occluded (const BVH4MBIntersector4Chunk* This, Ray4& ray, const __m128 valid); 44 | 45 | private: 46 | const BVH4MB* bvh; 47 | 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector8_hybrid.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR8_HYBRID_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR8_HYBRID_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector8.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector8Hybrid : public Intersector8 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector8::Triangle Triangle; 31 | typedef typename BVH4::NodeRef NodeRef; 32 | typedef typename BVH4::Node Node; 33 | 34 | public: 35 | BVH4Intersector8Hybrid (const BVH4* bvh) 36 | : Intersector8((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 37 | 38 | static Intersector8* create(const Accel* bvh) { 39 | return new BVH4Intersector8Hybrid((const BVH4*)bvh); 40 | } 41 | 42 | static void intersect(const BVH4Intersector8Hybrid* This, Ray8& ray, const __m256 valid); 43 | static __m256 occluded (const BVH4Intersector8Hybrid* This, Ray8& ray, const __m256 valid); 44 | 45 | private: 46 | const BVH4* bvh; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/simd/mic_f.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "mic.h" 18 | 19 | namespace embree 20 | { 21 | MIC_ALIGN float mic_f::float_idMod4[16] = {0.f,1.f,2.f,3.f,0.f,1.f,2.f,3.f,0.f,1.f,2.f,3.f,0.f,1.f,2.f,3.f}; 22 | MIC_ALIGN float mic_f::float_idDiv4[16] = {0.f,0.f,0.f,0.f,1.f,1.f,1.f,1.f,2.f,2.f,2.f,2.f,3.f,3.f,3.f,3.f}; 23 | MIC_ALIGN float mic_f::float_identity[16] = {0.f,1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f,10.f,11.f,12.f,13.f,14.f,15.f}; 24 | MIC_ALIGN float mic_f::float_cancelLE[4] = { 1.0f,1.0f,1.0f,0.0f }; 25 | 26 | MIC_ALIGN float mic_f::float_one_over[32] = { 27 | 0.0f, 28 | 1.0f / 1.0f, 29 | 1.0f / 2.0f, 30 | 1.0f / 3.0f, 31 | 1.0f / 4.0f, 32 | 1.0f / 5.0f, 33 | 1.0f / 6.0f, 34 | 1.0f / 8.0f, 35 | 1.0f / 9.0f, 36 | 1.0f / 10.0f, 37 | 1.0f / 11.0f, 38 | 1.0f / 12.0f, 39 | 1.0f / 13.0f, 40 | 1.0f / 14.0f, 41 | 1.0f / 15.0f, 42 | 1.0f / 16.0f, 43 | 1.0f / 17.0f, 44 | 1.0f / 18.0f, 45 | 1.0f / 19.0f, 46 | 1.0f / 21.0f, 47 | 1.0f / 22.0f, 48 | 1.0f / 23.0f, 49 | 1.0f / 24.0f, 50 | 1.0f / 25.0f, 51 | 1.0f / 26.0f, 52 | 1.0f / 27.0f, 53 | 1.0f / 28.0f, 54 | 1.0f / 29.0f, 55 | 1.0f / 30.0f, 56 | 1.0f / 31.0f 57 | }; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_triangle1_intersector16_single.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_SINGLE_H__ 18 | #define __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_SINGLE_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray16.h" 22 | #include "../include/intersector16.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH4AOS Traverser. Packet traversal for Quad BVH. */ 27 | class BVH4AOSTriangle1Intersector16Single : public Intersector16 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename BVH4AOS::NodeRef NodeRef; 31 | typedef typename BVH4AOS::Node Node; 32 | 33 | public: 34 | BVH4AOSTriangle1Intersector16Single (const BVH4AOS* bvh) 35 | : Intersector16((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 36 | 37 | static Intersector16* create(const Accel* bvh) { 38 | return new BVH4AOSTriangle1Intersector16Single((const BVH4AOS*)bvh); 39 | } 40 | 41 | static void intersect (const BVH4AOSTriangle1Intersector16Single* This, Ray16& ray, const __mmask valid); 42 | static __mmask occluded (const BVH4AOSTriangle1Intersector16Single* This, Ray16& ray, const __mmask valid); 43 | 44 | private: 45 | const BVH4AOS* bvh; 46 | }; 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_intersector16_chunk.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_INTERSECTOR16_CHUNK_H__ 18 | #define __EMBREE_BVH4AOS_INTERSECTOR16_CHUNK_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray16.h" 22 | #include "../include/intersector16.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH4AOS Traverser. Packet traversal for Quad BVH. */ 27 | template 28 | class BVH4AOSIntersector16Chunk : public Intersector16 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef typename TriangleIntersector::Triangle Triangle; 32 | typedef typename BVH4AOS::NodeRef NodeRef; 33 | typedef typename BVH4AOS::Node Node; 34 | 35 | public: 36 | BVH4AOSIntersector16Chunk (const BVH4AOS* bvh) 37 | : Intersector16((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector16* create(const Accel* bvh) { 40 | return new BVH4AOSIntersector16Chunk((const BVH4AOS*)bvh); 41 | } 42 | 43 | static void intersect (const BVH4AOSIntersector16Chunk* This, Ray16& ray, const __mmask valid); 44 | static __mmask occluded (const BVH4AOSIntersector16Chunk* This, Ray16& ray, const __mmask valid); 45 | 46 | private: 47 | const BVH4AOS* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_triangle1_intersector1_ref.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR1_REF_H__ 18 | #define __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR1_REF_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray.h" 22 | #include "../include/intersector1.h" 23 | #include "../geometry/triangle1.h" 24 | 25 | namespace embree 26 | { 27 | /*! BVH4AOS Traverser. Single ray traversal implementation for a Quad BVH. */ 28 | class BVH4AOSTriangle1Intersector1Ref : public Intersector1 29 | { 30 | public: 31 | 32 | /* shortcuts for frequently used types */ 33 | typedef Triangle1 Triangle; 34 | typedef typename BVH4AOS::NodeRef NodeRef; 35 | typedef typename BVH4AOS::Node Node; 36 | 37 | public: 38 | BVH4AOSTriangle1Intersector1Ref (const BVH4AOS* bvh) 39 | : Intersector1((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 40 | 41 | static Intersector1* create(const Accel* bvh) { 42 | return new BVH4AOSTriangle1Intersector1Ref((const BVH4AOS*)bvh); 43 | } 44 | 45 | static void intersect(const BVH4AOSTriangle1Intersector1Ref* This, Ray& ray); 46 | static bool occluded (const BVH4AOSTriangle1Intersector1Ref* This, Ray& ray); 47 | 48 | private: 49 | const BVH4AOS* bvh; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /test/embree/common/registry_intersector.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_INTERSECTOR_REGISTRY_H__ 18 | #define __EMBREE_INTERSECTOR_REGISTRY_H__ 19 | 20 | #include "default.h" 21 | #include "../geometry/triangle.h" 22 | #include "../include/embree.h" 23 | 24 | namespace embree 25 | { 26 | /*! Registry for intersectors */ 27 | template 28 | class IntersectorRegistry 29 | { 30 | public: 31 | 32 | typedef T* (*Constructor) (const Accel* accel); 33 | 34 | /*! sets the default intersector for an acceleration structure */ 35 | void setAccelDefaultTraverser(const std::string& accelName, const std::string& travName); 36 | 37 | /*! adds a new intersector */ 38 | void add(const std::string& accelName, const std::string& triName, const std::string& travName, const std::string& intName, bool def, const Constructor constructor); 39 | 40 | /*! get registered intersector by name */ 41 | T* get(std::string accelName, std::string travName, Accel* accel); 42 | 43 | /*! clears the registry */ 44 | void clear(); 45 | 46 | private: 47 | std::map defaultTraverser; 48 | std::map defaultIntersector; 49 | std::map table; 50 | }; 51 | } 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector4_hybrid.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR4_HYBRID_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR4_HYBRID_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector4.h" 22 | 23 | namespace embree 24 | { 25 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 26 | template 27 | class BVH4Intersector4Hybrid : public Intersector4 28 | { 29 | /* shortcuts for frequently used types */ 30 | typedef typename TriangleIntersector4::Triangle Triangle; 31 | typedef typename TriangleIntersector4::TriangleIntersector1 TriangleIntersector1; 32 | typedef typename BVH4::NodeRef NodeRef; 33 | typedef typename BVH4::Node Node; 34 | 35 | public: 36 | 37 | BVH4Intersector4Hybrid (const BVH4* bvh) 38 | : Intersector4((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 39 | 40 | static Intersector4* create(const Accel* bvh) { 41 | return new BVH4Intersector4Hybrid((const BVH4*)bvh); 42 | } 43 | 44 | static void intersect(const BVH4Intersector4Hybrid* This, Ray4& ray, const __m128 valid); 45 | static __m128 occluded (const BVH4Intersector4Hybrid* This, Ray4& ray, const __m128 valid); 46 | 47 | private: 48 | const BVH4* bvh; 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /test/embree/sys/sys.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {46478ecd-0029-4859-aa88-968d2bb1d791} 6 | 7 | 8 | {dd20820d-5a20-4f91-9e4f-04ab8a4b4dce} 9 | 10 | 11 | 12 | 13 | stl 14 | 15 | 16 | stl 17 | 18 | 19 | sync 20 | 21 | 22 | sync 23 | 24 | 25 | sync 26 | 27 | 28 | sync 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | stl 50 | 51 | 52 | sync 53 | 54 | 55 | sync 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_triangle1_intersector16_chunk.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_CHUNK_H__ 18 | #define __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_CHUNK_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray16.h" 22 | #include "../include/intersector16.h" 23 | #include "../geometry/triangles.h" 24 | 25 | namespace embree 26 | { 27 | /*! BVH4AOS Traverser. Packet traversal for Quad BVH. */ 28 | class BVH4AOSTriangle1Intersector16Chunk : public Intersector16 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef Triangle1 Triangle; 32 | typedef typename BVH4AOS::NodeRef NodeRef; 33 | typedef typename BVH4AOS::Node Node; 34 | 35 | public: 36 | BVH4AOSTriangle1Intersector16Chunk (const BVH4AOS* bvh) 37 | : Intersector16((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 38 | 39 | static Intersector16* create(const Accel* bvh) { 40 | return new BVH4AOSTriangle1Intersector16Chunk((const BVH4AOS*)bvh); 41 | } 42 | 43 | static void intersect (const BVH4AOSTriangle1Intersector16Chunk* This, Ray16& ray, const __mmask valid); 44 | static __mmask occluded (const BVH4AOSTriangle1Intersector16Chunk* This, Ray16& ray, const __mmask valid); 45 | 46 | private: 47 | const BVH4AOS* bvh; 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /test/embree/sys/thread.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_THREAD_H__ 18 | #define __EMBREE_THREAD_H__ 19 | 20 | #include "platform.h" 21 | 22 | namespace embree 23 | { 24 | /*! type for thread */ 25 | typedef struct opaque_thread_t* thread_t; 26 | 27 | /*! signature of thread start function */ 28 | typedef void (*thread_func)(void*); 29 | 30 | /*! creates a hardware thread running on specific logical thread */ 31 | thread_t createThread(thread_func f, void* arg, size_t stack_size = 0, ssize_t threadID = -1); 32 | 33 | /*! set affinity of the calling thread */ 34 | void setAffinity(ssize_t affinity); 35 | 36 | /*! the thread calling this function gets yielded */ 37 | void yield(); 38 | 39 | /*! waits until the given thread has terminated */ 40 | void join(thread_t tid); 41 | 42 | /*! destroy handle of a thread */ 43 | void destroyThread(thread_t tid); 44 | 45 | /*! type for handle to thread local storage */ 46 | typedef struct opaque_tls_t* tls_t; 47 | 48 | /*! creates thread local storage */ 49 | tls_t createTls(); 50 | 51 | /*! set the thread local storage pointer */ 52 | void setTls(tls_t tls, void* const ptr); 53 | 54 | /*! return the thread local storage pointer */ 55 | void* getTls(tls_t tls); 56 | 57 | /*! destroys thread local storage identifier */ 58 | void destroyTls(tls_t tls); 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /BRay/build/msvc2013/BRay.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {07abb38a-5a3d-45e1-8d4f-6a5952a2c95b} 6 | 7 | 8 | {5c6abfbb-28af-47d8-9149-0c862fe6c620} 9 | 10 | 11 | 12 | 13 | src 14 | 15 | 16 | src 17 | 18 | 19 | src 20 | 21 | 22 | src 23 | 24 | 25 | src 26 | 27 | 28 | src 29 | 30 | 31 | src 32 | 33 | 34 | src 35 | 36 | 37 | src 38 | 39 | 40 | src 41 | 42 | 43 | include 44 | 45 | 46 | 47 | 48 | src 49 | 50 | 51 | src 52 | 53 | 54 | src 55 | 56 | 57 | src 58 | 59 | 60 | src 61 | 62 | 63 | src 64 | 65 | 66 | 67 | 68 | src 69 | 70 | 71 | src 72 | 73 | 74 | -------------------------------------------------------------------------------- /test/embree/builders/primref.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PRIM_REF_H__ 18 | #define __EMBREE_PRIM_REF_H__ 19 | 20 | #include "../common/default.h" 21 | 22 | namespace embree 23 | { 24 | /*! A primitive reference stores the bounds of the primitive and its ID. */ 25 | struct __align(16) PrimRef 26 | { 27 | __forceinline PrimRef () {} 28 | __forceinline PrimRef (const BBox3f& bounds, size_t id) { 29 | assert(!bounds.empty() || id == size_t(-1)); 30 | lower = bounds.lower; 31 | upper = bounds.upper; 32 | #if defined(__X86_64__) 33 | lower.a = (unsigned) (id >> 0); 34 | upper.a = (unsigned) (id >> 32); 35 | #else 36 | lower.a = id; 37 | #endif 38 | } 39 | 40 | __forceinline size_t id() const { 41 | #if defined(__X86_64__) 42 | return (size_t(unsigned(upper.a)) << 32) | size_t(unsigned(lower.a)); 43 | #else 44 | return lower.a; 45 | #endif 46 | } 47 | 48 | __forceinline const BBox3f bounds() const { 49 | return BBox3f(lower,upper); 50 | } 51 | 52 | public: 53 | Vec3fa lower; 54 | Vec3fa upper; 55 | }; 56 | 57 | /*! Outputs primitive reference to a stream. */ 58 | inline std::ostream& operator<<(std::ostream& cout, const PrimRef& ref) { 59 | return cout << "{ lower = " << ref.lower << ", upper = " << ref.upper << ", id = " << ref.id() << " }"; 60 | } 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /test/embree/sys/sync/mutex.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_MUTEX_H__ 18 | #define __EMBREE_MUTEX_H__ 19 | 20 | #include "../platform.h" 21 | #include "atomic.h" 22 | 23 | namespace embree 24 | { 25 | /*! system mutex */ 26 | class MutexSys { 27 | friend class ConditionSys; 28 | public: 29 | 30 | MutexSys( void ); 31 | ~MutexSys( void ); 32 | 33 | void lock( void ); 34 | void unlock( void ); 35 | 36 | protected: 37 | void* mutex; 38 | 39 | MutexSys( const MutexSys& ); // don't implement 40 | MutexSys& operator =( const MutexSys& ); // don't implement 41 | }; 42 | 43 | /*! spinning mutex */ 44 | class MutexActive { 45 | public: 46 | __forceinline MutexActive( void ) : flag(0) {} 47 | void lock ( void ); 48 | void unlock( void ); 49 | protected: 50 | Atomic flag; 51 | 52 | MutexActive( const MutexActive& ); // don't implement 53 | MutexActive& operator =( const MutexActive& ); // don't implement 54 | }; 55 | 56 | /*! safe mutex lock and unlock helper */ 57 | template class Lock { 58 | public: 59 | Lock (Mutex& mutex) : mutex(mutex) { mutex.lock(); } 60 | ~Lock() { mutex.unlock(); } 61 | protected: 62 | Mutex& mutex; 63 | Lock( const Lock& ); // don't implement 64 | Lock& operator =( const Lock& ); // don't implement 65 | }; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_triangle1_intersector16_chunk_ref.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_CHUNK_REF_H__ 18 | #define __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_CHUNK_REF_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray16.h" 22 | #include "../include/intersector16.h" 23 | #include "../geometry/triangle1.h" 24 | 25 | namespace embree 26 | { 27 | /*! BVH4AOS Traverser. Single ray traversal implementation for a Quad BVH. */ 28 | class BVH4AOSTriangle1Intersector16ChunkRef : public Intersector16 29 | { 30 | public: 31 | 32 | /* shortcuts for frequently used types */ 33 | typedef Triangle1 Triangle; 34 | typedef typename BVH4AOS::NodeRef NodeRef; 35 | typedef typename BVH4AOS::Node Node; 36 | 37 | public: 38 | BVH4AOSTriangle1Intersector16ChunkRef (const BVH4AOS* bvh) 39 | : Intersector16((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 40 | 41 | static Intersector16* create(const Accel* bvh) { 42 | return new BVH4AOSTriangle1Intersector16ChunkRef((const BVH4AOS*)bvh); 43 | } 44 | 45 | static void intersect (const BVH4AOSTriangle1Intersector16ChunkRef* This, Ray16& ray, const __mmask valid); 46 | static __mmask occluded (const BVH4AOSTriangle1Intersector16ChunkRef* This, Ray16& ray, const __mmask valid); 47 | 48 | private: 49 | const BVH4AOS* bvh; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/bvh4aos_triangle1_intersector16_hybrid_ref.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_HYBRID_REF_H__ 18 | #define __EMBREE_BVH4AOS_TRIANGLE1_INTERSECTOR16_HYBRID_REF_H__ 19 | 20 | #include "bvh4aos.h" 21 | #include "../common/ray16.h" 22 | #include "../include/intersector16.h" 23 | #include "../geometry/triangle1.h" 24 | 25 | namespace embree 26 | { 27 | /*! BVH4AOS Traverser. Single ray traversal implementation for a Quad BVH. */ 28 | class BVH4AOSTriangle1Intersector16HybridRef : public Intersector16 29 | { 30 | public: 31 | 32 | /* shortcuts for frequently used types */ 33 | typedef Triangle1 Triangle; 34 | typedef typename BVH4AOS::NodeRef NodeRef; 35 | typedef typename BVH4AOS::Node Node; 36 | 37 | public: 38 | BVH4AOSTriangle1Intersector16HybridRef (const BVH4AOS* bvh) 39 | : Intersector16((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh) {} 40 | 41 | static Intersector16* create(const Accel* bvh) { 42 | return new BVH4AOSTriangle1Intersector16HybridRef((const BVH4AOS*)bvh); 43 | } 44 | 45 | static void intersect (const BVH4AOSTriangle1Intersector16HybridRef* This, Ray16& ray, const __mmask valid); 46 | static __mmask occluded (const BVH4AOSTriangle1Intersector16HybridRef* This, Ray16& ray, const __mmask valid); 47 | 48 | private: 49 | const BVH4AOS* bvh; 50 | }; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /test/embree/common/accel.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ACCEL_H__ 18 | #define __EMBREE_ACCEL_H__ 19 | 20 | #include "registry_builder.h" 21 | #include "registry_intersector.h" 22 | #include "../geometry/triangle.h" 23 | 24 | namespace embree 25 | { 26 | struct RTCGeometry; 27 | 28 | /*! Abstract acceleration structure interface. */ 29 | class Accel : public RefCount { 30 | ALIGNED_CLASS; 31 | public: 32 | 33 | /*! Default constructor. */ 34 | Accel (RTCGeometry* geom, const TriangleType& trity); 35 | 36 | public: 37 | 38 | /*! return name of this acceleration structure */ 39 | virtual const std::string name() const = 0; 40 | 41 | /*! prints statistics */ 42 | virtual void print() = 0; 43 | 44 | __forceinline void* nodePtr() { return NULL; } 45 | __forceinline const void* nodePtr() const { return NULL; } 46 | 47 | __forceinline void* triPtr() { return NULL; } 48 | __forceinline const void* triPtr() const { return NULL; } 49 | 50 | public: 51 | RTCGeometry* geom; //!< geometry this acceleration structure is build over 52 | const TriangleType& trity; //!< triangle type stored in BVH 53 | const Vec3fa* vertices; //!< Pointer to vertex array. 54 | size_t numVertices; //!< Number of vertices 55 | BBox3f bounds; //!< Bounding box of geometry. 56 | }; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /BRay/src/PoolAllocator.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // PoolAllocator.h 4 | // 5 | // Pooled memory allocator for batching small mallocs 6 | // 7 | // The lazy man's utility library 8 | // Joshua Barczak 9 | // Copyright 2014 Joshua Barczak 10 | // 11 | // LICENSE: See Doc\License.txt for terms and conditions 12 | // 13 | //===================================================================================================================== 14 | 15 | 16 | #ifndef _POOL_ALLOCATOR_H_ 17 | #define _POOL_ALLOCATOR_H_ 18 | 19 | namespace BRay 20 | { 21 | /// Simple block allocator which allocates storage in chunks and never releases any of it 22 | /// This is intended for aggregating large numbers of temporary allocs which are all released at once 23 | /// It is by no means a general purpose allocator. 24 | class PoolAllocator 25 | { 26 | public: 27 | 28 | class ScopedFree 29 | { 30 | public: 31 | ScopedFree( PoolAllocator& alloc ) : m_rAlloc(alloc){} 32 | ~ScopedFree() { m_rAlloc.FreeAll(); }; 33 | private: 34 | PoolAllocator& m_rAlloc; 35 | }; 36 | 37 | class ScopedRecycler 38 | { 39 | public: 40 | ScopedRecycler( PoolAllocator& alloc ) : m_rAlloc(alloc){} 41 | ~ScopedRecycler() { m_rAlloc.Recycle(); }; 42 | private: 43 | PoolAllocator& m_rAlloc; 44 | }; 45 | 46 | PoolAllocator() : m_pHead(0) {} 47 | ~PoolAllocator() { FreeAll(); } 48 | 49 | template< class T > T* GetA() { return reinterpret_cast( GetMore( sizeof(T) ) ); } 50 | template< class T > T* GetSome( size_t n ) { return reinterpret_cast( GetMore( sizeof(T)*n ) ); }; 51 | void* GetMore( size_t nSize ); 52 | 53 | void FreeAll( ); 54 | 55 | void Recycle( ); 56 | 57 | private: 58 | 59 | struct AllocHeader 60 | { 61 | AllocHeader* pNext; ///< Next block in linked list 62 | size_t nCapacity; ///< Total Size of block (including header) 63 | size_t nOffset; ///< Offset of next free byte 64 | }; 65 | 66 | 67 | enum 68 | { 69 | ALIGN = 64, ///< Align all 'GetMore' calls to this size 70 | CHUNKSIZE = 16*1024, ///< Align all mallocs to this size 71 | HEADER_SIZE = (sizeof(AllocHeader) + ALIGN-1) & ~(ALIGN-1) 72 | }; 73 | 74 | AllocHeader* m_pHead; 75 | }; 76 | } 77 | 78 | 79 | 80 | #endif -------------------------------------------------------------------------------- /test/embree/bvh4aos/builder/bvh4aos_task_scheduler.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_MIC_TASK_SCHEDULER_H__ 18 | #define __EMBREE_BVH4AOS_MIC_TASK_SCHEDULER_H__ 19 | 20 | #include "bvh4aos_globals.h" 21 | #include "bvh4aos_builder_util.h" 22 | 23 | namespace embree 24 | { 25 | 26 | class QBVHTaskScheduler 27 | { 28 | public: 29 | 30 | static AtomicCounter taskCounter; 31 | static QuadTreeBarrier taskBarrier; 32 | 33 | static unsigned int NUM_TOTAL_THREADS; 34 | static unsigned int NUM_TOTAL_CORES; 35 | static unsigned int CONTROL_THREAD_ID; 36 | 37 | static AtomicMutex coreTaskCounter[MAX_MIC_CORES]; 38 | static AtomicMutex debugMutex; 39 | 40 | static void (* taskPtr)(const unsigned int threadID); 41 | 42 | static bool taskDispatch(const unsigned int threadID = CONTROL_THREAD_ID); 43 | static void taskDispatchMainLoop(const unsigned int threadID); 44 | static void releaseThreads(); 45 | 46 | static _INLINE bool dispatchTask(void (* task)(const unsigned int threadID), 47 | const unsigned int threadID = CONTROL_THREAD_ID) 48 | { 49 | QBVHTaskScheduler::taskPtr = task; 50 | return QBVHTaskScheduler::taskDispatch(threadID); 51 | } 52 | 53 | static _INLINE void syncThreads(const unsigned int threadID, 54 | const unsigned int threads = NUM_TOTAL_THREADS) 55 | { 56 | taskBarrier.sync(threadID,threads); 57 | } 58 | 59 | }; 60 | 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /BRay/src/Accelerator.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // BVHBuilder.h 4 | // 5 | // B-Ray BVH builder 6 | // 7 | // Copyright 2015 Joshua Barczak 8 | // 9 | // LICENSE: This source code is distributed under the terms of the GNU GPL v2 10 | // 11 | // 12 | //===================================================================================================================== 13 | 14 | #ifndef _BVH_BUILDER_H_ 15 | #define _BVH_BUILDER_H_ 16 | 17 | #include "Types.h" 18 | #include "PoolAllocator.h" 19 | 20 | namespace BRay{ 21 | struct Mesh; 22 | 23 | namespace _INTERNAL{ 24 | 25 | using BRay::PoolAllocator; 26 | 27 | struct PreprocessedTri; 28 | 29 | struct TriList 30 | { 31 | uint32 GetTriCount() const { return m_nTris; }; 32 | 33 | const PreprocessedTri* GetTriList() const { return (const PreprocessedTri*) (this+1); } 34 | PreprocessedTri* GetTriList() { return (PreprocessedTri*) (this+1); } 35 | uint32 m_nTris; 36 | }; 37 | 38 | 39 | struct BVHNode 40 | { 41 | bool IsLeaf() const { return (m_pNext & 4)!=0; } 42 | 43 | size_t GetSplitAxis() const { return m_pNext & 3; } 44 | const char* GetPrefetch() const { return (const char*)m_pNext; } 45 | const float* GetAABB() const { return m_AABB; } 46 | TriList* GetTriList() const { return (TriList*)(m_pNext&~7); } 47 | BVHNode* GetLeftChild() const { return (BVHNode*)(m_pNext&~7); } 48 | BVHNode* GetRightChild() const { return GetLeftChild()+1; } 49 | 50 | void SetAABB( const float* p ) 51 | { 52 | for( int i=0; i<6; i++ ) 53 | m_AABB[i] = p[i]; 54 | } 55 | 56 | void CreateLeaf( TriList* pList ) 57 | { 58 | m_pNext = (uint64)pList; 59 | m_pNext |= 4; 60 | } 61 | 62 | void CreateInnerNode( BVHNode* pKids, uint nAxis ) 63 | { 64 | m_pNext = (uint64) pKids; 65 | m_pNext |= (nAxis); 66 | } 67 | 68 | 69 | float m_AABB[6]; 70 | uint64 m_pNext; ///< Pointer to pair of child nodes (inner), or triangle list (leaf) 71 | ///< low-order bits contain 2-bit split axis and 1 bit (is-leaf) flag 72 | }; 73 | 74 | 75 | 76 | struct Accelerator : public Object 77 | { 78 | BVHNode* pBVHRoot; 79 | size_t nStackDepth; 80 | size_t nRefCount; 81 | PoolAllocator Memory; 82 | }; 83 | 84 | void BuildBVH( Accelerator* pAccel, const Mesh* pMesh, float fIntersectCost ); 85 | 86 | }} 87 | 88 | #endif -------------------------------------------------------------------------------- /BRay/include/BRay.h: -------------------------------------------------------------------------------- 1 | //===================================================================================================================== 2 | // 3 | // BRay.h 4 | // 5 | // B-Ray raytracer API 6 | // 7 | // Copyright 2015 Joshua Barczak 8 | // 9 | // LICENSE: This source code is distributed under the terms of the GNU GPL v2 10 | // 11 | // 12 | //===================================================================================================================== 13 | 14 | #ifndef _BRAY_H_ 15 | #define _BRAY_H_ 16 | 17 | namespace BRay 18 | { 19 | typedef unsigned int uint32; 20 | static_assert( sizeof(uint32) == 4, "Your compiler disagrees with our assumptions"); 21 | 22 | namespace _INTERNAL{ 23 | struct Accelerator; 24 | struct Tracer; 25 | }; 26 | 27 | 28 | typedef _INTERNAL::Accelerator* AcceleratorHandle; 29 | typedef _INTERNAL::Tracer* TracerHandle; 30 | 31 | enum 32 | { 33 | MAX_TRACER_SIZE = 4096, 34 | }; 35 | 36 | struct RayHitInfo 37 | { 38 | enum 39 | { 40 | NULL_PRIMID = 0xffffffff 41 | }; 42 | float u; 43 | float v; 44 | uint32 nPrimID; 45 | float t; 46 | }; 47 | 48 | 49 | class Allocator 50 | { 51 | public: 52 | virtual void* Malloc( size_t nBytes, size_t nAlign ) = 0; 53 | virtual void Free( void* pBytes ) = 0; 54 | }; 55 | 56 | 57 | struct Mesh 58 | { 59 | const float* pVertexPositions; 60 | const uint32* pIndices; 61 | uint32 nVertexStride; 62 | uint32 nTriangleStride; 63 | uint32 nTriangles; 64 | }; 65 | 66 | struct RayData 67 | { 68 | float O[3]; float TMax; 69 | float D[3]; float _Pad; 70 | }; 71 | 72 | void Init( Allocator* pAlloc ); 73 | void Shutdown( ); 74 | 75 | AcceleratorHandle CreateAccelerator( const Mesh* pMesh ); 76 | void ReleaseAccelerator( AcceleratorHandle hAccel ); 77 | 78 | TracerHandle CreateTracer( size_t nMaxRays, AcceleratorHandle hAccel ); 79 | void ReleaseTracer( TracerHandle pStream ); 80 | 81 | void ResetTracer( TracerHandle hTracer ); 82 | void AddRay( TracerHandle hTracer, const RayData* pRay ); 83 | void ReadRayOrigin( TracerHandle hTracer,float* pOrigin, size_t nRay ); 84 | void ReadRayDirection( TracerHandle hTracer, float* pDir, size_t nRay ); 85 | void ReadRayData( TracerHandle hTracer, size_t nRay, RayData* pRayOut ); 86 | size_t GetRayCount( TracerHandle hTracer ); 87 | 88 | void Trace( TracerHandle hTracer, BRay::RayHitInfo* pHitsOut ); 89 | void OcclusionTrace( TracerHandle hTracer, unsigned char* pOcclusionOut ); 90 | } 91 | 92 | 93 | #endif -------------------------------------------------------------------------------- /test/embree/common/registry_accel.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ACCEL_REGISTRY_H__ 18 | #define __EMBREE_ACCEL_REGISTRY_H__ 19 | 20 | #include "default.h" 21 | #include "../geometry/triangle.h" 22 | #include "../include/embree.h" 23 | 24 | namespace embree 25 | { 26 | /*! Registry for acceleration structures and triangles */ 27 | class AccelRegistry 28 | { 29 | public: 30 | typedef Accel* (*Constructor)(RTCGeometry* geom, const TriangleType& trity); 31 | 32 | public: 33 | 34 | /*! sets the default acceleration structure */ 35 | void setDefaultAccel(const std::string& accelName); 36 | 37 | /*! sets the default triangle for an acceleration structure */ 38 | void setDefaultTriangle(const std::string& accelName, const std::string& triangleName); 39 | 40 | /*! adds a new acceleration structure to the registry */ 41 | void add(const std::string& accelName, Constructor constructor); 42 | 43 | /*! adds a new acceleration structure to the registry */ 44 | void add(const std::string& triName, const TriangleType& trity); 45 | 46 | /*! constructs an empty acceleration structure */ 47 | Accel* create(std::string accelName, RTCGeometry* geom); 48 | 49 | /*! clears the registry */ 50 | void clear(); 51 | 52 | private: 53 | std::string defaultAccel; 54 | std::map defaultTriangle; 55 | std::map accelTable; 56 | std::map triangleTable; 57 | }; 58 | } 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /test/embree/simd/avx.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_AVX_H__ 18 | #define __EMBREE_AVX_H__ 19 | 20 | #include "simd/sse.h" 21 | 22 | #if defined(__AVX__) 23 | #include 24 | #else 25 | #include "immintrin_emu.h" 26 | #endif 27 | 28 | #if defined (__AVX_I__) 29 | #endif 30 | 31 | #if defined (__AVX2__) 32 | #endif 33 | 34 | namespace embree 35 | { 36 | struct avxb; 37 | struct avxi; 38 | struct avxf; 39 | } 40 | 41 | #include "simd/avxb.h" 42 | #if defined (__AVX_I__) 43 | #include "simd/avxi.h" 44 | #else 45 | #include "simd/avxi_emu.h" 46 | #endif 47 | #include "simd/avxf.h" 48 | 49 | namespace embree 50 | { 51 | typedef avxb avxb_t; 52 | typedef avxi avxi_t; 53 | typedef avxf avxf_t; 54 | 55 | typedef avxb avxb_m; 56 | typedef avxi avxi_m; 57 | typedef avxf avxf_m; 58 | } 59 | 60 | #define BEGIN_ITERATE_AVXB(valid_i,id_o) { \ 61 | int _valid_t = movemask(valid_i); \ 62 | while (_valid_t) { \ 63 | int id_o = __bsf(_valid_t); \ 64 | _valid_t = __btc(_valid_t,id_o); 65 | #define END_ITERATE_AVXB } } 66 | 67 | #define BEGIN_ITERATE_AVXI(valid_i,obj_i,valid_o,obj_o) { \ 68 | int _valid_t = movemask(valid_i); \ 69 | while (_valid_t) { \ 70 | int obj_o = obj_i[__bsf(_valid_t)]; \ 71 | avxb valid_o = valid_i & (obj_i == broadcast(&obj_i[__bsf(_valid_t)])); \ 72 | _valid_t ^= movemask(valid_o); 73 | #define END_ITERATE_AVXI } } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /test/embree/math/permutation.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PERMUTATION_H__ 18 | #define __EMBREE_PERMUTATION_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "random.h" 22 | 23 | #include 24 | 25 | namespace embree 26 | { 27 | /*! Random permutation. */ 28 | class Permutation 29 | { 30 | public: 31 | 32 | /*! Creates a random permutation. Uses system random number generator. */ 33 | Permutation(int size) 34 | { 35 | elts = size; 36 | perm = new int[elts]; 37 | for (int i=0; i()%elts]); 39 | } 40 | 41 | /*! Creates a random permutation. Random number generator is provided as argument. */ 42 | Permutation(int size, Random& rng) 43 | { 44 | elts = size; 45 | perm = new int[elts]; 46 | for (int i=0; i= 0 && i < elts); 63 | return perm[i]; 64 | } 65 | 66 | private: 67 | int elts; //!< Size of the permutation. 68 | int* perm; //!< Array storing the permutation. 69 | }; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /test/embree/sys/sync/atomic.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ATOMIC_H__ 18 | #define __EMBREE_ATOMIC_H__ 19 | 20 | #include "../intrinsics.h" 21 | 22 | namespace embree 23 | { 24 | struct Atomic { 25 | protected: 26 | Atomic( const Atomic& ); // don't implement 27 | Atomic& operator =( const Atomic& ); // don't implement 28 | 29 | public: 30 | __forceinline Atomic( void ) : data(0) {} 31 | __forceinline Atomic( const atomic_t data ) : data(data) {} 32 | __forceinline Atomic& operator =( const atomic_t input ) { data = input; return *this; } 33 | __forceinline operator atomic_t() const { return data; } 34 | 35 | public: 36 | __forceinline atomic_t sub( const atomic_t input ) { return atomic_add(&data,-input) - input; } 37 | __forceinline atomic_t add( const atomic_t input ) { return atomic_add(&data, input) + input; } 38 | __forceinline friend atomic_t operator +=( Atomic& value, const atomic_t input ) { return atomic_add(&value.data, input) + input; } 39 | __forceinline friend atomic_t operator ++( Atomic& value ) { return atomic_add(&value.data, 1) + 1; } 40 | __forceinline friend atomic_t operator --( Atomic& value ) { return atomic_add(&value.data, -1) - 1; } 41 | __forceinline friend atomic_t operator ++( Atomic& value, int ) { return atomic_add(&value.data, 1); } 42 | __forceinline friend atomic_t operator --( Atomic& value, int ) { return atomic_add(&value.data, -1); } 43 | __forceinline friend atomic_t cmpxchg ( Atomic& value, const atomic_t v, const atomic_t c) { return atomic_cmpxchg(&value.data,v,c); } 44 | 45 | private: 46 | volatile atomic_t data; 47 | }; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/embree/bvh4/bvh4_intersector8_hybrid_stream.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4_INTERSECTOR8_HYBRID_STREAM_H__ 18 | #define __EMBREE_BVH4_INTERSECTOR8_HYBRID_STREAM_H__ 19 | 20 | #include "bvh4.h" 21 | #include "../include/intersector_stream.h" 22 | #include "bvh4_intersector8_hybrid.h" 23 | 24 | namespace embree 25 | { 26 | /*! BVH4 Traverser. Packet traversal implementation for a Quad BVH. */ 27 | template 28 | class BVH4Intersector8HybridStream : public IntersectorStream 29 | { 30 | /* shortcuts for frequently used types */ 31 | typedef typename TriangleIntersector8::Triangle Triangle; 32 | typedef typename BVH4::NodeRef NodeRef; 33 | typedef typename BVH4::Node Node; 34 | Intersector8* packetIntersector; 35 | 36 | public: 37 | BVH4Intersector8HybridStream (const BVH4* bvh) 38 | : IntersectorStream((intersectFunc)intersect,(occludedFunc)occluded), bvh(bvh), packetIntersector(BVH4Intersector8Hybrid::create(bvh)) {} 39 | 40 | static IntersectorStream* create(const Accel* bvh) { 41 | return new BVH4Intersector8HybridStream((const BVH4*)bvh); 42 | } 43 | 44 | static void intersect(BVH4Intersector8HybridStream* This, StreamRay* rays, StreamRayExtra* rayExtras, StreamHit* hits, unsigned count, unsigned thread); 45 | static void occluded(BVH4Intersector8HybridStream* This, StreamRay* rays, StreamRayExtra* rayExtras, unsigned count, unsigned char* occluded, unsigned thread); 46 | 47 | ~BVH4Intersector8HybridStream() { 48 | delete packetIntersector; 49 | } 50 | 51 | private: 52 | const BVH4* bvh; 53 | }; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /test/embree/math/random.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RANDOM_H__ 18 | #define __EMBREE_RANDOM_H__ 19 | 20 | #include "math.h" 21 | 22 | namespace embree 23 | { 24 | class Random 25 | { 26 | public: 27 | 28 | __forceinline Random(const int seed = 27) { 29 | setSeed(seed); 30 | } 31 | 32 | __forceinline void setSeed(const int s) 33 | { 34 | const int a = 16807; 35 | const int m = 2147483647; 36 | const int q = 127773; 37 | const int r = 2836; 38 | int j, k; 39 | 40 | if (s == 0) seed = 1; 41 | else if (s < 0) seed = -s; 42 | else seed = s; 43 | 44 | for (j = 32+7; j >= 0; j--) { 45 | k = seed / q; 46 | seed = a*(seed - k*q) - r*k; 47 | if (seed < 0) seed += m; 48 | if (j < 32) table[j] = seed; 49 | } 50 | state = table[0]; 51 | } 52 | 53 | __forceinline int getInt() 54 | { 55 | const int a = 16807; 56 | const int m = 2147483647; 57 | const int q = 127773; 58 | const int r = 2836; 59 | 60 | int k = seed / q; 61 | seed = a*(seed - k*q) - r*k; 62 | if (seed < 0) seed += m; 63 | int j = state / (1 + (2147483647-1) / 32); 64 | state = table[j]; 65 | table[j] = seed; 66 | 67 | return state; 68 | } 69 | 70 | __forceinline int getInt (int limit) { return getInt() % limit; } 71 | __forceinline float getFloat ( ) { return min(getInt() / 2147483647.0f, 1.0f - float(ulp)); } 72 | __forceinline double getDouble( ) { return min(getInt() / 2147483647.0 , 1.0 - double(ulp)); } 73 | 74 | private: 75 | int seed; 76 | int state; 77 | int table[32]; 78 | }; 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /test/embree/builders/splitter.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_SPLITTER_H__ 18 | #define __EMBREE_SPLITTER_H__ 19 | 20 | #include "../geometry/geometry.h" 21 | #include "primrefalloc.h" 22 | #include "primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | /*! Splits a list of build primitives into two lists using a single thread. */ 27 | template 28 | class Splitter 29 | { 30 | typedef typename Heuristic::Split Split; 31 | typedef typename Heuristic::PrimInfo PrimInfo; 32 | 33 | public: 34 | /*! the constructor directly performs the split */ 35 | Splitter (size_t thread, PrimRefAlloc* alloc, const RTCGeometry* geom, 36 | atomic_set& prims, const PrimInfo& pinfo, const Split& psplit); 37 | 38 | /*! perform specified split */ 39 | void split(size_t thread, PrimRefAlloc* alloc, const RTCGeometry* geom, 40 | atomic_set& prims, const PrimInfo& pinfo, const Split& split); 41 | 42 | /*! perform specified spatial split */ 43 | void split_spatial(size_t thread, PrimRefAlloc* alloc, const RTCGeometry* geom, 44 | atomic_set& prims, const PrimInfo& pinfo, const Split& split); 45 | 46 | /* output data */ 47 | public: 48 | atomic_set lprims; //!< left primitive list 49 | atomic_set rprims; //!< right primitive list 50 | PrimInfo linfo; //!< left bounding information of primitives 51 | PrimInfo rinfo; //!< right bounding information of primitives 52 | Split lsplit; //!< best split for left primitives 53 | Split rsplit; //!< best split for right primitives 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /test/embree/common/registry_builder.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BUILDER_REGISTRY_H__ 18 | #define __EMBREE_BUILDER_REGISTRY_H__ 19 | 20 | #include "default.h" 21 | #include "../geometry/triangle.h" 22 | #include "../include/embree.h" 23 | #include "accel.h" 24 | 25 | namespace embree 26 | { 27 | /*! Registry for acceleration structure builders */ 28 | class BuilderRegistry 29 | { 30 | public: 31 | typedef void (*Builder)(TaskScheduler::Event* group, Accel* accel, const size_t maxLeafSize, const size_t forceLeafSize); 32 | 33 | struct BuildClosure 34 | { 35 | BuildClosure () {} 36 | BuildClosure (Builder builder, const size_t minLeafSize, const size_t maxLeafSize) 37 | : builder(builder), minLeafSize(minLeafSize), maxLeafSize(maxLeafSize) {} 38 | 39 | public: 40 | Builder builder; 41 | size_t minLeafSize; 42 | size_t maxLeafSize; 43 | }; 44 | 45 | public: 46 | 47 | /*! sets the default builder for an acceleration structure */ 48 | void setDefaultBuilder(const std::string& accelName, const std::string& builderName); 49 | 50 | /*! adds a new builder to the registry */ 51 | void add(const std::string& accelName, const std::string& triName, const std::string& builderName, 52 | Builder builder, const size_t minLeafSize = 1, const size_t maxLeafSize = inf); 53 | 54 | /*! builds an acceleration structure using the specified builder */ 55 | void build(std::string builderName, TaskScheduler::Event* group, Accel* accel); 56 | 57 | /*! clears the registry */ 58 | void clear(); 59 | 60 | private: 61 | std::map defaultBuilder; 62 | std::map table; 63 | }; 64 | } 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /test/embree/common/stat.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_STAT_H__ 18 | #define __EMBREE_STAT_H__ 19 | 20 | #include "default.h" 21 | 22 | /* Makros to gather statistics */ 23 | #ifdef __USE_STAT_COUNTERS__ 24 | #define STAT(x) x 25 | #define STAT3(s,x,y,z) \ 26 | STAT(Stat::get().code .s+=x); \ 27 | STAT(Stat::get().active.s+=y); \ 28 | STAT(Stat::get().all .s+=z); 29 | #else 30 | #define STAT(x) 31 | #define STAT3(s,x,y,z) 32 | #endif 33 | 34 | namespace embree 35 | { 36 | /*! Gathers ray tracing statistics. */ 37 | class Stat 38 | { 39 | public: 40 | 41 | Stat (); 42 | ~Stat (); 43 | 44 | class Counters 45 | { 46 | public: 47 | Counters () { 48 | clear(); 49 | } 50 | 51 | void clear() { 52 | memset(this,0,sizeof(Counters)); 53 | } 54 | 55 | public: 56 | 57 | union { 58 | 59 | struct { 60 | 61 | /* per packet and per ray stastics */ 62 | struct { 63 | /* normal and shadow ray statistics */ 64 | struct { 65 | size_t travs; 66 | size_t trav_nodes; 67 | size_t trav_leaves; 68 | size_t trav_tris; 69 | } normal, shadow; 70 | } all, active, code; 71 | }; 72 | 73 | size_t data[32]; 74 | }; 75 | }; 76 | 77 | public: 78 | 79 | static __forceinline Counters& get() { 80 | return instance.cntrs; 81 | } 82 | 83 | static void clear() { 84 | instance.cntrs.clear(); 85 | } 86 | 87 | static void print(std::ostream& cout); 88 | 89 | private: 90 | Counters cntrs; 91 | private: 92 | static Stat instance; 93 | }; 94 | } 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /test/embree/common/default.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RTCORE_DEFAULT_H__ 18 | #define __EMBREE_RTCORE_DEFAULT_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "sys/ref.h" 22 | #include "sys/intrinsics.h" 23 | #include "sys/sync/atomic.h" 24 | #include "sys/stl/vector.h" 25 | #include "sys/stl/string.h" 26 | #include "sys/taskscheduler.h" 27 | 28 | #include "math/math.h" 29 | #include "math/vec2.h" 30 | #include "math/vec3.h" 31 | #include "math/vec4.h" 32 | #include "math/bbox.h" 33 | #include "math/affinespace.h" 34 | 35 | #include "simd/simd.h" 36 | 37 | #include "stat.h" 38 | 39 | #include 40 | #include 41 | 42 | namespace embree 43 | { 44 | #if defined (__SSE__) 45 | typedef Vec2 sse2b; 46 | typedef Vec3 sse3b; 47 | typedef Vec2 sse2i; 48 | typedef Vec3 sse3i; 49 | typedef Vec2 sse2f; 50 | typedef Vec3 sse3f; 51 | 52 | typedef Vec3 sse3b_m; 53 | typedef Vec3 sse3i_m; 54 | typedef Vec3 sse3f_m; 55 | #endif 56 | 57 | #if defined (__AVX__) 58 | typedef Vec2 avx2b; 59 | typedef Vec3 avx3b; 60 | typedef Vec2 avx2i; 61 | typedef Vec3 avx3i; 62 | typedef Vec2 avx2f; 63 | typedef Vec3 avx3f; 64 | 65 | typedef Vec2 avx2b_m; 66 | typedef Vec3 avx3b_m; 67 | typedef Vec2 avx2i_m; 68 | typedef Vec3 avx3i_m; 69 | typedef Vec2 avx2f_m; 70 | typedef Vec3 avx3f_m; 71 | #endif 72 | 73 | #if defined(__MIC__) 74 | typedef Vec2 mic2b; 75 | typedef Vec3 mic3b; 76 | typedef Vec2 mic2i; 77 | typedef Vec3 mic3i; 78 | typedef Vec2 mic2f; 79 | typedef Vec3 mic3f; 80 | #endif 81 | 82 | extern int g_verbose; 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /test/embree/builders/heuristics.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_HEURISTICS_H__ 18 | #define __EMBREE_HEURISTICS_H__ 19 | 20 | #include "primref.h" 21 | #include "primrefblock.h" 22 | 23 | #include "heuristic_binning.h" 24 | #include "heuristic_spatial.h" 25 | 26 | #define INSTANTIATE_TEMPLATE_BY_HEURISTIC(Base) \ 27 | template class Base >; \ 28 | template class Base >; \ 29 | template class Base >; \ 30 | template class Base >; \ 31 | template class Base >; \ 32 | template class Base >; 33 | 34 | #define INSTANTIATE_TEMPLATE_BY_BVH_AND_HEURISTIC(Base,BVH) \ 35 | template class Base >; \ 36 | template class Base >; \ 37 | template class Base >; \ 38 | template class Base >; \ 39 | template class Base >; \ 40 | template class Base >; 41 | 42 | #define INSTANTIATE_TEMPLATE_BY_HEURISTIC_AND_PRIMREFLIST(Splitter) \ 43 | template class Splitter, atomic_set >; \ 44 | template class Splitter, atomic_set >; \ 45 | template class Splitter, atomic_set >; \ 46 | template class Splitter, atomic_set >; \ 47 | template class Splitter, atomic_set >; \ 48 | template class Splitter, atomic_set >; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/EmbreeHooks.cpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _NO_EMBREE 3 | 4 | #include "BRay.h" 5 | #include "Simpleton.h" 6 | #include "embree.h" 7 | #include "embree/common/stream_ray.h" 8 | typedef unsigned int uint; 9 | 10 | #include 11 | 12 | static embree::IntersectorStream* m_pIntersector=0; 13 | static LARGE_INTEGER m_Timer; 14 | 15 | void CreateEmbreeScene( uint nTris, uint nVerts, float* pVerts, uint* pIndices ) 16 | { 17 | embree::rtcInit(); 18 | embree::RTCGeometry* pMesh = embree::rtcNewTriangleMesh( nTris, nVerts, "bvh4.triangle8" ); 19 | embree::RTCVertex* pVB = embree::rtcMapPositionBuffer( pMesh ); 20 | embree::RTCTriangle* pIB = embree::rtcMapTriangleBuffer( pMesh ); 21 | 22 | for( uint i=0; iintersect( rays, extras, hits, nRays, 0 ); 71 | 72 | QueryPerformanceCounter(&tm1); 73 | m_Timer.QuadPart += (tm1.QuadPart-tm.QuadPart); 74 | 75 | for( uint i=0; i= blockSize)) return false; 54 | ptr[num++] = ref; 55 | return true; 56 | } 57 | 58 | /*! access the i-th primitive reference */ 59 | __forceinline PrimRef& operator[] (size_t i) { return ptr[i]; } 60 | __forceinline const PrimRef& operator[] (size_t i) const { return ptr[i]; } 61 | 62 | /*! access the i-th primitive reference */ 63 | __forceinline PrimRef& at (size_t i) { return ptr[i]; } 64 | __forceinline const PrimRef& at (size_t i) const { return ptr[i]; } 65 | 66 | private: 67 | PrimRef ptr[blockSize]; //!< Block with primitive references 68 | size_t num; //!< Number of primitive references in block 69 | char align[sizeof(PrimRef)-sizeof(size_t)]; 70 | }; 71 | } 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /test/embree/builders/bvh_sort.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH_SORT_TEMPLATED_H__ 18 | #define __EMBREE_BVH_SORT_TEMPLATED_H__ 19 | 20 | #include "../common/default.h" 21 | #include "../geometry/geometry.h" 22 | 23 | namespace embree 24 | { 25 | /* BVH child sorting by occlusion. */ 26 | template 27 | class BVHSortT 28 | { 29 | public: 30 | typedef typename BVH::Node Node; 31 | typedef typename BVH::NodeRef NodeRef; 32 | 33 | static float sort(RTCGeometry* geom, BVH* bvh, NodeRef node) 34 | { 35 | /*! return if we found depth barrier */ 36 | if (node.isBarrier()) 37 | return 0; 38 | 39 | /*! sum up triangle areas */ 40 | else if (node.isLeaf()) 41 | { 42 | float A = 0.0f; 43 | size_t num; const char* tri = node.leaf(bvh->triPtr(),num); 44 | for (size_t i=0; itrity.area(tri+i*bvh->trity.bytes,geom); 46 | return A; 47 | } 48 | 49 | /*! sort node children based on approximated opacity */ 50 | else 51 | { 52 | /*! calculate half of node surface area */ 53 | Node* n = node.node(bvh->nodePtr()); 54 | 55 | /*! recurse into children first */ 56 | float A = 0.0f; 57 | float opacity[BVH::N]; 58 | for (size_t c=0; cchild(c)); 60 | opacity[c] = dA*rcp(halfArea(n->bounds(c))); 61 | A += dA; 62 | } 63 | 64 | /*! sort children by opacity */ 65 | for (size_t i=BVH::N-1; i>0; i--) { 66 | for (size_t j=0; j opacity[j+1]) { 68 | std::swap(opacity[j+0],opacity[j+1]); 69 | BVH::swap(n,j+0,n,j+1); 70 | } 71 | } 72 | } 73 | return A; 74 | } 75 | } 76 | }; 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /test/embree/common/ray4.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RAY4_H__ 18 | #define __EMBREE_RAY4_H__ 19 | 20 | #include "ray.h" 21 | 22 | namespace embree 23 | { 24 | /*! Ray structure. Contains all information of 4 rays including 25 | * precomputed reciprocal direction. */ 26 | struct Ray4 27 | { 28 | /*! Default construction does nothing. */ 29 | __forceinline Ray4() {} 30 | 31 | /*! Constructs a ray from origin, direction, and ray segment. Near 32 | * has to be smaller than far. */ 33 | __forceinline Ray4(const sse3f& org, const sse3f& dir, const ssef& tnear = zero, const ssef& tfar = inf, const ssef& time = zero, const ssei& mask = -1) 34 | : org(org), dir(dir), tnear(tnear), tfar(tfar), id0(-1), id1(-1), mask(mask), time(time) {} 35 | 36 | /*! Tests if we hit something. */ 37 | __forceinline operator sseb() const { return id0 != ssei(-1); } 38 | 39 | public: 40 | sse3f org; //!< Ray origin 41 | sse3f dir; //!< Ray direction 42 | ssef tnear; //!< Start of ray segment 43 | ssef tfar; //!< End of ray segment 44 | ssef u; //!< Barycentric u coordinate of hit 45 | ssef v; //!< Barycentric v coordinate of hit 46 | ssei id0; //!< 1st primitive ID 47 | ssei id1; //!< 2nd primitive ID 48 | sse3f Ng; //!< Geometry normal 49 | ssei mask; //!< used to mask out objects during traversal 50 | ssef time; //!< Time of this ray for motion blur. 51 | }; 52 | 53 | /*! Outputs ray to stream. */ 54 | inline std::ostream& operator<<(std::ostream& cout, const Ray4& ray) { 55 | return cout << "{ " << 56 | "org = " << ray.org << ", dir = " << ray.dir << ", near = " << ray.tnear << ", far = " << ray.tfar << ", time = " << ray.time << ", " << 57 | "id0 = " << ray.id0 << ", id1 = " << ray.id1 << ", " << "u = " << ray.u << ", v = " << ray.v << ", Ng = " << ray.Ng << " }"; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /test/embree/common/ray8.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RAY8_H__ 18 | #define __EMBREE_RAY8_H__ 19 | 20 | #include "ray.h" 21 | 22 | namespace embree 23 | { 24 | /*! Ray structure. Contains all information of 8 rays including 25 | * precomputed reciprocal direction. */ 26 | struct Ray8 27 | { 28 | /*! Default construction does nothing. */ 29 | __forceinline Ray8() {} 30 | 31 | /*! Constructs a ray from origin, direction, and ray segment. Near 32 | * has to be smaller than far. */ 33 | __forceinline Ray8(const avx3f& org, const avx3f& dir, const avxf& tnear = zero, const avxf& tfar = inf, const avxf& time = zero, const avxi& mask = -1) 34 | : org(org), dir(dir), tnear(tnear), tfar(tfar), id0(-1), id1(-1), mask(mask), time(time) {} 35 | 36 | /*! Tests if we hit something. */ 37 | __forceinline operator avxb() const { return id0 != avxi(-1); } 38 | 39 | public: 40 | avx3f org; //!< Ray origin 41 | avx3f dir; //!< Ray direction 42 | avxf tnear; //!< Start of ray segment 43 | avxf tfar; //!< End of ray segment 44 | avxf u; //!< Barycentric u coordinate of hit 45 | avxf v; //!< Barycentric v coordinate of hit 46 | avxi id0; //!< 1st primitive ID 47 | avxi id1; //!< 2nd primitive ID 48 | avx3f Ng; //!< Geometry normal 49 | avxi mask; //!< used to mask out objects during traversal 50 | avxf time; //!< Time of this ray for motion blur. 51 | }; 52 | 53 | /*! Outputs ray to stream. */ 54 | inline std::ostream& operator<<(std::ostream& cout, const Ray8& ray) { 55 | return cout << "{ " << 56 | "org = " << ray.org << ", dir = " << ray.dir << ", near = " << ray.tnear << ", far = " << ray.tfar << ", time = " << ray.time << ", " << 57 | "id0 = " << ray.id0 << ", id1 = " << ray.id1 << ", " << "u = " << ray.u << ", v = " << ray.v << ", Ng = " << ray.Ng << " }"; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /test/embree/common/ray16.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RAY16_H__ 18 | #define __EMBREE_RAY16_H__ 19 | 20 | #include "ray.h" 21 | 22 | namespace embree 23 | { 24 | /*! Ray structure. Contains all information of 16 rays including 25 | * precomputed reciprocal direction. */ 26 | struct Ray16 27 | { 28 | /*! Default construction does nothing. */ 29 | __forceinline Ray16() {} 30 | 31 | /*! Constructs a ray from origin, direction, and ray segment. Near 32 | * has to be smaller than far. */ 33 | __forceinline Ray16(const mic3f& org, const mic3f& dir, const mic_f& tnear = zero, const mic_f& tfar = inf, const mic_f& time = zero, const mic_i& mask = -1) 34 | : org(org), dir(dir), tnear(tnear), tfar(tfar), id0(-1), id1(-1), mask(mask), time(time) {} 35 | 36 | /*! Tests if we hit something. */ 37 | __forceinline operator mic_m() const { return id0 != mic_i(-1); } 38 | 39 | public: 40 | mic3f org; //!< Ray origin 41 | mic3f dir; //!< Ray direction 42 | mic_f tnear; //!< Start of ray segment 43 | mic_f tfar; //!< End of ray segment 44 | mic_f u; //!< Barycentric u coordinate of hit 45 | mic_f v; //!< Barycentric v coordinate of hit 46 | mic_i id0; //!< 1st primitive ID 47 | mic_i id1; //!< 2nd primitive ID 48 | mic3f Ng; //!< Geometry normal 49 | mic_i mask; //!< used to mask out objects during traversal 50 | mic_f time; //!< Time of this ray for motion blur. 51 | }; 52 | 53 | /*! Outputs ray to stream. */ 54 | inline std::ostream& operator<<(std::ostream& cout, const Ray16& ray) { 55 | return cout << "{ " << 56 | "org = " << ray.org << ", dir = " << ray.dir << ", near = " << ray.tnear << ", far = " << ray.tfar << ", time = " << ray.time << ", " << 57 | "id0 = " << ray.id0 << ", id1 = " << ray.id1 << ", " << "u = " << ray.u << ", v = " << ray.v << ", Ng = " << ray.Ng << " }"; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /test/embree/simd/mic_i.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "mic.h" 18 | 19 | namespace embree 20 | { 21 | MIC_ALIGN int mic_i::int_identity[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }; 22 | MIC_ALIGN int mic_i::int_idMod4[16] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3}; 23 | MIC_ALIGN int mic_i::int_idDiv4[16] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3}; 24 | MIC_ALIGN int mic_i::int_pow4[16] = {1,4,16,64,256,1024,4096,16384,65536,262144,1048576,4194304,16777216,67108864,268435456,1073741824}; 25 | MIC_ALIGN int mic_i::int_zlc4[4] = {0xffffffff,0xffffffff,0xffffffff,0}; 26 | MIC_ALIGN int mic_i::int_addtriID4[16] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3}; 27 | MIC_ALIGN unsigned int mic_i::uint_shift1[32] = { 28 | ((unsigned int)1 << 0), 29 | ((unsigned int)1 << 1), 30 | ((unsigned int)1 << 2), 31 | ((unsigned int)1 << 3), 32 | ((unsigned int)1 << 4), 33 | ((unsigned int)1 << 5), 34 | ((unsigned int)1 << 6), 35 | ((unsigned int)1 << 7), 36 | ((unsigned int)1 << 8), 37 | ((unsigned int)1 << 9), 38 | ((unsigned int)1 << 10), 39 | ((unsigned int)1 << 11), 40 | ((unsigned int)1 << 12), 41 | ((unsigned int)1 << 13), 42 | ((unsigned int)1 << 14), 43 | ((unsigned int)1 << 15), 44 | ((unsigned int)1 << 16), 45 | ((unsigned int)1 << 17), 46 | ((unsigned int)1 << 18), 47 | ((unsigned int)1 << 19), 48 | ((unsigned int)1 << 20), 49 | ((unsigned int)1 << 21), 50 | ((unsigned int)1 << 22), 51 | ((unsigned int)1 << 23), 52 | ((unsigned int)1 << 24), 53 | ((unsigned int)1 << 25), 54 | ((unsigned int)1 << 26), 55 | ((unsigned int)1 << 27), 56 | ((unsigned int)1 << 28), 57 | ((unsigned int)1 << 29), 58 | ((unsigned int)1 << 30), 59 | ((unsigned int)1 << 31) 60 | }; 61 | 62 | MIC_ALIGN int mic_i::int_aos2soa[16] = { 63 | 0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15 64 | }; 65 | 66 | MIC_ALIGN int mic_i::int_reverse_identity[16] = { 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }; 67 | } 68 | -------------------------------------------------------------------------------- /test/embree/common/ray.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_RAY_H__ 18 | #define __EMBREE_RAY_H__ 19 | 20 | #include "../common/default.h" 21 | 22 | namespace embree 23 | { 24 | /*! Ray structure. Contains all information about a ray including 25 | * precomputed reciprocal direction. */ 26 | struct Ray 27 | { 28 | /*! Default construction does nothing. */ 29 | __forceinline Ray() {} 30 | 31 | /*! Constructs a ray from origin, direction, and ray segment. Near 32 | * has to be smaller than far. */ 33 | __forceinline Ray(const Vector3f& org, const Vector3f& dir, float tnear = zero, float tfar = inf, float time = zero, int mask = -1) 34 | : org(org), dir(dir), tnear(tnear), tfar(tfar), id0(-1), id1(-1), mask(mask), time(time) {} 35 | 36 | /*! Tests if we hit something. */ 37 | __forceinline operator bool() const { return id0 != -1; } 38 | 39 | public: 40 | Vec3fa org; //!< Ray origin 41 | Vec3fa dir; //!< Ray direction 42 | float tnear; //!< Start of ray segment 43 | float tfar; //!< End of ray segment 44 | float u; //!< Barycentric u coordinate of hit 45 | float v; //!< Barycentric v coordinate of hit 46 | int id0; //!< 1st primitive ID 47 | int id1; //!< 2nd primitive ID 48 | Vec3fa Ng; //!< Not normalized geometry normal 49 | int mask; //!< used to mask out objects during traversal 50 | float time; //!< Time of this ray for motion blur. 51 | }; 52 | 53 | /*! Outputs ray to stream. */ 54 | inline std::ostream& operator<<(std::ostream& cout, const Ray& ray) { 55 | return cout << "{ " << 56 | "org = " << ray.org << ", dir = " << ray.dir << ", near = " << ray.tnear << ", far = " << ray.tfar << ", time = " << ray.time << ", " << 57 | "id0 = " << ray.id0 << ", id1 = " << ray.id1 << ", " << "u = " << ray.u << ", v = " << ray.v << ", Ng = " << ray.Ng << " }"; 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /test/embree/common/registry_builder.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "registry_builder.h" 18 | 19 | namespace embree 20 | { 21 | void BuilderRegistry::setDefaultBuilder(const std::string& accelName, const std::string& builderName) { 22 | defaultBuilder[accelName] = builderName; 23 | } 24 | 25 | void BuilderRegistry::add(const std::string& accelName, const std::string& triName, const std::string& builderName, 26 | Builder builder, const size_t minLeafSize, const size_t maxLeafSize) 27 | { 28 | table[accelName+"."+triName+"."+builderName] = BuildClosure(builder,minLeafSize,maxLeafSize); 29 | } 30 | 31 | void BuilderRegistry::build(std::string builderName, TaskScheduler::Event* group, Accel* accel) 32 | { 33 | std::string accelType = accel->name(); 34 | 35 | /*! split accelName into accel and triangle */ 36 | std::string accelName = accelType; 37 | std::string triangleName = "default"; 38 | size_t pos = accelName.find_first_of('.'); 39 | if (pos != std::string::npos) { 40 | triangleName = accelName.substr(pos+1); 41 | accelName.resize(pos); 42 | } 43 | 44 | /*! select default builder */ 45 | if (builderName == "default") { 46 | builderName = defaultBuilder[accelName]; 47 | if (builderName == "") throw std::runtime_error("Acceleration structure \""+accelName+"\" has no default builder."); 48 | } 49 | 50 | /*! find specified builder */ 51 | std::string key = accelType + "." + builderName; 52 | if (table.find(key) == table.end()) 53 | throw std::runtime_error("Acceleration structure \""+accel->name()+"\" has no builder \""+builderName+"\"."); 54 | 55 | /*! build acceleration structure */ 56 | const BuildClosure& closure = table[key]; 57 | closure.builder(group,accel,closure.minLeafSize,closure.maxLeafSize); 58 | } 59 | 60 | void BuilderRegistry::clear() 61 | { 62 | defaultBuilder.clear(); 63 | table.clear(); 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /test/embree/bvh4aos/builder/bvh4aos_builder.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_BVH4AOS_BUILDER_H__ 18 | #define __EMBREE_BVH4AOS_BUILDER_H__ 19 | 20 | #include "bvh4aos/bvh4aos.h" 21 | #include "sys/sync/barrier.h" 22 | #include "geometry/triangle.h" 23 | #include "geometry/triangle_mesh.h" 24 | 25 | namespace embree 26 | { 27 | /* BVH4AOS builder. The builder is multi-threaded and implements 3 28 | * different build strategies: 1) Small tasks are finished in a 29 | * single thread (BuildTask) 2) Medium sized tasks are split into 30 | * two tasks using a single thread (SplitTask) and 3) Large tasks are 31 | * split using multiple threads on one processor. */ 32 | 33 | class BVH4AOSBuilder : public RefCount 34 | { 35 | public: 36 | 37 | /*! Type of BVH built */ 38 | typedef BVH4AOS Type; 39 | 40 | public: 41 | 42 | /*! creates the acceleration structure */ 43 | static void create (TaskScheduler::Event* event, Accel* accel, const size_t minLeafSize = 1, const size_t maxLeafSize = inf) { 44 | new BVH4AOSBuilder(event,(BVH4AOS*)accel,minLeafSize,maxLeafSize,true); 45 | } 46 | 47 | static void create_fast(TaskScheduler::Event* event, Accel* accel, const size_t minLeafSize = 1, const size_t maxLeafSize = inf) { 48 | new BVH4AOSBuilder(event,(BVH4AOS*)accel,minLeafSize,maxLeafSize,false); 49 | } 50 | 51 | /*! Constructor. */ 52 | BVH4AOSBuilder(TaskScheduler::Event* event, BVH4AOS* bvh, const size_t minLeafSize = 1, const size_t maxLeafSize = inf, 53 | const bool highQuality = true); 54 | 55 | private: 56 | 57 | static unsigned int buildMode; 58 | 59 | /*! run function for BVH4AOSBuilder worker threads */ 60 | TASK_RUN_FUNCTION(BVH4AOSBuilder,task_build_parallel); 61 | 62 | /*! finishes the build */ 63 | TASK_COMPLETE_FUNCTION(BVH4AOSBuilder,finish); 64 | 65 | public: 66 | TaskScheduler::Task task; 67 | TriangleMesh* mesh; 68 | BVH4AOS* bvh; //!< Output BVH 69 | }; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /test/embree/builders/primrefgen.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_PRIMREFGENBIN_H__ 18 | #define __EMBREE_PRIMREFGENBIN_H__ 19 | 20 | #include "../geometry/geometry.h" 21 | #include "primrefalloc.h" 22 | #include "primrefblock.h" 23 | 24 | namespace embree 25 | { 26 | /*! Generates a list of build primitives from a list of triangles. */ 27 | template 28 | class PrimRefGen 29 | { 30 | static const size_t numTasks = 40; 31 | typedef typename Heuristic::Split Split; 32 | typedef typename Heuristic::PrimInfo PrimInfo; 33 | 34 | public: 35 | __forceinline PrimRefGen () {} 36 | 37 | /*! standard constructor that schedules the task */ 38 | PrimRefGen (TaskScheduler::Event* group, const RTCGeometry* geom, PrimRefAlloc* alloc); 39 | 40 | /*! destruction */ 41 | ~PrimRefGen(); 42 | 43 | public: 44 | 45 | /*! parallel task to iterate over the triangles */ 46 | TASK_RUN_FUNCTION(PrimRefGen,task_gen_parallel); 47 | 48 | /*! reduces the bounding information gathered in parallel */ 49 | TASK_COMPLETE_FUNCTION(PrimRefGen,task_gen_parallel_reduce); 50 | 51 | /* input data */ 52 | private: 53 | const RTCGeometry* geom; //!< input geometry 54 | size_t numTriangles; //!< number of primitives 55 | PrimRefAlloc* alloc; //!< allocator for build primitive blocks 56 | 57 | /* intermediate data */ 58 | private: 59 | TaskScheduler::Task task; 60 | BBox3f geomBounds[numTasks]; //!< Geometry bounds per thread 61 | BBox3f centBounds[numTasks]; //!< Centroid bounds per thread 62 | Heuristic heuristics[numTasks]; //!< Heuristics per thread 63 | 64 | /* output data */ 65 | public: 66 | PrimRefBlockList prims; //!< list of build primitives 67 | PrimInfo pinfo; //!< bounding information of primitives 68 | Split split; //!< best possible split 69 | }; 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /test/embree/geometry/triangles.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ACCEL_TRIANGLES_H__ 18 | #define __EMBREE_ACCEL_TRIANGLES_H__ 19 | 20 | /*! include all triangles */ 21 | #include "virtual_object.h" 22 | 23 | #include "triangle1i.h" 24 | #include "triangle1v.h" 25 | #include "triangle1.h" 26 | 27 | #if defined (__SSE__) 28 | #include "triangle4i.h" 29 | #include "triangle4v.h" 30 | #include "triangle4.h" 31 | #endif 32 | 33 | #if defined (__AVX__) 34 | #include "triangle8.h" 35 | #endif 36 | 37 | /*! include single ray triangle intersectors */ 38 | #include "virtual_object_intersector1.h" 39 | 40 | #if defined (__SSE__) 41 | #include "intersector1_moeller.h" 42 | #include "intersector1_pluecker.h" 43 | #include "triangle1_intersector1_moeller.h" 44 | #include "triangle1_intersector1_moeller_stream.h" 45 | #include "triangle4_intersector1_moeller.h" 46 | #include "triangle4_intersector1_moeller_stream.h" 47 | #endif 48 | 49 | #if defined (__AVX__) 50 | #include "triangle8_intersector1_moeller.h" 51 | #include "triangle8_intersector1_moeller_stream.h" 52 | #endif 53 | 54 | #if defined(__MIC__) 55 | #include "../geometry/triangle1_intersector1_moeller_mic.h" 56 | #endif 57 | 58 | /* include all 4 ray packet triangle intersectors */ 59 | #if defined(__SSE__) 60 | #include "virtual_object_intersector4.h" 61 | #include "intersector4_moeller.h" 62 | #include "intersector4_pluecker.h" 63 | #include "triangle1_intersector4_moeller.h" 64 | #include "triangle4_intersector4_moeller.h" 65 | #endif 66 | 67 | /* include all 8 ray packet triangle intersectors */ 68 | #if defined(__AVX__) 69 | #include "virtual_object_intersector8.h" 70 | #include "intersector8_moeller.h" 71 | #include "intersector8_pluecker.h" 72 | #include "triangle1_intersector8_moeller.h" 73 | #include "triangle4_intersector8_moeller.h" 74 | #endif 75 | 76 | /* include all 16 ray packet triangle intersectors */ 77 | #if defined(__MIC__) 78 | #include "virtual_object_intersector16.h" 79 | #include "../geometry/triangle1_intersector16_moeller_mic.h" 80 | #endif 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /test/embree/include/intersector1.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_INTERSECTOR1_H__ 18 | #define __EMBREE_INTERSECTOR1_H__ 19 | 20 | #include 21 | 22 | namespace embree 23 | { 24 | class Accel; 25 | struct Ray; 26 | 27 | /*! Single ray interface to the traverser. A closest intersection 28 | * point of a ray with the geometry can be found. A ray can also be 29 | * tested for occlusion by any geometry. */ 30 | class Intersector1 { 31 | public: 32 | 33 | /*! name for this interface */ 34 | static const char* const name; 35 | 36 | /*! Intersect function pointer type. */ 37 | typedef void (*intersectFunc)(const Intersector1* This, /*!< pointer to this intersector */ 38 | Ray& ray /*!< Ray to shoot. */); 39 | 40 | /*! Occluded function pointer type. */ 41 | typedef bool (*occludedFunc) (const Intersector1* This, /*!< pointer to this intersector */ 42 | Ray& ray /*!< Ray to test occlusion for. */); 43 | 44 | public: 45 | 46 | /*! Default constructor. */ 47 | __forceinline Intersector1 () 48 | : intersectPtr(NULL), occludedPtr(NULL) {} 49 | 50 | /*! Constructs the intersector from two function pointers. */ 51 | __forceinline Intersector1 (intersectFunc intersect, occludedFunc occluded) 52 | : intersectPtr(intersect), occludedPtr(occluded) {} 53 | 54 | /*! Intersects the ray with the geometry and returns the hit 55 | * information. */ 56 | __forceinline void intersect(Ray& ray) const { 57 | intersectPtr(this,ray); 58 | } 59 | 60 | /*! Tests the ray for occlusion with the scene. */ 61 | __forceinline bool occluded (Ray& ray) const { 62 | return occludedPtr(this,ray); 63 | } 64 | 65 | public: 66 | intersectFunc intersectPtr; /*!< Pointer to intersect function */ 67 | occludedFunc occludedPtr; /*!< Pointer to occluded function */ 68 | }; 69 | 70 | typedef Intersector1 RTCIntersector1; 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /test/embree/math/col3.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_COL3_H__ 18 | #define __EMBREE_COL3_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "math/math.h" 22 | 23 | namespace embree 24 | { 25 | //////////////////////////////////////////////////////////////////////////////// 26 | /// RGB Color Class 27 | //////////////////////////////////////////////////////////////////////////////// 28 | 29 | template struct Col3 30 | { 31 | T r, g, b; 32 | 33 | //////////////////////////////////////////////////////////////////////////////// 34 | /// Construction 35 | //////////////////////////////////////////////////////////////////////////////// 36 | 37 | __forceinline Col3 ( ) { } 38 | __forceinline Col3 ( const Col3& other ) { r = other.r; g = other.g; b = other.b; } 39 | __forceinline Col3& operator=( const Col3& other ) { r = other.r; g = other.g; b = other.b; return *this; } 40 | 41 | __forceinline explicit Col3 (const T& v) : r(v), g(v), b(v) {} 42 | __forceinline Col3 (const T& r, const T& g, const T& b) : r(r), g(g), b(b) {} 43 | 44 | //////////////////////////////////////////////////////////////////////////////// 45 | /// Constants 46 | //////////////////////////////////////////////////////////////////////////////// 47 | 48 | __forceinline Col3 (ZeroTy) : r(zero) , g(zero) , b(zero) {} 49 | __forceinline Col3 (OneTy) : r(one) , g(one) , b(one) {} 50 | __forceinline Col3 (PosInfTy) : r(pos_inf), g(pos_inf), b(pos_inf) {} 51 | __forceinline Col3 (NegInfTy) : r(neg_inf), g(neg_inf), b(neg_inf) {} 52 | }; 53 | 54 | /*! output operator */ 55 | template inline std::ostream& operator<<(std::ostream& cout, const Col3& a) { 56 | return cout << "(" << a.r << ", " << a.g << ", " << a.b << ")"; 57 | } 58 | 59 | /*! default template instantiations */ 60 | typedef Col3 Col3c; 61 | typedef Col3 Col3f; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /test/embree/geometry/triangle.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_ACCEL_TRIANGLE_H__ 18 | #define __EMBREE_ACCEL_TRIANGLE_H__ 19 | 20 | #include "../common/default.h" 21 | #include "../include/embree.h" 22 | 23 | #include "../common/ray.h" 24 | 25 | #if defined(__SSE__) 26 | #include "../common/ray4.h" 27 | #endif 28 | 29 | #if defined(__AVX__) 30 | #include "../common/ray8.h" 31 | #endif 32 | 33 | #if defined(__MIC__) 34 | #include "../common/ray16.h" 35 | #endif 36 | 37 | #include "../builders/primrefblock.h" 38 | 39 | namespace embree 40 | { 41 | struct RTCGeometry; 42 | 43 | struct TriangleType 44 | { 45 | /*! constructs the triangle type */ 46 | TriangleType (const char* name, size_t bytes, size_t blockSize, bool needVertices, int intCost) 47 | : name(name), bytes(bytes), blockSize(blockSize), needVertices(needVertices), intCost(intCost) {} 48 | 49 | /*! Computes the number of blocks required to store a number of triangles. */ 50 | virtual size_t blocks(size_t x) const = 0; 51 | 52 | /*! Returns the number of stored triangles. */ 53 | virtual size_t size(const char* This) const = 0; 54 | 55 | /*! Computes the area of the triangle. */ 56 | virtual float area(const char* This, const RTCGeometry* geom) const = 0; 57 | 58 | /*! Packs triangle taken from primitive list. */ 59 | virtual void pack(char* This, atomic_set::block_iterator_unsafe& prims, const RTCGeometry* geom) const = 0; 60 | 61 | /*! Computes the bounds of timestep t0 and t1 of a moving triangle. */ 62 | virtual std::pair bounds(char* This, const RTCGeometry* geom) const { return std::pair(empty,empty); } 63 | 64 | std::string name; //!< name of this triangle type 65 | size_t bytes; //!< number of bytes of the triangle data 66 | size_t blockSize; //!< block size 67 | bool needVertices; //!< determines if we need the vertex array 68 | int intCost; //!< cost of one ray/triangle intersection 69 | }; 70 | } 71 | 72 | #endif 73 | 74 | 75 | -------------------------------------------------------------------------------- /test/embree/include/intersector_stream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Intel Corporation 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are met: 5 | * 6 | * - Redistributions of source code must retain the above copyright notice, 7 | * this list of conditions and the following disclaimer. 8 | * - Redistributions in binary form must reproduce the above copyright notice, 9 | * this list of conditions and the following disclaimer in the documentation 10 | * and/or other materials provided with the distribution. 11 | * - Neither the name of Intel Corporation nor the names of its contributors 12 | * may be used to endorse or promote products derived from this software 13 | * without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | #ifndef __EMBREE_INTERSECTOR_STREAM_H__ 30 | #define __EMBREE_INTERSECTOR_STREAM_H__ 31 | 32 | #include 33 | #include 34 | 35 | namespace embree { 36 | 37 | class Accel; 38 | struct Ray; 39 | struct StreamRay; 40 | struct StreamRayExtra; 41 | struct StreamHit; 42 | 43 | class IntersectorStream { 44 | public: 45 | static const char* const name; 46 | 47 | typedef void (*intersectFunc)(const IntersectorStream* This, StreamRay* rays, StreamRayExtra* rayExtras, StreamHit* hits, unsigned count, unsigned thread); 48 | typedef void (*occludedFunc)(const IntersectorStream* This, StreamRay* rays, StreamRayExtra* rayExtras, unsigned count, unsigned char* occluded, unsigned thread); 49 | 50 | public: 51 | __forceinline IntersectorStream() : intersectPtr(0), occludedPtr(0) {} 52 | 53 | __forceinline IntersectorStream(intersectFunc intersect, occludedFunc occluded) : intersectPtr(intersect), occludedPtr(occluded) {} 54 | 55 | __forceinline void intersect(StreamRay* rays, StreamRayExtra* rayExtras, StreamHit* hits, unsigned count, unsigned thread) const { 56 | return intersectPtr(this, rays, rayExtras, hits, count, thread); 57 | } 58 | 59 | __forceinline void occluded(StreamRay* rays, StreamRayExtra* rayExtras, unsigned count, unsigned char* occluded, unsigned thread) const { 60 | occludedPtr(this, rays, rayExtras, count, occluded, thread); 61 | } 62 | 63 | public: 64 | intersectFunc intersectPtr; 65 | occludedFunc occludedPtr; 66 | }; 67 | 68 | typedef IntersectorStream RTCIntersectorStream; 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /test/embree/sys/filename.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_FILENAME_H__ 18 | #define __EMBREE_FILENAME_H__ 19 | 20 | #include "platform.h" 21 | 22 | namespace embree 23 | { 24 | /*! Convenience class for handling file names and paths. */ 25 | class FileName 26 | { 27 | public: 28 | 29 | /*! create an empty filename */ 30 | FileName (); 31 | 32 | /*! create a valid filename from a string */ 33 | FileName (const char* filename); 34 | 35 | /*! create a valid filename from a string */ 36 | FileName (const std::string& filename); 37 | 38 | /*! auto convert into a string */ 39 | operator std::string() const { return filename; } 40 | 41 | /*! returns a string of the filename */ 42 | const std::string str() const { return filename; } 43 | 44 | /*! returns a c-string of the filename */ 45 | const char* c_str() const { return filename.c_str(); } 46 | 47 | /*! returns the path of a filename */ 48 | FileName path() const; 49 | 50 | /*! returns the file of a filename */ 51 | std::string base() const; 52 | 53 | /*! returns the base of a filename without extension */ 54 | std::string name() const; 55 | 56 | /*! returns the file extension */ 57 | std::string ext() const; 58 | 59 | /*! drops the file extension */ 60 | FileName dropExt() const; 61 | 62 | /*! replaces the file extension */ 63 | FileName setExt(const std::string& ext = "") const; 64 | 65 | /*! adds file extension */ 66 | FileName addExt(const std::string& ext = "") const; 67 | 68 | /*! concatenates two filenames to this/other */ 69 | FileName operator +( const FileName& other ) const; 70 | 71 | /*! concatenates two filenames to this/other */ 72 | FileName operator +( const std::string& other ) const; 73 | 74 | /*! removes the base from a filename (if possible) */ 75 | FileName operator -( const FileName& base ) const; 76 | 77 | /*! output operator */ 78 | friend std::ostream& operator<<(std::ostream& cout, const FileName& filename); 79 | 80 | private: 81 | std::string filename; 82 | }; 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /test/embree/math/col4.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #ifndef __EMBREE_COL4_H__ 18 | #define __EMBREE_COL4_H__ 19 | 20 | #include "sys/platform.h" 21 | #include "math/math.h" 22 | 23 | namespace embree 24 | { 25 | //////////////////////////////////////////////////////////////////////////////// 26 | /// RGBA Color Class 27 | //////////////////////////////////////////////////////////////////////////////// 28 | 29 | template struct Col4 30 | { 31 | T r, g, b, a; 32 | 33 | //////////////////////////////////////////////////////////////////////////////// 34 | /// Construction 35 | //////////////////////////////////////////////////////////////////////////////// 36 | 37 | __forceinline Col4 ( ) { } 38 | __forceinline Col4 ( const Col4& other ) { r = other.r; g = other.g; b = other.b; a = other.a; } 39 | __forceinline Col4& operator=( const Col4& other ) { r = other.r; g = other.g; b = other.b; a = other.a; return *this; } 40 | 41 | __forceinline explicit Col4 (const T& v) : r(v), g(v), b(v), a(v) {} 42 | __forceinline Col4 (const T& r, const T& g, const T& b, const T& a) : r(r), g(g), b(b), a(a) {} 43 | 44 | //////////////////////////////////////////////////////////////////////////////// 45 | /// Constants 46 | //////////////////////////////////////////////////////////////////////////////// 47 | 48 | __forceinline Col4 (ZeroTy) : r(zero) , g(zero) , b(zero) , a(zero) {} 49 | __forceinline Col4 (OneTy) : r(one) , g(one) , b(one) , a(one) {} 50 | __forceinline Col4 (PosInfTy) : r(pos_inf), g(pos_inf), b(pos_inf), a(pos_inf) {} 51 | __forceinline Col4 (NegInfTy) : r(neg_inf), g(neg_inf), b(neg_inf), a(neg_inf) {} 52 | }; 53 | 54 | /*! output operator */ 55 | template inline std::ostream& operator<<(std::ostream& cout, const Col4& a) { 56 | return cout << "(" << a.r << ", " << a.g << ", " << a.b << ", " << a.a << ")"; 57 | } 58 | 59 | /*! default template instantiations */ 60 | typedef Col4 Col4c; 61 | typedef Col4 Col4f; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /test/embree/sys/library.cpp: -------------------------------------------------------------------------------- 1 | // ======================================================================== // 2 | // Copyright 2009-2013 Intel Corporation // 3 | // // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); // 5 | // you may not use this file except in compliance with the License. // 6 | // You may obtain a copy of the License at // 7 | // // 8 | // http://www.apache.org/licenses/LICENSE-2.0 // 9 | // // 10 | // Unless required by applicable law or agreed to in writing, software // 11 | // distributed under the License is distributed on an "AS IS" BASIS, // 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // 13 | // See the License for the specific language governing permissions and // 14 | // limitations under the License. // 15 | // ======================================================================== // 16 | 17 | #include "library.h" 18 | #include "sysinfo.h" 19 | #include "filename.h" 20 | 21 | //////////////////////////////////////////////////////////////////////////////// 22 | /// Windows Platform 23 | //////////////////////////////////////////////////////////////////////////////// 24 | 25 | #if defined(__WIN32__) 26 | 27 | #define WIN32_LEAN_AND_MEAN 28 | #include 29 | 30 | namespace embree 31 | { 32 | /* opens a shared library */ 33 | lib_t openLibrary(const std::string& file) 34 | { 35 | std::string fullName = file+".dll"; 36 | FileName executable = getExecutableFileName(); 37 | HANDLE handle = LoadLibrary((executable.path() + fullName).c_str()); 38 | return lib_t(handle); 39 | } 40 | 41 | /* returns address of a symbol from the library */ 42 | void* getSymbol(lib_t lib, const std::string& sym) { 43 | return GetProcAddress(HMODULE(lib),sym.c_str()); 44 | } 45 | 46 | /* closes the shared library */ 47 | void closeLibrary(lib_t lib) { 48 | FreeLibrary(HMODULE(lib)); 49 | } 50 | } 51 | #endif 52 | 53 | //////////////////////////////////////////////////////////////////////////////// 54 | /// Unix Platform 55 | //////////////////////////////////////////////////////////////////////////////// 56 | 57 | #if defined(__UNIX__) 58 | 59 | #include 60 | 61 | namespace embree 62 | { 63 | /* opens a shared library */ 64 | lib_t openLibrary(const std::string& file) 65 | { 66 | #if defined(__MACOSX__) 67 | std::string fullName = "lib"+file+".dylib"; 68 | #else 69 | std::string fullName = "lib"+file+".so"; 70 | #endif 71 | FileName executable = getExecutableFileName(); 72 | void* lib = dlopen((executable.path() + fullName).c_str(),RTLD_NOW); 73 | if (lib == NULL) throw std::runtime_error(dlerror()); 74 | return lib_t(lib); 75 | } 76 | 77 | /* returns address of a symbol from the library */ 78 | void* getSymbol(lib_t lib, const std::string& sym) { 79 | return dlsym(lib,sym.c_str()); 80 | } 81 | 82 | /* closes the shared library */ 83 | void closeLibrary(lib_t lib) { 84 | dlclose(lib); 85 | } 86 | } 87 | #endif 88 | --------------------------------------------------------------------------------