|
7 | 7 | #include <xmmintrin.h> |
8 | 8 | #pragma warning(pop) |
9 | 9 |
|
10 | | -// can you say "barebone"? |
11 | | -#ifndef _MM_ALIGN16 |
12 | | -#define _MM_ALIGN16 __declspec(align(16)) |
13 | | -#endif // _MM_ALIGN16 |
14 | | - |
15 | | -struct _MM_ALIGN16 vec_t : public Fvector3 |
| 10 | +struct alignas(16) vec_t : public Fvector3 |
16 | 11 | { |
17 | 12 | float pad; |
18 | 13 | }; |
19 | 14 | // static vec_t vec_c ( float _x, float _y, float _z) { vec_t v; v.x=_x;v.y=_y;v.z=_z;v.pad=0; return v; } |
20 | 15 |
|
21 | | -struct _MM_ALIGN16 aabb_t |
| 16 | +struct alignas(16) aabb_t |
22 | 17 | { |
23 | 18 | vec_t min; |
24 | 19 | vec_t max; |
25 | 20 | }; |
26 | | -struct _MM_ALIGN16 ray_t |
| 21 | +struct alignas(16) ray_t |
27 | 22 | { |
28 | 23 | vec_t pos; |
29 | 24 | vec_t inv_dir; |
@@ -148,16 +143,16 @@ ICF BOOL isect_fpu(const Fvector& min, const Fvector& max, const ray_t& ray, Fve |
148 | 143 | #define rotatelps(ps) _mm_shuffle_ps((ps), (ps), 0x39) // a,b,c,d -> b,c,d,a |
149 | 144 | #define muxhps(low, high) _mm_movehl_ps((low), (high)) // low{a,b,c,d}|high{e,f,g,h} = {c,d,g,h} |
150 | 145 |
|
151 | | -static const float flt_plus_inf = -logf(0); // let's keep C and C++ compilers happy. |
152 | | -static const float _MM_ALIGN16 ps_cst_plus_inf[4] = {flt_plus_inf, flt_plus_inf, flt_plus_inf, flt_plus_inf}, |
153 | | - ps_cst_minus_inf[4] = {-flt_plus_inf, -flt_plus_inf, -flt_plus_inf, -flt_plus_inf}; |
| 146 | +static constexpr auto flt_plus_inf = std::numeric_limits<float>::infinity(); |
| 147 | +alignas(16) static constexpr float ps_cst_plus_inf[4] = { flt_plus_inf, flt_plus_inf, flt_plus_inf, flt_plus_inf }, |
| 148 | + ps_cst_minus_inf[4] = { -flt_plus_inf, -flt_plus_inf, -flt_plus_inf, -flt_plus_inf }; |
154 | 149 |
|
155 | 150 | ICF BOOL isect_sse(const aabb_t& box, const ray_t& ray, float& dist) |
156 | 151 | { |
157 | 152 | // you may already have those values hanging around somewhere |
158 | 153 | const __m128 plus_inf = loadps(ps_cst_plus_inf), minus_inf = loadps(ps_cst_minus_inf); |
159 | 154 |
|
160 | | - // use whatever's apropriate to load. |
| 155 | + // use whatever's appropriate to load. |
161 | 156 | const __m128 box_min = loadps(&box.min), box_max = loadps(&box.max), pos = loadps(&ray.pos), |
162 | 157 | inv_dir = loadps(&ray.inv_dir); |
163 | 158 |
|
@@ -200,7 +195,7 @@ ICF BOOL isect_sse(const aabb_t& box, const ray_t& ray, float& dist) |
200 | 195 | extern Fvector c_spatial_offset[8]; |
201 | 196 |
|
202 | 197 | template <bool b_use_sse, bool b_first, bool b_nearest> |
203 | | -class _MM_ALIGN16 walker |
| 198 | +class alignas(16) walker |
204 | 199 | { |
205 | 200 | public: |
206 | 201 | ray_t ray; |
|
0 commit comments