Path: blob/master/thirdparty/embree/kernels/bvh/bvh_intersector_hybrid.h
9913 views
// Copyright 2009-2021 Intel Corporation1// SPDX-License-Identifier: Apache-2.023#pragma once45#include "bvh.h"6#include "../common/ray.h"7#include "../common/stack_item.h"8#include "node_intersector_frustum.h"910namespace embree11{12namespace isa13{14template<int K, bool robust>15struct TravRayK;1617/*! BVH hybrid packet intersector. Switches between packet and single ray traversal (optional). */18template<int N, int K, int types, bool robust, typename PrimitiveIntersectorK, bool single = true>19class BVHNIntersectorKHybrid20{21/* shortcuts for frequently used types */22typedef typename PrimitiveIntersectorK::Precalculations Precalculations;23typedef typename PrimitiveIntersectorK::Primitive Primitive;24typedef BVHN<N> BVH;25typedef typename BVH::NodeRef NodeRef;26typedef typename BVH::BaseNode BaseNode;27typedef typename BVH::AABBNode AABBNode;2829static const size_t stackSizeSingle = 1+(N-1)*BVH::maxDepth+3; // +3 due to 16-wide store30static const size_t stackSizeChunk = 1+(N-1)*BVH::maxDepth;3132static const size_t switchThresholdIncoherent = \33(K==4) ? 3 :34(K==8) ? ((N==4) ? 5 : 7) :35(K==16) ? 14 : // 14 seems to work best for KNL due to better ordered chunk traversal360;3738private:39static void intersect1(Accel::Intersectors* This, const BVH* bvh, NodeRef root, size_t k, Precalculations& pre,40RayHitK<K>& ray, const TravRayK<K, robust>& tray, RayQueryContext* context);41static bool occluded1(Accel::Intersectors* This, const BVH* bvh, NodeRef root, size_t k, Precalculations& pre,42RayK<K>& ray, const TravRayK<K, robust>& tray, RayQueryContext* context);4344public:45static void intersect(vint<K>* valid, Accel::Intersectors* This, RayHitK<K>& ray, RayQueryContext* context);46static void occluded (vint<K>* valid, Accel::Intersectors* This, RayK<K>& ray, RayQueryContext* context);4748static void intersectCoherent(vint<K>* valid, Accel::Intersectors* This, RayHitK<K>& ray, RayQueryContext* context);49static void occludedCoherent (vint<K>* valid, Accel::Intersectors* This, RayK<K>& ray, RayQueryContext* context);5051};5253/*! BVH packet intersector. */54template<int N, int K, int types, bool robust, typename PrimitiveIntersectorK>55class BVHNIntersectorKChunk : public BVHNIntersectorKHybrid<N, K, types, robust, PrimitiveIntersectorK, false> {};56}57}585960