| 1 | #if GLM_ARCH & GLM_ARCH_SSE2_BIT |
| 2 | |
| 3 | #include "type_mat4x4.hpp" |
| 4 | #include "../geometric.hpp" |
| 5 | #include "../simd/matrix.h" |
| 6 | #include <cstring> |
| 7 | |
| 8 | namespace glm{ |
| 9 | namespace detail |
| 10 | { |
| 11 | # if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE |
| 12 | template<qualifier Q> |
| 13 | struct compute_matrixCompMult<4, 4, float, Q, true> |
| 14 | { |
| 15 | GLM_STATIC_ASSERT(detail::is_aligned<Q>::value, "Specialization requires aligned"); |
| 16 | |
| 17 | GLM_FUNC_QUALIFIER static mat<4, 4, float, Q> call(mat<4, 4, float, Q> const& x, mat<4, 4, float, Q> const& y) |
| 18 | { |
| 19 | mat<4, 4, float, Q> Result; |
| 20 | glm_mat4_matrixCompMult( |
| 21 | *static_cast<glm_vec4 const (*)[4]>(&x[0].data), |
| 22 | *static_cast<glm_vec4 const (*)[4]>(&y[0].data), |
| 23 | *static_cast<glm_vec4(*)[4]>(&Result[0].data)); |
| 24 | return Result; |
| 25 | } |
| 26 | }; |
| 27 | # endif |
| 28 | |
| 29 | template<qualifier Q> |
| 30 | struct compute_transpose<4, 4, float, Q, true> |
| 31 | { |
| 32 | GLM_FUNC_QUALIFIER static mat<4, 4, float, Q> call(mat<4, 4, float, Q> const& m) |
| 33 | { |
| 34 | mat<4, 4, float, Q> Result; |
| 35 | glm_mat4_transpose(&m[0].data, &Result[0].data); |
| 36 | return Result; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | template<qualifier Q> |
| 41 | struct compute_determinant<4, 4, float, Q, true> |
| 42 | { |
| 43 | GLM_FUNC_QUALIFIER static float call(mat<4, 4, float, Q> const& m) |
| 44 | { |
| 45 | return _mm_cvtss_f32(glm_mat4_determinant(&m[0].data)); |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | template<qualifier Q> |
| 50 | struct compute_inverse<4, 4, float, Q, true> |
| 51 | { |
| 52 | GLM_FUNC_QUALIFIER static mat<4, 4, float, Q> call(mat<4, 4, float, Q> const& m) |
| 53 | { |
| 54 | mat<4, 4, float, Q> Result; |
| 55 | glm_mat4_inverse(&m[0].data, &Result[0].data); |
| 56 | return Result; |
| 57 | } |
| 58 | }; |
| 59 | }//namespace detail |
| 60 | |
| 61 | # if GLM_CONFIG_ALIGNED_GENTYPES == GLM_ENABLE |
| 62 | template<> |
| 63 | GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_lowp> outerProduct<4, 4, float, aligned_lowp>(vec<4, float, aligned_lowp> const& c, vec<4, float, aligned_lowp> const& r) |
| 64 | { |
| 65 | __m128 NativeResult[4]; |
| 66 | glm_mat4_outerProduct(c.data, r.data, NativeResult); |
| 67 | mat<4, 4, float, aligned_lowp> Result; |
| 68 | std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); |
| 69 | return Result; |
| 70 | } |
| 71 | |
| 72 | template<> |
| 73 | GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_mediump> outerProduct<4, 4, float, aligned_mediump>(vec<4, float, aligned_mediump> const& c, vec<4, float, aligned_mediump> const& r) |
| 74 | { |
| 75 | __m128 NativeResult[4]; |
| 76 | glm_mat4_outerProduct(c.data, r.data, NativeResult); |
| 77 | mat<4, 4, float, aligned_mediump> Result; |
| 78 | std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); |
| 79 | return Result; |
| 80 | } |
| 81 | |
| 82 | template<> |
| 83 | GLM_FUNC_QUALIFIER mat<4, 4, float, aligned_highp> outerProduct<4, 4, float, aligned_highp>(vec<4, float, aligned_highp> const& c, vec<4, float, aligned_highp> const& r) |
| 84 | { |
| 85 | __m128 NativeResult[4]; |
| 86 | glm_mat4_outerProduct(c.data, r.data, NativeResult); |
| 87 | mat<4, 4, float, aligned_highp> Result; |
| 88 | std::memcpy(&Result[0], &NativeResult[0], sizeof(Result)); |
| 89 | return Result; |
| 90 | } |
| 91 | # endif |
| 92 | }//namespace glm |
| 93 | |
| 94 | #endif |