| 1 | // Copyright 2009-2021 Intel Corporation | 
| 2 | // SPDX-License-Identifier: Apache-2.0 | 
| 3 |  | 
| 4 | #pragma once | 
| 5 |  | 
| 6 | #include "disc_intersector.h" | 
| 7 | #include "intersector_epilog.h" | 
| 8 | #include "pointi.h" | 
| 9 |  | 
| 10 | namespace embree | 
| 11 | { | 
| 12 |   namespace isa | 
| 13 |   { | 
| 14 |     template<int M, bool filter> | 
| 15 |     struct DiscMiIntersector1 | 
| 16 |     { | 
| 17 |       typedef PointMi<M> Primitive; | 
| 18 |       typedef CurvePrecalculations1 Precalculations; | 
| 19 |  | 
| 20 |       static __forceinline void intersect(const Precalculations& pre, | 
| 21 |                                           RayHit& ray, | 
| 22 |                                           IntersectContext* context, | 
| 23 |                                           const Primitive& Disc) | 
| 24 |       { | 
| 25 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 26 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 27 |         Vec4vf<M> v0; Disc.gather(v0, geom); | 
| 28 |         const vbool<M> valid = Disc.valid(); | 
| 29 |         DiscIntersector1<M>::intersect( | 
| 30 |           valid, ray, context, geom, pre, v0, Intersect1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 31 |       } | 
| 32 |  | 
| 33 |       static __forceinline bool occluded(const Precalculations& pre, | 
| 34 |                                          Ray& ray, | 
| 35 |                                          IntersectContext* context, | 
| 36 |                                          const Primitive& Disc) | 
| 37 |       { | 
| 38 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 39 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 40 |         Vec4vf<M> v0; Disc.gather(v0, geom); | 
| 41 |         const vbool<M> valid = Disc.valid(); | 
| 42 |         return DiscIntersector1<M>::intersect( | 
| 43 |           valid, ray, context, geom, pre, v0, Occluded1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 44 |       } | 
| 45 |     }; | 
| 46 |  | 
| 47 |     template<int M, bool filter> | 
| 48 |     struct DiscMiMBIntersector1 | 
| 49 |     { | 
| 50 |       typedef PointMi<M> Primitive; | 
| 51 |       typedef CurvePrecalculations1 Precalculations; | 
| 52 |  | 
| 53 |       static __forceinline void intersect(const Precalculations& pre, | 
| 54 |                                           RayHit& ray, | 
| 55 |                                           IntersectContext* context, | 
| 56 |                                           const Primitive& Disc) | 
| 57 |       { | 
| 58 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 59 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 60 |         Vec4vf<M> v0; Disc.gather(v0, geom, ray.time()); | 
| 61 |         const vbool<M> valid = Disc.valid(); | 
| 62 |         DiscIntersector1<M>::intersect( | 
| 63 |           valid, ray, context, geom, pre, v0, Intersect1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 64 |       } | 
| 65 |  | 
| 66 |       static __forceinline bool occluded(const Precalculations& pre, | 
| 67 |                                          Ray& ray, | 
| 68 |                                          IntersectContext* context, | 
| 69 |                                          const Primitive& Disc) | 
| 70 |       { | 
| 71 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 72 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 73 |         Vec4vf<M> v0; Disc.gather(v0, geom, ray.time()); | 
| 74 |         const vbool<M> valid = Disc.valid(); | 
| 75 |         return DiscIntersector1<M>::intersect( | 
| 76 |           valid, ray, context, geom, pre, v0, Occluded1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 77 |       } | 
| 78 |     }; | 
| 79 |  | 
| 80 |     template<int M, int K, bool filter> | 
| 81 |     struct DiscMiIntersectorK | 
| 82 |     { | 
| 83 |       typedef PointMi<M> Primitive; | 
| 84 |       typedef CurvePrecalculationsK<K> Precalculations; | 
| 85 |  | 
| 86 |       static __forceinline void intersect( | 
| 87 |           const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 88 |       { | 
| 89 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 90 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 91 |         Vec4vf<M> v0; Disc.gather(v0, geom); | 
| 92 |         const vbool<M> valid = Disc.valid(); | 
| 93 |         DiscIntersectorK<M, K>::intersect( | 
| 94 |             valid, ray, k, context, geom, pre, v0, | 
| 95 |             Intersect1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 96 |       } | 
| 97 |  | 
| 98 |       static __forceinline bool occluded( | 
| 99 |           const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 100 |       { | 
| 101 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 102 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 103 |         Vec4vf<M> v0; Disc.gather(v0, geom); | 
| 104 |         const vbool<M> valid = Disc.valid(); | 
| 105 |         return DiscIntersectorK<M, K>::intersect( | 
| 106 |           valid, ray, k, context, geom, pre, v0, | 
| 107 |           Occluded1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 108 |       } | 
| 109 |     }; | 
| 110 |  | 
| 111 |     template<int M, int K, bool filter> | 
| 112 |     struct DiscMiMBIntersectorK | 
| 113 |     { | 
| 114 |       typedef PointMi<M> Primitive; | 
| 115 |       typedef CurvePrecalculationsK<K> Precalculations; | 
| 116 |  | 
| 117 |       static __forceinline void intersect( | 
| 118 |           const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 119 |       { | 
| 120 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 121 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 122 |         Vec4vf<M> v0; Disc.gather(v0, geom, ray.time()[k]); | 
| 123 |         const vbool<M> valid = Disc.valid(); | 
| 124 |         DiscIntersectorK<M, K>::intersect( | 
| 125 |           valid, ray, k, context, geom, pre, v0, | 
| 126 |           Intersect1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 127 |       } | 
| 128 |  | 
| 129 |       static __forceinline bool occluded( | 
| 130 |           const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 131 |       { | 
| 132 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 133 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 134 |         Vec4vf<M> v0; Disc.gather(v0, geom, ray.time()[k]); | 
| 135 |         const vbool<M> valid = Disc.valid(); | 
| 136 |         return DiscIntersectorK<M, K>::intersect( | 
| 137 |           valid, ray, k, context, geom, pre, v0, Occluded1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 138 |       } | 
| 139 |     }; | 
| 140 |  | 
| 141 |     template<int M, bool filter> | 
| 142 |     struct OrientedDiscMiIntersector1 | 
| 143 |     { | 
| 144 |       typedef PointMi<M> Primitive; | 
| 145 |       typedef CurvePrecalculations1 Precalculations; | 
| 146 |  | 
| 147 |       static __forceinline void intersect(const Precalculations& pre, | 
| 148 |                                           RayHit& ray, | 
| 149 |                                           IntersectContext* context, | 
| 150 |                                           const Primitive& Disc) | 
| 151 |       { | 
| 152 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 153 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 154 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 155 |         Disc.gather(v0, n0, geom); | 
| 156 |         const vbool<M> valid = Disc.valid(); | 
| 157 |         DiscIntersector1<M>::intersect( | 
| 158 |           valid, ray, context, geom, pre, v0, n0, Intersect1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 159 |       } | 
| 160 |  | 
| 161 |       static __forceinline bool occluded(const Precalculations& pre, | 
| 162 |                                          Ray& ray, | 
| 163 |                                          IntersectContext* context, | 
| 164 |                                          const Primitive& Disc) | 
| 165 |       { | 
| 166 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 167 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 168 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 169 |         Disc.gather(v0, n0, geom); | 
| 170 |         const vbool<M> valid = Disc.valid(); | 
| 171 |         return DiscIntersector1<M>::intersect( | 
| 172 |           valid, ray, context, geom, pre, v0, n0, Occluded1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 173 |       } | 
| 174 |     }; | 
| 175 |  | 
| 176 |     template<int M, bool filter> | 
| 177 |     struct OrientedDiscMiMBIntersector1 | 
| 178 |     { | 
| 179 |       typedef PointMi<M> Primitive; | 
| 180 |       typedef CurvePrecalculations1 Precalculations; | 
| 181 |  | 
| 182 |       static __forceinline void intersect(const Precalculations& pre, | 
| 183 |                                           RayHit& ray, | 
| 184 |                                           IntersectContext* context, | 
| 185 |                                           const Primitive& Disc) | 
| 186 |       { | 
| 187 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 188 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 189 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 190 |         Disc.gather(v0, n0, geom, ray.time()); | 
| 191 |         const vbool<M> valid = Disc.valid(); | 
| 192 |         DiscIntersector1<M>::intersect( | 
| 193 |           valid, ray, context, geom, pre, v0, n0, Intersect1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 194 |       } | 
| 195 |  | 
| 196 |       static __forceinline bool occluded(const Precalculations& pre, | 
| 197 |                                          Ray& ray, | 
| 198 |                                          IntersectContext* context, | 
| 199 |                                          const Primitive& Disc) | 
| 200 |       { | 
| 201 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 202 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 203 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 204 |         Disc.gather(v0, n0, geom, ray.time()); | 
| 205 |         const vbool<M> valid = Disc.valid(); | 
| 206 |         return DiscIntersector1<M>::intersect( | 
| 207 |           valid, ray, context, geom, pre, v0, n0, Occluded1EpilogM<M, filter>(ray, context, Disc.geomID(), Disc.primID())); | 
| 208 |       } | 
| 209 |     }; | 
| 210 |  | 
| 211 |     template<int M, int K, bool filter> | 
| 212 |     struct OrientedDiscMiIntersectorK | 
| 213 |     { | 
| 214 |       typedef PointMi<M> Primitive; | 
| 215 |       typedef CurvePrecalculationsK<K> Precalculations; | 
| 216 |  | 
| 217 |       static __forceinline void intersect( | 
| 218 |           const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 219 |       { | 
| 220 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 221 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 222 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 223 |         Disc.gather(v0, n0, geom); | 
| 224 |         const vbool<M> valid = Disc.valid(); | 
| 225 |         DiscIntersectorK<M, K>::intersect( | 
| 226 |             valid, ray, k, context, geom, pre, v0, n0, | 
| 227 |             Intersect1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 228 |       } | 
| 229 |  | 
| 230 |       static __forceinline bool occluded( | 
| 231 |           const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 232 |       { | 
| 233 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 234 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 235 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 236 |         Disc.gather(v0, n0, geom); | 
| 237 |         const vbool<M> valid = Disc.valid(); | 
| 238 |         return DiscIntersectorK<M, K>::intersect( | 
| 239 |             valid, ray, k, context, geom, pre, v0, n0, | 
| 240 |             Occluded1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 241 |       } | 
| 242 |     }; | 
| 243 |  | 
| 244 |     template<int M, int K, bool filter> | 
| 245 |     struct OrientedDiscMiMBIntersectorK | 
| 246 |     { | 
| 247 |       typedef PointMi<M> Primitive; | 
| 248 |       typedef CurvePrecalculationsK<K> Precalculations; | 
| 249 |  | 
| 250 |       static __forceinline void intersect( | 
| 251 |           const Precalculations& pre, RayHitK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 252 |       { | 
| 253 |         STAT3(normal.trav_prims, 1, 1, 1); | 
| 254 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 255 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 256 |         Disc.gather(v0, n0, geom, ray.time()[k]); | 
| 257 |         const vbool<M> valid = Disc.valid(); | 
| 258 |         DiscIntersectorK<M, K>::intersect( | 
| 259 |             valid, ray, k, context, geom, pre, v0, n0, | 
| 260 |             Intersect1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 261 |       } | 
| 262 |  | 
| 263 |       static __forceinline bool occluded( | 
| 264 |           const Precalculations& pre, RayK<K>& ray, size_t k, IntersectContext* context, const Primitive& Disc) | 
| 265 |       { | 
| 266 |         STAT3(shadow.trav_prims, 1, 1, 1); | 
| 267 |         const Points* geom = context->scene->get<Points>(Disc.geomID()); | 
| 268 |         Vec4vf<M> v0; Vec3vf<M> n0; | 
| 269 |         Disc.gather(v0, n0, geom, ray.time()[k]); | 
| 270 |         const vbool<M> valid = Disc.valid(); | 
| 271 |         return DiscIntersectorK<M, K>::intersect( | 
| 272 |             valid, ray, k, context, geom, pre, v0, n0, | 
| 273 |             Occluded1KEpilogM<M, K, filter>(ray, k, context, Disc.geomID(), Disc.primID())); | 
| 274 |       } | 
| 275 |     }; | 
| 276 |   }  // namespace isa | 
| 277 | }  // namespace embree | 
| 278 |  |