1 | // Copyright 2009-2021 Intel Corporation |
---|---|
2 | // SPDX-License-Identifier: Apache-2.0 |
3 | |
4 | #pragma once |
5 | |
6 | #include "../common/ray.h" |
7 | #include "../common/geometry.h" |
8 | |
9 | namespace embree |
10 | { |
11 | namespace isa |
12 | { |
13 | struct CurvePrecalculations1 |
14 | { |
15 | float depth_scale; |
16 | LinearSpace3fa ray_space; |
17 | |
18 | __forceinline CurvePrecalculations1() {} |
19 | |
20 | __forceinline CurvePrecalculations1(const Ray& ray, const void* ptr) |
21 | { |
22 | depth_scale = rsqrt(x: dot(a: ray.dir,b: ray.dir)); |
23 | LinearSpace3fa space = frame(N: depth_scale*ray.dir); |
24 | space.vz *= depth_scale; |
25 | ray_space = space.transposed(); |
26 | } |
27 | }; |
28 | |
29 | template<int K> |
30 | struct CurvePrecalculationsK |
31 | { |
32 | vfloat<K> depth_scale; |
33 | LinearSpace3fa ray_space[K]; |
34 | |
35 | __forceinline CurvePrecalculationsK(const vbool<K>& valid, const RayK<K>& ray) |
36 | { |
37 | size_t mask = movemask(valid); |
38 | depth_scale = rsqrt(dot(ray.dir,ray.dir)); |
39 | while (mask) { |
40 | size_t k = bscf(v&: mask); |
41 | Vec3fa ray_dir_k = Vec3fa(ray.dir.x[k],ray.dir.y[k],ray.dir.z[k]); |
42 | LinearSpace3fa ray_space_k = frame(depth_scale[k]*ray_dir_k); |
43 | ray_space_k.vz *= depth_scale[k]; |
44 | ray_space[k] = ray_space_k.transposed(); |
45 | } |
46 | } |
47 | }; |
48 | } |
49 | } |
50 |