1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include "instance.h"
7#include "../common/ray.h"
8#include "../common/point_query.h"
9
10namespace embree
11{
12 namespace isa
13 {
14 struct InstanceIntersector1
15 {
16 typedef InstancePrimitive Primitive;
17
18 struct Precalculations {
19 __forceinline Precalculations (const Ray& ray, const void *ptr) {}
20 };
21
22 static void intersect(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& prim);
23 static bool occluded(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& prim);
24 static bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& prim);
25 };
26
27 struct InstanceIntersector1MB
28 {
29 typedef InstancePrimitive Primitive;
30
31 struct Precalculations {
32 __forceinline Precalculations (const Ray& ray, const void *ptr) {}
33 };
34
35 static void intersect(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& prim);
36 static bool occluded(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& prim);
37 static bool pointQuery(PointQuery* query, PointQueryContext* context, const Primitive& prim);
38 };
39
40 template<int K>
41 struct InstanceIntersectorK
42 {
43 typedef InstancePrimitive Primitive;
44
45 struct Precalculations {
46 __forceinline Precalculations (const vbool<K>& valid, const RayK<K>& ray) {}
47 };
48
49 static void intersect(const vbool<K>& valid_i, const Precalculations& pre, RayHitK<K>& ray, IntersectContext* context, const Primitive& prim);
50 static vbool<K> occluded(const vbool<K>& valid_i, const Precalculations& pre, RayK<K>& ray, IntersectContext* context, const Primitive& prim);
51
52 static __forceinline void intersect(Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& prim) {
53 intersect(vbool<K>(1<<int(k)),pre,ray,context,prim);
54 }
55
56 static __forceinline bool occluded(Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& prim) {
57 occluded(vbool<K>(1<<int(k)),pre,ray,context,prim);
58 return ray.tfar[k] < 0.0f;
59 }
60 };
61
62 template<int K>
63 struct InstanceIntersectorKMB
64 {
65 typedef InstancePrimitive Primitive;
66
67 struct Precalculations {
68 __forceinline Precalculations (const vbool<K>& valid, const RayK<K>& ray) {}
69 };
70
71 static void intersect(const vbool<K>& valid_i, const Precalculations& pre, RayHitK<K>& ray, IntersectContext* context, const Primitive& prim);
72 static vbool<K> occluded(const vbool<K>& valid_i, const Precalculations& pre, RayK<K>& ray, IntersectContext* context, const Primitive& prim);
73
74 static __forceinline void intersect(Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& prim) {
75 intersect(vbool<K>(1<<int(k)),pre,ray,context,prim);
76 }
77
78 static __forceinline bool occluded(Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& prim) {
79 occluded(vbool<K>(1<<int(k)),pre,ray,context,prim);
80 return ray.tfar[k] < 0.0f;
81 }
82 };
83 }
84}
85