diff options
Diffstat (limited to 'thirdparty/embree/kernels/common/accel.h')
-rw-r--r-- | thirdparty/embree/kernels/common/accel.h | 200 |
1 files changed, 59 insertions, 141 deletions
diff --git a/thirdparty/embree/kernels/common/accel.h b/thirdparty/embree/kernels/common/accel.h index d24326ce92..7d959377ae 100644 --- a/thirdparty/embree/kernels/common/accel.h +++ b/thirdparty/embree/kernels/common/accel.h @@ -17,7 +17,7 @@ namespace embree { ALIGNED_CLASS_(16); public: - enum Type { TY_UNKNOWN = 0, TY_ACCELN = 1, TY_ACCEL_INSTANCE = 2, TY_BVH4 = 3, TY_BVH8 = 4 }; + enum Type { TY_UNKNOWN = 0, TY_ACCELN = 1, TY_ACCEL_INSTANCE = 2, TY_BVH4 = 3, TY_BVH8 = 4, TY_GPU = 5 }; public: AccelData (const Type type) @@ -73,61 +73,49 @@ namespace embree /*! Type of intersect function pointer for single rays. */ typedef void (*IntersectFunc)(Intersectors* This, /*!< this pointer to accel */ RTCRayHit& ray, /*!< ray to intersect */ - IntersectContext* context); + RayQueryContext* context); /*! Type of intersect function pointer for ray packets of size 4. */ typedef void (*IntersectFunc4)(const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRayHit4& ray, /*!< ray packet to intersect */ - IntersectContext* context); + RayQueryContext* context); /*! Type of intersect function pointer for ray packets of size 8. */ typedef void (*IntersectFunc8)(const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRayHit8& ray, /*!< ray packet to intersect */ - IntersectContext* context); + RayQueryContext* context); /*! Type of intersect function pointer for ray packets of size 16. */ typedef void (*IntersectFunc16)(const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRayHit16& ray, /*!< ray packet to intersect */ - IntersectContext* context); + RayQueryContext* context); - /*! Type of intersect function pointer for ray packets of size N. */ - typedef void (*IntersectFuncN)(Intersectors* This, /*!< this pointer to accel */ - RTCRayHitN** ray, /*!< ray stream to intersect */ - const size_t N, /*!< number of rays in stream */ - IntersectContext* context /*!< layout flags */); - - /*! Type of occlusion function pointer for single rays. */ typedef void (*OccludedFunc) (Intersectors* This, /*!< this pointer to accel */ RTCRay& ray, /*!< ray to test occlusion */ - IntersectContext* context); + RayQueryContext* context); /*! Type of occlusion function pointer for ray packets of size 4. */ typedef void (*OccludedFunc4) (const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRay4& ray, /*!< ray packet to test occlusion. */ - IntersectContext* context); + RayQueryContext* context); /*! Type of occlusion function pointer for ray packets of size 8. */ typedef void (*OccludedFunc8) (const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRay8& ray, /*!< ray packet to test occlusion. */ - IntersectContext* context); + RayQueryContext* context); /*! Type of occlusion function pointer for ray packets of size 16. */ typedef void (*OccludedFunc16) (const void* valid, /*!< pointer to valid mask */ Intersectors* This, /*!< this pointer to accel */ RTCRay16& ray, /*!< ray packet to test occlusion. */ - IntersectContext* context); + RayQueryContext* context); - /*! Type of intersect function pointer for ray packets of size N. */ - typedef void (*OccludedFuncN)(Intersectors* This, /*!< this pointer to accel */ - RTCRayN** ray, /*!< ray stream to test occlusion */ - const size_t N, /*!< number of rays in stream */ - IntersectContext* context /*!< layout flags */); typedef void (*ErrorFunc) (); struct Collider @@ -217,30 +205,13 @@ namespace embree const char* name; }; - struct IntersectorN - { - IntersectorN (ErrorFunc error = nullptr) - : intersect((IntersectFuncN)error), occluded((OccludedFuncN)error), name(nullptr) {} - - IntersectorN (IntersectFuncN intersect, OccludedFuncN occluded, const char* name) - : intersect(intersect), occluded(occluded), name(name) {} - - operator bool() const { return name; } - - public: - static const char* type; - IntersectFuncN intersect; - OccludedFuncN occluded; - const char* name; - }; - struct Intersectors { Intersectors() - : ptr(nullptr), leafIntersector(nullptr), collider(nullptr), intersector1(nullptr), intersector4(nullptr), intersector8(nullptr), intersector16(nullptr), intersectorN(nullptr) {} + : ptr(nullptr), leafIntersector(nullptr), collider(nullptr), intersector1(nullptr), intersector4(nullptr), intersector8(nullptr), intersector16(nullptr) {} Intersectors (ErrorFunc error) - : ptr(nullptr), leafIntersector(nullptr), collider(error), intersector1(error), intersector4(error), intersector8(error), intersector16(error), intersectorN(error) {} + : ptr(nullptr), leafIntersector(nullptr), collider(error), intersector1(error), intersector4(error), intersector8(error), intersector16(error) {} void print(size_t ident) { @@ -264,10 +235,6 @@ namespace embree for (size_t i=0; i<ident; i++) std::cout << " "; std::cout << "intersector16 = " << intersector16.name << std::endl; } - if (intersectorN.name) { - for (size_t i=0; i<ident; i++) std::cout << " "; - std::cout << "intersectorN = " << intersectorN.name << std::endl; - } } void select(bool filter) @@ -284,10 +251,6 @@ namespace embree if (filter) intersector16 = intersector16_filter; else intersector16 = intersector16_nofilter; } - if (intersectorN_filter) { - if (filter) intersectorN = intersectorN_filter; - else intersectorN = intersectorN_nofilter; - } } __forceinline bool pointQuery (PointQuery* query, PointQueryContext* context) { @@ -302,133 +265,138 @@ namespace embree } /*! Intersects a single ray with the scene. */ - __forceinline void intersect (RTCRayHit& ray, IntersectContext* context) { + __forceinline void intersect (RTCRayHit& ray, RayQueryContext* context) { assert(intersector1.intersect); intersector1.intersect(this,ray,context); } /*! Intersects a packet of 4 rays with the scene. */ - __forceinline void intersect4 (const void* valid, RTCRayHit4& ray, IntersectContext* context) { + __forceinline void intersect4 (const void* valid, RTCRayHit4& ray, RayQueryContext* context) { assert(intersector4.intersect); intersector4.intersect(valid,this,ray,context); } /*! Intersects a packet of 8 rays with the scene. */ - __forceinline void intersect8 (const void* valid, RTCRayHit8& ray, IntersectContext* context) { + __forceinline void intersect8 (const void* valid, RTCRayHit8& ray, RayQueryContext* context) { assert(intersector8.intersect); intersector8.intersect(valid,this,ray,context); } /*! Intersects a packet of 16 rays with the scene. */ - __forceinline void intersect16 (const void* valid, RTCRayHit16& ray, IntersectContext* context) { + __forceinline void intersect16 (const void* valid, RTCRayHit16& ray, RayQueryContext* context) { assert(intersector16.intersect); intersector16.intersect(valid,this,ray,context); } + + /*! Intersects a packet of 4 rays with the scene. */ + __forceinline void intersect (const void* valid, RTCRayHit4& ray, RayQueryContext* context) { + assert(intersector4.intersect); + intersector4.intersect(valid,this,ray,context); + } - /*! Intersects a stream of N rays in SOA layout with the scene. */ - __forceinline void intersectN (RTCRayHitN** rayN, const size_t N, IntersectContext* context) - { - assert(intersectorN.intersect); - intersectorN.intersect(this,rayN,N,context); + /*! Intersects a packet of 8 rays with the scene. */ + __forceinline void intersect (const void* valid, RTCRayHit8& ray, RayQueryContext* context) { + assert(intersector8.intersect); + intersector8.intersect(valid,this,ray,context); + } + + /*! Intersects a packet of 16 rays with the scene. */ + __forceinline void intersect (const void* valid, RTCRayHit16& ray, RayQueryContext* context) { + assert(intersector16.intersect); + intersector16.intersect(valid,this,ray,context); } #if defined(__SSE__) || defined(__ARM_NEON) - __forceinline void intersect(const vbool4& valid, RayHitK<4>& ray, IntersectContext* context) { + __forceinline void intersect(const vbool4& valid, RayHitK<4>& ray, RayQueryContext* context) { const vint<4> mask = valid.mask32(); intersect4(&mask,(RTCRayHit4&)ray,context); } #endif #if defined(__AVX__) - __forceinline void intersect(const vbool8& valid, RayHitK<8>& ray, IntersectContext* context) { + __forceinline void intersect(const vbool8& valid, RayHitK<8>& ray, RayQueryContext* context) { const vint<8> mask = valid.mask32(); intersect8(&mask,(RTCRayHit8&)ray,context); } #endif #if defined(__AVX512F__) - __forceinline void intersect(const vbool16& valid, RayHitK<16>& ray, IntersectContext* context) { + __forceinline void intersect(const vbool16& valid, RayHitK<16>& ray, RayQueryContext* context) { const vint<16> mask = valid.mask32(); intersect16(&mask,(RTCRayHit16&)ray,context); } #endif - template<int K> - __forceinline void intersectN (RayHitK<K>** rayN, const size_t N, IntersectContext* context) - { - intersectN((RTCRayHitN**)rayN,N,context); - } - /*! Tests if single ray is occluded by the scene. */ - __forceinline void occluded (RTCRay& ray, IntersectContext* context) { + __forceinline void occluded (RTCRay& ray, RayQueryContext* context) { assert(intersector1.occluded); intersector1.occluded(this,ray,context); } /*! Tests if a packet of 4 rays is occluded by the scene. */ - __forceinline void occluded4 (const void* valid, RTCRay4& ray, IntersectContext* context) { + __forceinline void occluded4 (const void* valid, RTCRay4& ray, RayQueryContext* context) { assert(intersector4.occluded); intersector4.occluded(valid,this,ray,context); } /*! Tests if a packet of 8 rays is occluded by the scene. */ - __forceinline void occluded8 (const void* valid, RTCRay8& ray, IntersectContext* context) { + __forceinline void occluded8 (const void* valid, RTCRay8& ray, RayQueryContext* context) { assert(intersector8.occluded); intersector8.occluded(valid,this,ray,context); } /*! Tests if a packet of 16 rays is occluded by the scene. */ - __forceinline void occluded16 (const void* valid, RTCRay16& ray, IntersectContext* context) { + __forceinline void occluded16 (const void* valid, RTCRay16& ray, RayQueryContext* context) { assert(intersector16.occluded); intersector16.occluded(valid,this,ray,context); } + + /*! Tests if a packet of 4 rays is occluded by the scene. */ + __forceinline void occluded (const void* valid, RTCRay4& ray, RayQueryContext* context) { + assert(intersector4.occluded); + intersector4.occluded(valid,this,ray,context); + } - /*! Tests if a stream of N rays in SOA layout is occluded by the scene. */ - __forceinline void occludedN (RTCRayN** rayN, const size_t N, IntersectContext* context) - { - assert(intersectorN.occluded); - intersectorN.occluded(this,rayN,N,context); + /*! Tests if a packet of 8 rays is occluded by the scene. */ + __forceinline void occluded (const void* valid, RTCRay8& ray, RayQueryContext* context) { + assert(intersector8.occluded); + intersector8.occluded(valid,this,ray,context); + } + + /*! Tests if a packet of 16 rays is occluded by the scene. */ + __forceinline void occluded (const void* valid, RTCRay16& ray, RayQueryContext* context) { + assert(intersector16.occluded); + intersector16.occluded(valid,this,ray,context); } #if defined(__SSE__) || defined(__ARM_NEON) - __forceinline void occluded(const vbool4& valid, RayK<4>& ray, IntersectContext* context) { + __forceinline void occluded(const vbool4& valid, RayK<4>& ray, RayQueryContext* context) { const vint<4> mask = valid.mask32(); occluded4(&mask,(RTCRay4&)ray,context); } #endif #if defined(__AVX__) - __forceinline void occluded(const vbool8& valid, RayK<8>& ray, IntersectContext* context) { + __forceinline void occluded(const vbool8& valid, RayK<8>& ray, RayQueryContext* context) { const vint<8> mask = valid.mask32(); occluded8(&mask,(RTCRay8&)ray,context); } #endif #if defined(__AVX512F__) - __forceinline void occluded(const vbool16& valid, RayK<16>& ray, IntersectContext* context) { + __forceinline void occluded(const vbool16& valid, RayK<16>& ray, RayQueryContext* context) { const vint<16> mask = valid.mask32(); occluded16(&mask,(RTCRay16&)ray,context); } #endif - template<int K> - __forceinline void occludedN (RayK<K>** rayN, const size_t N, IntersectContext* context) - { - occludedN((RTCRayN**)rayN,N,context); - } - /*! Tests if single ray is occluded by the scene. */ - __forceinline void intersect(RTCRay& ray, IntersectContext* context) { + __forceinline void intersect(RTCRay& ray, RayQueryContext* context) { occluded(ray, context); } /*! Tests if a packet of K rays is occluded by the scene. */ template<int K> - __forceinline void intersect(const vbool<K>& valid, RayK<K>& ray, IntersectContext* context) { + __forceinline void intersect(const vbool<K>& valid, RayK<K>& ray, RayQueryContext* context) { occluded(valid, ray, context); } - /*! Tests if a packet of N rays in SOA layout is occluded by the scene. */ - template<int K> - __forceinline void intersectN(RayK<K>** rayN, const size_t N, IntersectContext* context) { - occludedN(rayN, N, context); - } public: AccelData* ptr; @@ -444,9 +412,6 @@ namespace embree Intersector16 intersector16; Intersector16 intersector16_filter; Intersector16 intersector16_nofilter; - IntersectorN intersectorN; - IntersectorN intersectorN_filter; - IntersectorN intersectorN_nofilter; }; public: @@ -506,51 +471,4 @@ namespace embree (Accel::OccludedFunc16)intersector::occluded, \ TOSTRING(isa) "::" TOSTRING(symbol)); \ } - -#define DEFINE_INTERSECTORN(symbol,intersector) \ - Accel::IntersectorN symbol() { \ - return Accel::IntersectorN((Accel::IntersectFuncN)intersector::intersect, \ - (Accel::OccludedFuncN)intersector::occluded, \ - TOSTRING(isa) "::" TOSTRING(symbol)); \ - } - - /* ray stream filter interface */ - typedef void (*intersectStreamAOS_func)(Scene* scene, RTCRayHit* _rayN, const size_t N, const size_t stride, IntersectContext* context); - typedef void (*intersectStreamAOP_func)(Scene* scene, RTCRayHit** _rayN, const size_t N, IntersectContext* context); - typedef void (*intersectStreamSOA_func)(Scene* scene, char* rayN, const size_t N, const size_t streams, const size_t stream_offset, IntersectContext* context); - typedef void (*intersectStreamSOP_func)(Scene* scene, const RTCRayHitNp* rayN, const size_t N, IntersectContext* context); - - typedef void (*occludedStreamAOS_func)(Scene* scene, RTCRay* _rayN, const size_t N, const size_t stride, IntersectContext* context); - typedef void (*occludedStreamAOP_func)(Scene* scene, RTCRay** _rayN, const size_t N, IntersectContext* context); - typedef void (*occludedStreamSOA_func)(Scene* scene, char* rayN, const size_t N, const size_t streams, const size_t stream_offset, IntersectContext* context); - typedef void (*occludedStreamSOP_func)(Scene* scene, const RTCRayNp* rayN, const size_t N, IntersectContext* context); - - struct RayStreamFilterFuncs - { - RayStreamFilterFuncs() - : intersectAOS(nullptr), intersectAOP(nullptr), intersectSOA(nullptr), intersectSOP(nullptr), - occludedAOS(nullptr), occludedAOP(nullptr), occludedSOA(nullptr), occludedSOP(nullptr) {} - - RayStreamFilterFuncs(void (*ptr) ()) - : intersectAOS((intersectStreamAOS_func) ptr), intersectAOP((intersectStreamAOP_func) ptr), intersectSOA((intersectStreamSOA_func) ptr), intersectSOP((intersectStreamSOP_func) ptr), - occludedAOS((occludedStreamAOS_func) ptr), occludedAOP((occludedStreamAOP_func) ptr), occludedSOA((occludedStreamSOA_func) ptr), occludedSOP((occludedStreamSOP_func) ptr) {} - - RayStreamFilterFuncs(intersectStreamAOS_func intersectAOS, intersectStreamAOP_func intersectAOP, intersectStreamSOA_func intersectSOA, intersectStreamSOP_func intersectSOP, - occludedStreamAOS_func occludedAOS, occludedStreamAOP_func occludedAOP, occludedStreamSOA_func occludedSOA, occludedStreamSOP_func occludedSOP) - : intersectAOS(intersectAOS), intersectAOP(intersectAOP), intersectSOA(intersectSOA), intersectSOP(intersectSOP), - occludedAOS(occludedAOS), occludedAOP(occludedAOP), occludedSOA(occludedSOA), occludedSOP(occludedSOP) {} - - public: - intersectStreamAOS_func intersectAOS; - intersectStreamAOP_func intersectAOP; - intersectStreamSOA_func intersectSOA; - intersectStreamSOP_func intersectSOP; - - occludedStreamAOS_func occludedAOS; - occludedStreamAOP_func occludedAOP; - occludedStreamSOA_func occludedSOA; - occludedStreamSOP_func occludedSOP; - }; - - typedef RayStreamFilterFuncs (*RayStreamFilterFuncsType)(); } |