1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "curveNv.h"
#include "curveNi_intersector.h"
namespace embree
{
namespace isa
{
template<int M>
struct CurveNvIntersector1 : public CurveNiIntersector1<M>
{
typedef CurveNv<M> Primitive;
typedef CurvePrecalculations1 Precalculations;
template<typename Intersector, typename Epilog>
static __forceinline void intersect_t(const Precalculations& pre, RayHit& ray, IntersectContext* context, const Primitive& prim)
{
vfloat<M> tNear;
vbool<M> valid = CurveNiIntersector1<M>::intersect(ray,prim,tNear);
const size_t N = prim.N;
size_t mask = movemask(valid);
while (mask)
{
const size_t i = bscf(mask);
STAT3(normal.trav_prims,1,1,1);
const unsigned int geomID = prim.geomID(N);
const unsigned int primID = prim.primID(N)[i];
const CurveGeometry* geom = (CurveGeometry*) context->scene->get(geomID);
const Vec3ff a0 = Vec3ff::loadu(&prim.vertices(i,N)[0]);
const Vec3ff a1 = Vec3ff::loadu(&prim.vertices(i,N)[1]);
const Vec3ff a2 = Vec3ff::loadu(&prim.vertices(i,N)[2]);
const Vec3ff a3 = Vec3ff::loadu(&prim.vertices(i,N)[3]);
size_t mask1 = mask;
const size_t i1 = bscf(mask1);
if (mask) {
prefetchL1(&prim.vertices(i1,N)[0]);
prefetchL1(&prim.vertices(i1,N)[4]);
if (mask1) {
const size_t i2 = bsf(mask1);
prefetchL2(&prim.vertices(i2,N)[0]);
prefetchL2(&prim.vertices(i2,N)[4]);
}
}
Intersector().intersect(pre,ray,context,geom,primID,a0,a1,a2,a3,Epilog(ray,context,geomID,primID));
mask &= movemask(tNear <= vfloat<M>(ray.tfar));
}
}
template<typename Intersector, typename Epilog>
static __forceinline bool occluded_t(const Precalculations& pre, Ray& ray, IntersectContext* context, const Primitive& prim)
{
vfloat<M> tNear;
vbool<M> valid = CurveNiIntersector1<M>::intersect(ray,prim,tNear);
const size_t N = prim.N;
size_t mask = movemask(valid);
while (mask)
{
const size_t i = bscf(mask);
STAT3(shadow.trav_prims,1,1,1);
const unsigned int geomID = prim.geomID(N);
const unsigned int primID = prim.primID(N)[i];
const CurveGeometry* geom = (CurveGeometry*) context->scene->get(geomID);
const Vec3ff a0 = Vec3ff::loadu(&prim.vertices(i,N)[0]);
const Vec3ff a1 = Vec3ff::loadu(&prim.vertices(i,N)[1]);
const Vec3ff a2 = Vec3ff::loadu(&prim.vertices(i,N)[2]);
const Vec3ff a3 = Vec3ff::loadu(&prim.vertices(i,N)[3]);
size_t mask1 = mask;
const size_t i1 = bscf(mask1);
if (mask) {
prefetchL1(&prim.vertices(i1,N)[0]);
prefetchL1(&prim.vertices(i1,N)[4]);
if (mask1) {
const size_t i2 = bsf(mask1);
prefetchL2(&prim.vertices(i2,N)[0]);
prefetchL2(&prim.vertices(i2,N)[4]);
}
}
if (Intersector().intersect(pre,ray,context,geom,primID,a0,a1,a2,a3,Epilog(ray,context,geomID,primID)))
return true;
mask &= movemask(tNear <= vfloat<M>(ray.tfar));
}
return false;
}
};
template<int M, int K>
struct CurveNvIntersectorK : public CurveNiIntersectorK<M,K>
{
typedef CurveNv<M> Primitive;
typedef CurvePrecalculationsK<K> Precalculations;
template<typename Intersector, typename Epilog>
static __forceinline void intersect_t(Precalculations& pre, RayHitK<K>& ray, const size_t k, IntersectContext* context, const Primitive& prim)
{
vfloat<M> tNear;
vbool<M> valid = CurveNiIntersectorK<M,K>::intersect(ray,k,prim,tNear);
const size_t N = prim.N;
size_t mask = movemask(valid);
while (mask)
{
const size_t i = bscf(mask);
STAT3(normal.trav_prims,1,1,1);
const unsigned int geomID = prim.geomID(N);
const unsigned int primID = prim.primID(N)[i];
const CurveGeometry* geom = (CurveGeometry*) context->scene->get(geomID);
const Vec3ff a0 = Vec3ff::loadu(&prim.vertices(i,N)[0]);
const Vec3ff a1 = Vec3ff::loadu(&prim.vertices(i,N)[1]);
const Vec3ff a2 = Vec3ff::loadu(&prim.vertices(i,N)[2]);
const Vec3ff a3 = Vec3ff::loadu(&prim.vertices(i,N)[3]);
size_t mask1 = mask;
const size_t i1 = bscf(mask1);
if (mask) {
prefetchL1(&prim.vertices(i1,N)[0]);
prefetchL1(&prim.vertices(i1,N)[4]);
if (mask1) {
const size_t i2 = bsf(mask1);
prefetchL2(&prim.vertices(i2,N)[0]);
prefetchL2(&prim.vertices(i2,N)[4]);
}
}
Intersector().intersect(pre,ray,k,context,geom,primID,a0,a1,a2,a3,Epilog(ray,k,context,geomID,primID));
mask &= movemask(tNear <= vfloat<M>(ray.tfar[k]));
}
}
template<typename Intersector, typename Epilog>
static __forceinline bool occluded_t(Precalculations& pre, RayK<K>& ray, const size_t k, IntersectContext* context, const Primitive& prim)
{
vfloat<M> tNear;
vbool<M> valid = CurveNiIntersectorK<M,K>::intersect(ray,k,prim,tNear);
const size_t N = prim.N;
size_t mask = movemask(valid);
while (mask)
{
const size_t i = bscf(mask);
STAT3(shadow.trav_prims,1,1,1);
const unsigned int geomID = prim.geomID(N);
const unsigned int primID = prim.primID(N)[i];
const CurveGeometry* geom = (CurveGeometry*) context->scene->get(geomID);
const Vec3ff a0 = Vec3ff::loadu(&prim.vertices(i,N)[0]);
const Vec3ff a1 = Vec3ff::loadu(&prim.vertices(i,N)[1]);
const Vec3ff a2 = Vec3ff::loadu(&prim.vertices(i,N)[2]);
const Vec3ff a3 = Vec3ff::loadu(&prim.vertices(i,N)[3]);
size_t mask1 = mask;
const size_t i1 = bscf(mask1);
if (mask) {
prefetchL1(&prim.vertices(i1,N)[0]);
prefetchL1(&prim.vertices(i1,N)[4]);
if (mask1) {
const size_t i2 = bsf(mask1);
prefetchL2(&prim.vertices(i2,N)[0]);
prefetchL2(&prim.vertices(i2,N)[4]);
}
}
if (Intersector().intersect(pre,ray,k,context,geom,primID,a0,a1,a2,a3,Epilog(ray,k,context,geomID,primID)))
return true;
mask &= movemask(tNear <= vfloat<M>(ray.tfar[k]));
}
return false;
}
};
}
}
|