Skip to content

Commit

Permalink
Simplify Swizzle trait and condense all swizzles into this trait
Browse files Browse the repository at this point in the history
  • Loading branch information
calebzulawski committed Oct 1, 2023
1 parent eb3c050 commit 06a1070
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 194 deletions.
9 changes: 4 additions & 5 deletions crates/core_simd/examples/matrix_inversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Run this code with `cargo test --example matrix_inversion`
#![feature(array_chunks, portable_simd)]
use core_simd::simd::*;
use Which::*;

// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
Expand Down Expand Up @@ -164,10 +163,10 @@ pub fn simd_inv4x4(m: Matrix4x4) -> Option<Matrix4x4> {
let m_2 = f32x4::from_array(m[2]);
let m_3 = f32x4::from_array(m[3]);

const SHUFFLE01: [Which; 4] = [First(0), First(1), Second(0), Second(1)];
const SHUFFLE02: [Which; 4] = [First(0), First(2), Second(0), Second(2)];
const SHUFFLE13: [Which; 4] = [First(1), First(3), Second(1), Second(3)];
const SHUFFLE23: [Which; 4] = [First(2), First(3), Second(2), Second(3)];
const SHUFFLE01: [usize; 4] = [0, 1, 4, 5];
const SHUFFLE02: [usize; 4] = [0, 2, 4, 6];
const SHUFFLE13: [usize; 4] = [1, 3, 5, 7];
const SHUFFLE23: [usize; 4] = [2, 3, 6, 7];

let tmp = simd_swizzle!(m_0, m_1, SHUFFLE01);
let row1 = simd_swizzle!(m_2, m_3, SHUFFLE01);
Expand Down
1 change: 1 addition & 0 deletions crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const_mut_refs,
convert_float_to_int,
decl_macro,
inline_const,
intra_doc_pointers,
platform_intrinsics,
repr_simd,
Expand Down
Loading

0 comments on commit 06a1070

Please sign in to comment.