From 5a934e3611d9f171d61b73cfc1d2fa4954574e7e Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sun, 3 Dec 2023 22:27:08 +1300 Subject: [PATCH] Update cord-simd implementation to fix nightly. --- codegen/templates/coresimd.rs.tera | 62 ++++---- codegen/templates/mat.rs.tera | 34 ++-- codegen/templates/vec.rs.tera | 2 +- src/coresimd.rs | 2 +- src/f32/coresimd/mat2.rs | 8 +- src/f32/coresimd/mat3a.rs | 32 +--- src/f32/coresimd/mat4.rs | 240 ++++++----------------------- src/f32/coresimd/vec3a.rs | 2 +- src/f32/coresimd/vec4.rs | 2 +- 9 files changed, 108 insertions(+), 276 deletions(-) diff --git a/codegen/templates/coresimd.rs.tera b/codegen/templates/coresimd.rs.tera index 961a2565..c1f2fd3a 100644 --- a/codegen/templates/coresimd.rs.tera +++ b/codegen/templates/coresimd.rs.tera @@ -4,25 +4,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let mul00 = swp00 * swp01; @@ -33,25 +33,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let mul00 = swp00 * swp01; @@ -62,25 +62,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let mul00 = swp00 * swp01; @@ -91,25 +91,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let mul00 = swp00 * swp01; @@ -120,25 +120,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let mul00 = swp00 * swp01; @@ -149,25 +149,25 @@ let swp0a = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let swp0b = simd_swizzle!( self.w_axis.0, self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp00 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); let swp03 = simd_swizzle!( self.z_axis.0, self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let mul00 = swp00 * swp01; @@ -180,28 +180,28 @@ let temp0 = simd_swizzle!( self.y_axis.0, self.x_axis.0, - [First(0), First(0), Second(0), Second(0)] + [0, 0, 4, 4] ); let vec0 = simd_swizzle!(temp0, [0, 2, 2, 2]); let temp1 = simd_swizzle!( self.y_axis.0, self.x_axis.0, - [First(1), First(1), Second(1), Second(1)] + [1, 1, 5, 5] ); let vec1 = simd_swizzle!(temp1, [0, 2, 2, 2]); let temp2 = simd_swizzle!( self.y_axis.0, self.x_axis.0, - [First(2), First(2), Second(2), Second(2)] + [2, 2, 6, 6] ); let vec2 = simd_swizzle!(temp2, [0, 2, 2, 2]); let temp3 = simd_swizzle!( self.y_axis.0, self.x_axis.0, - [First(3), First(3), Second(3), Second(3)] + [3, 3, 7, 7] ); let vec3 = simd_swizzle!(temp3, [0, 2, 2, 2]); @@ -233,9 +233,9 @@ let add03 = sub03 + mul11; let inv3 = sign_a * add03; - let row0 = simd_swizzle!(inv0, inv1, [First(0), First(0), Second(0), Second(0)]); - let row1 = simd_swizzle!(inv2, inv3, [First(0), First(0), Second(0), Second(0)]); - let row2 = simd_swizzle!(row0, row1, [First(0), First(2), Second(0), Second(2)]); + let row0 = simd_swizzle!(inv0, inv1, [0, 0, 4, 4]); + let row1 = simd_swizzle!(inv2, inv3, [0, 0, 4, 4]); + let row2 = simd_swizzle!(row0, row1, [0, 2, 4, 6]); let dot0 = dot4(self.x_axis.0, row2); glam_assert!(dot0 != 0.0); diff --git a/codegen/templates/mat.rs.tera b/codegen/templates/mat.rs.tera index 818c50ac..36d9516e 100644 --- a/codegen/templates/mat.rs.tera +++ b/codegen/templates/mat.rs.tera @@ -108,7 +108,7 @@ use core::arch::x86_64::*; {% elif is_wasm32 %} use core::arch::wasm32::*; {% elif is_coresimd %} -use core::simd::{Which::*, *}; +use core::simd::*; {% endif %} {% if self_t == "Mat2" and is_sse2 %} @@ -1017,29 +1017,29 @@ impl {{ self_t }} { let tmp0 = simd_swizzle!( self.x_axis.0, self.y_axis.0, - [First(0), First(1), Second(0), Second(1)] + [0, 1, 4, 5] ); let tmp1 = simd_swizzle!( self.x_axis.0, self.y_axis.0, - [First(2), First(3), Second(2), Second(3)] + [2, 3, 6, 7] ); Self { x_axis: Vec3A(simd_swizzle!( tmp0, self.z_axis.0, - [First(0), First(2), Second(0), Second(0)] + [0, 2, 4, 4] )), y_axis: Vec3A(simd_swizzle!( tmp0, self.z_axis.0, - [First(1), First(3), Second(1), Second(1)] + [1, 3, 5, 5] )), z_axis: Vec3A(simd_swizzle!( tmp1, self.z_axis.0, - [First(0), First(2), Second(2), Second(2)] + [0, 2, 6, 6] )), } {% elif self_t == "Mat4" and is_sse2 %} @@ -1075,29 +1075,29 @@ impl {{ self_t }} { let tmp0 = simd_swizzle!( self.x_axis.0, self.y_axis.0, - [First(0), First(1), Second(0), Second(1)] + [0, 1, 4, 5] ); let tmp1 = simd_swizzle!( self.x_axis.0, self.y_axis.0, - [First(2), First(3), Second(2), Second(3)] + [2, 3, 6, 7] ); let tmp2 = simd_swizzle!( self.z_axis.0, self.w_axis.0, - [First(0), First(1), Second(0), Second(1)] + [0, 1, 4, 5] ); let tmp3 = simd_swizzle!( self.z_axis.0, self.w_axis.0, - [First(2), First(3), Second(2), Second(3)] + [2, 3, 6, 7] ); Self { - x_axis: Vec4(simd_swizzle!(tmp0, tmp2, [First(0), First(2), Second(0), Second(2)])), - y_axis: Vec4(simd_swizzle!(tmp0, tmp2, [First(1), First(3), Second(1), Second(3)])), - z_axis: Vec4(simd_swizzle!(tmp1, tmp3, [First(0), First(2), Second(0), Second(2)])), - w_axis: Vec4(simd_swizzle!(tmp1, tmp3, [First(1), First(3), Second(1), Second(3)])), + x_axis: Vec4(simd_swizzle!(tmp0, tmp2, [0, 2, 4, 6])), + y_axis: Vec4(simd_swizzle!(tmp0, tmp2, [1, 3, 5, 7])), + z_axis: Vec4(simd_swizzle!(tmp1, tmp3, [0, 2, 4, 6])), + w_axis: Vec4(simd_swizzle!(tmp1, tmp3, [1, 3, 5, 7])), } {% else %} Self { @@ -1226,13 +1226,13 @@ impl {{ self_t }} { let swpfaca = simd_swizzle!(self.y_axis.0, [1, 0, 0, 0]); let mulfaca = swpfaca * subfaca; - let subtmpb = simd_swizzle!(sube, subf, [First(1), First(3), Second(0), Second(0)]); + let subtmpb = simd_swizzle!(sube, subf, [1, 3, 4, 4]); let subfacb = simd_swizzle!(subtmpb, [0, 1, 1, 3]); let swpfacb = simd_swizzle!(self.y_axis.0, [2, 2, 1, 1]); let mulfacb = swpfacb * subfacb; let subres = mulfaca - mulfacb; - let subtmpc = simd_swizzle!(sube, subf, [First(2), First(2), Second(0), Second(1)]); + let subtmpc = simd_swizzle!(sube, subf, [2, 2, 4, 5]); let subfacc = simd_swizzle!(subtmpc, [0, 2, 3, 3]); let swpfacc = simd_swizzle!(self.y_axis.0, [3, 3, 3, 2]); let mulfacc = swpfacc * subfacc; @@ -1933,7 +1933,7 @@ impl {{ self_t }} { let cydyaxbx1 = simd_swizzle!(axbxcydy1, [2, 3, 0, 1]); let result0 = axbxcydy0 + cydyaxbx0; let result1 = axbxcydy1 + cydyaxbx1; - Self(simd_swizzle!(result0, result1, [First(0), First(1), Second(0), Second(1)])) + Self(simd_swizzle!(result0, result1, [0, 1, 4, 5])) {% else %} Self::from_cols( {% for axis in axes %} diff --git a/codegen/templates/vec.rs.tera b/codegen/templates/vec.rs.tera index a783b86c..6938f557 100644 --- a/codegen/templates/vec.rs.tera +++ b/codegen/templates/vec.rs.tera @@ -169,7 +169,7 @@ use core::arch::x86_64::*; {% elif is_wasm32 %} use core::arch::wasm32::*; {% elif is_coresimd %} -use core::simd::*; +use core::simd::{cmp::SimdPartialEq, cmp::SimdPartialOrd, num::SimdFloat, *}; use std::simd::StdFloat; {% endif %} diff --git a/src/coresimd.rs b/src/coresimd.rs index c6a87d5f..a6401ef5 100644 --- a/src/coresimd.rs +++ b/src/coresimd.rs @@ -1,4 +1,4 @@ -use core::simd::*; +use core::simd::{num::SimdFloat, *}; /// Calculates the vector 3 dot product and returns answer in x lane of f32x4. #[inline(always)] diff --git a/src/f32/coresimd/mat2.rs b/src/f32/coresimd/mat2.rs index 030b74d7..98d235ba 100644 --- a/src/f32/coresimd/mat2.rs +++ b/src/f32/coresimd/mat2.rs @@ -6,7 +6,7 @@ use core::fmt; use core::iter::{Product, Sum}; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use core::simd::{Which::*, *}; +use core::simd::*; /// Creates a 2x2 matrix from two column vectors. #[inline(always)] @@ -249,11 +249,7 @@ impl Mat2 { let cydyaxbx1 = simd_swizzle!(axbxcydy1, [2, 3, 0, 1]); let result0 = axbxcydy0 + cydyaxbx0; let result1 = axbxcydy1 + cydyaxbx1; - Self(simd_swizzle!( - result0, - result1, - [First(0), First(1), Second(0), Second(1)] - )) + Self(simd_swizzle!(result0, result1, [0, 1, 4, 5])) } /// Adds two 2x2 matrices. diff --git a/src/f32/coresimd/mat3a.rs b/src/f32/coresimd/mat3a.rs index a59ee706..49028abd 100644 --- a/src/f32/coresimd/mat3a.rs +++ b/src/f32/coresimd/mat3a.rs @@ -6,7 +6,7 @@ use core::fmt; use core::iter::{Product, Sum}; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use core::simd::{Which::*, *}; +use core::simd::*; /// Creates a 3x3 matrix from three column vectors. #[inline(always)] @@ -405,33 +405,13 @@ impl Mat3A { #[must_use] #[inline] pub fn transpose(&self) -> Self { - let tmp0 = simd_swizzle!( - self.x_axis.0, - self.y_axis.0, - [First(0), First(1), Second(0), Second(1)] - ); - let tmp1 = simd_swizzle!( - self.x_axis.0, - self.y_axis.0, - [First(2), First(3), Second(2), Second(3)] - ); + let tmp0 = simd_swizzle!(self.x_axis.0, self.y_axis.0, [0, 1, 4, 5]); + let tmp1 = simd_swizzle!(self.x_axis.0, self.y_axis.0, [2, 3, 6, 7]); Self { - x_axis: Vec3A(simd_swizzle!( - tmp0, - self.z_axis.0, - [First(0), First(2), Second(0), Second(0)] - )), - y_axis: Vec3A(simd_swizzle!( - tmp0, - self.z_axis.0, - [First(1), First(3), Second(1), Second(1)] - )), - z_axis: Vec3A(simd_swizzle!( - tmp1, - self.z_axis.0, - [First(0), First(2), Second(2), Second(2)] - )), + x_axis: Vec3A(simd_swizzle!(tmp0, self.z_axis.0, [0, 2, 4, 4])), + y_axis: Vec3A(simd_swizzle!(tmp0, self.z_axis.0, [1, 3, 5, 5])), + z_axis: Vec3A(simd_swizzle!(tmp1, self.z_axis.0, [0, 2, 6, 6])), } } diff --git a/src/f32/coresimd/mat4.rs b/src/f32/coresimd/mat4.rs index 968b2bf2..bc6a1582 100644 --- a/src/f32/coresimd/mat4.rs +++ b/src/f32/coresimd/mat4.rs @@ -8,7 +8,7 @@ use core::fmt; use core::iter::{Product, Sum}; use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use core::simd::{Which::*, *}; +use core::simd::*; /// Creates a 4x4 matrix from four column vectors. #[inline(always)] @@ -544,48 +544,16 @@ impl Mat4 { #[inline] pub fn transpose(&self) -> Self { // Based on https://github.com/microsoft/DirectXMath `XMMatrixTranspose` - let tmp0 = simd_swizzle!( - self.x_axis.0, - self.y_axis.0, - [First(0), First(1), Second(0), Second(1)] - ); - let tmp1 = simd_swizzle!( - self.x_axis.0, - self.y_axis.0, - [First(2), First(3), Second(2), Second(3)] - ); - let tmp2 = simd_swizzle!( - self.z_axis.0, - self.w_axis.0, - [First(0), First(1), Second(0), Second(1)] - ); - let tmp3 = simd_swizzle!( - self.z_axis.0, - self.w_axis.0, - [First(2), First(3), Second(2), Second(3)] - ); + let tmp0 = simd_swizzle!(self.x_axis.0, self.y_axis.0, [0, 1, 4, 5]); + let tmp1 = simd_swizzle!(self.x_axis.0, self.y_axis.0, [2, 3, 6, 7]); + let tmp2 = simd_swizzle!(self.z_axis.0, self.w_axis.0, [0, 1, 4, 5]); + let tmp3 = simd_swizzle!(self.z_axis.0, self.w_axis.0, [2, 3, 6, 7]); Self { - x_axis: Vec4(simd_swizzle!( - tmp0, - tmp2, - [First(0), First(2), Second(0), Second(2)] - )), - y_axis: Vec4(simd_swizzle!( - tmp0, - tmp2, - [First(1), First(3), Second(1), Second(3)] - )), - z_axis: Vec4(simd_swizzle!( - tmp1, - tmp3, - [First(0), First(2), Second(0), Second(2)] - )), - w_axis: Vec4(simd_swizzle!( - tmp1, - tmp3, - [First(1), First(3), Second(1), Second(3)] - )), + x_axis: Vec4(simd_swizzle!(tmp0, tmp2, [0, 2, 4, 6])), + y_axis: Vec4(simd_swizzle!(tmp0, tmp2, [1, 3, 5, 7])), + z_axis: Vec4(simd_swizzle!(tmp1, tmp3, [0, 2, 4, 6])), + w_axis: Vec4(simd_swizzle!(tmp1, tmp3, [1, 3, 5, 7])), } } @@ -609,13 +577,13 @@ impl Mat4 { let swpfaca = simd_swizzle!(self.y_axis.0, [1, 0, 0, 0]); let mulfaca = swpfaca * subfaca; - let subtmpb = simd_swizzle!(sube, subf, [First(1), First(3), Second(0), Second(0)]); + let subtmpb = simd_swizzle!(sube, subf, [1, 3, 4, 4]); let subfacb = simd_swizzle!(subtmpb, [0, 1, 1, 3]); let swpfacb = simd_swizzle!(self.y_axis.0, [2, 2, 1, 1]); let mulfacb = swpfacb * subfacb; let subres = mulfaca - mulfacb; - let subtmpc = simd_swizzle!(sube, subf, [First(2), First(2), Second(0), Second(1)]); + let subtmpc = simd_swizzle!(sube, subf, [2, 2, 4, 5]); let subfacc = simd_swizzle!(subtmpc, [0, 2, 3, 3]); let swpfacc = simd_swizzle!(self.y_axis.0, [3, 3, 3, 2]); let mulfacc = swpfacc * subfacc; @@ -637,174 +605,78 @@ impl Mat4 { pub fn inverse(&self) -> Self { // Based on https://github.com/g-truc/glm `glm_mat4_inverse` let fac0 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [3, 3, 7, 7]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [2, 2, 6, 6]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [2, 2, 6, 6]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [3, 3, 7, 7]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; mul00 - mul01 }; let fac1 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [3, 3, 7, 7]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [1, 1, 5, 5]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [1, 1, 5, 5]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [3, 3, 7, 7]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; mul00 - mul01 }; let fac2 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [2, 2, 6, 6]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [1, 1, 5, 5]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [1, 1, 5, 5]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [2, 2, 6, 6]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; mul00 - mul01 }; let fac3 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [3, 3, 7, 7]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [0, 0, 4, 4]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [0, 0, 4, 4]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [3, 3, 7, 7]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; mul00 - mul01 }; let fac4 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [2, 2, 6, 6]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [0, 0, 4, 4]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [0, 0, 4, 4]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [2, 2, 6, 6]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; mul00 - mul01 }; let fac5 = { - let swp0a = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); - let swp0b = simd_swizzle!( - self.w_axis.0, - self.z_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); - - let swp00 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); + let swp0a = simd_swizzle!(self.w_axis.0, self.z_axis.0, [1, 1, 5, 5]); + let swp0b = simd_swizzle!(self.w_axis.0, self.z_axis.0, [0, 0, 4, 4]); + + let swp00 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [0, 0, 4, 4]); let swp01 = simd_swizzle!(swp0a, [0, 0, 0, 2]); let swp02 = simd_swizzle!(swp0b, [0, 0, 0, 2]); - let swp03 = simd_swizzle!( - self.z_axis.0, - self.y_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); + let swp03 = simd_swizzle!(self.z_axis.0, self.y_axis.0, [1, 1, 5, 5]); let mul00 = swp00 * swp01; let mul01 = swp02 * swp03; @@ -813,32 +685,16 @@ impl Mat4 { let sign_a = f32x4::from_array([-1.0, 1.0, -1.0, 1.0]); let sign_b = f32x4::from_array([1.0, -1.0, 1.0, -1.0]); - let temp0 = simd_swizzle!( - self.y_axis.0, - self.x_axis.0, - [First(0), First(0), Second(0), Second(0)] - ); + let temp0 = simd_swizzle!(self.y_axis.0, self.x_axis.0, [0, 0, 4, 4]); let vec0 = simd_swizzle!(temp0, [0, 2, 2, 2]); - let temp1 = simd_swizzle!( - self.y_axis.0, - self.x_axis.0, - [First(1), First(1), Second(1), Second(1)] - ); + let temp1 = simd_swizzle!(self.y_axis.0, self.x_axis.0, [1, 1, 5, 5]); let vec1 = simd_swizzle!(temp1, [0, 2, 2, 2]); - let temp2 = simd_swizzle!( - self.y_axis.0, - self.x_axis.0, - [First(2), First(2), Second(2), Second(2)] - ); + let temp2 = simd_swizzle!(self.y_axis.0, self.x_axis.0, [2, 2, 6, 6]); let vec2 = simd_swizzle!(temp2, [0, 2, 2, 2]); - let temp3 = simd_swizzle!( - self.y_axis.0, - self.x_axis.0, - [First(3), First(3), Second(3), Second(3)] - ); + let temp3 = simd_swizzle!(self.y_axis.0, self.x_axis.0, [3, 3, 7, 7]); let vec3 = simd_swizzle!(temp3, [0, 2, 2, 2]); let mul00 = vec1 * fac0; @@ -869,9 +725,9 @@ impl Mat4 { let add03 = sub03 + mul11; let inv3 = sign_a * add03; - let row0 = simd_swizzle!(inv0, inv1, [First(0), First(0), Second(0), Second(0)]); - let row1 = simd_swizzle!(inv2, inv3, [First(0), First(0), Second(0), Second(0)]); - let row2 = simd_swizzle!(row0, row1, [First(0), First(2), Second(0), Second(2)]); + let row0 = simd_swizzle!(inv0, inv1, [0, 0, 4, 4]); + let row1 = simd_swizzle!(inv2, inv3, [0, 0, 4, 4]); + let row2 = simd_swizzle!(row0, row1, [0, 2, 4, 6]); let dot0 = dot4(self.x_axis.0, row2); glam_assert!(dot0 != 0.0); diff --git a/src/f32/coresimd/vec3a.rs b/src/f32/coresimd/vec3a.rs index 46141d8a..9f1cd509 100644 --- a/src/f32/coresimd/vec3a.rs +++ b/src/f32/coresimd/vec3a.rs @@ -7,7 +7,7 @@ use core::fmt; use core::iter::{Product, Sum}; use core::{f32, ops::*}; -use core::simd::*; +use core::simd::{cmp::SimdPartialEq, cmp::SimdPartialOrd, num::SimdFloat, *}; use std::simd::StdFloat; /// Creates a 3-dimensional vector. diff --git a/src/f32/coresimd/vec4.rs b/src/f32/coresimd/vec4.rs index 4057ec98..bbfa0d5a 100644 --- a/src/f32/coresimd/vec4.rs +++ b/src/f32/coresimd/vec4.rs @@ -7,7 +7,7 @@ use core::fmt; use core::iter::{Product, Sum}; use core::{f32, ops::*}; -use core::simd::*; +use core::simd::{cmp::SimdPartialEq, cmp::SimdPartialOrd, num::SimdFloat, *}; use std::simd::StdFloat; /// Creates a 4-dimensional vector.