Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/embree/kernels/bvh/bvh_intersector_hybrid.h
9913 views
1
// Copyright 2009-2021 Intel Corporation
2
// SPDX-License-Identifier: Apache-2.0
3
4
#pragma once
5
6
#include "bvh.h"
7
#include "../common/ray.h"
8
#include "../common/stack_item.h"
9
#include "node_intersector_frustum.h"
10
11
namespace embree
12
{
13
namespace isa
14
{
15
template<int K, bool robust>
16
struct TravRayK;
17
18
/*! BVH hybrid packet intersector. Switches between packet and single ray traversal (optional). */
19
template<int N, int K, int types, bool robust, typename PrimitiveIntersectorK, bool single = true>
20
class BVHNIntersectorKHybrid
21
{
22
/* shortcuts for frequently used types */
23
typedef typename PrimitiveIntersectorK::Precalculations Precalculations;
24
typedef typename PrimitiveIntersectorK::Primitive Primitive;
25
typedef BVHN<N> BVH;
26
typedef typename BVH::NodeRef NodeRef;
27
typedef typename BVH::BaseNode BaseNode;
28
typedef typename BVH::AABBNode AABBNode;
29
30
static const size_t stackSizeSingle = 1+(N-1)*BVH::maxDepth+3; // +3 due to 16-wide store
31
static const size_t stackSizeChunk = 1+(N-1)*BVH::maxDepth;
32
33
static const size_t switchThresholdIncoherent = \
34
(K==4) ? 3 :
35
(K==8) ? ((N==4) ? 5 : 7) :
36
(K==16) ? 14 : // 14 seems to work best for KNL due to better ordered chunk traversal
37
0;
38
39
private:
40
static void intersect1(Accel::Intersectors* This, const BVH* bvh, NodeRef root, size_t k, Precalculations& pre,
41
RayHitK<K>& ray, const TravRayK<K, robust>& tray, RayQueryContext* context);
42
static bool occluded1(Accel::Intersectors* This, const BVH* bvh, NodeRef root, size_t k, Precalculations& pre,
43
RayK<K>& ray, const TravRayK<K, robust>& tray, RayQueryContext* context);
44
45
public:
46
static void intersect(vint<K>* valid, Accel::Intersectors* This, RayHitK<K>& ray, RayQueryContext* context);
47
static void occluded (vint<K>* valid, Accel::Intersectors* This, RayK<K>& ray, RayQueryContext* context);
48
49
static void intersectCoherent(vint<K>* valid, Accel::Intersectors* This, RayHitK<K>& ray, RayQueryContext* context);
50
static void occludedCoherent (vint<K>* valid, Accel::Intersectors* This, RayK<K>& ray, RayQueryContext* context);
51
52
};
53
54
/*! BVH packet intersector. */
55
template<int N, int K, int types, bool robust, typename PrimitiveIntersectorK>
56
class BVHNIntersectorKChunk : public BVHNIntersectorKHybrid<N, K, types, robust, PrimitiveIntersectorK, false> {};
57
}
58
}
59
60