aboutsummaryrefslogtreecommitdiff
path: root/src/bool/sse2/bvec3a.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bool/sse2/bvec3a.rs')
-rw-r--r--src/bool/sse2/bvec3a.rs36
1 files changed, 2 insertions, 34 deletions
diff --git a/src/bool/sse2/bvec3a.rs b/src/bool/sse2/bvec3a.rs
index 0ac65a5..0fdbdf6 100644
--- a/src/bool/sse2/bvec3a.rs
+++ b/src/bool/sse2/bvec3a.rs
@@ -9,7 +9,6 @@ use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;
-#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec3A,
@@ -17,7 +16,8 @@ union UnionCast {
/// A 3-dimensional SIMD vector mask.
///
-/// This type is 16 byte aligned.
+/// This type is 16 byte aligned and is backed by a SIMD vector. If SIMD is not available
+/// `BVec3A` will be a type alias for `BVec3`.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec3A(pub(crate) __m128);
@@ -33,7 +33,6 @@ impl BVec3A {
/// Creates a new vector mask.
#[inline(always)]
- #[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
unsafe {
UnionCast {
@@ -45,7 +44,6 @@ impl BVec3A {
/// Creates a vector with all elements set to `v`.
#[inline]
- #[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
@@ -55,59 +53,29 @@ impl BVec3A {
/// A true element results in a `1` bit and a false element in a `0` bit. Element `x` goes
/// into the first lowest bit, element `y` into the second, etc.
#[inline]
- #[must_use]
pub fn bitmask(self) -> u32 {
unsafe { (_mm_movemask_ps(self.0) as u32) & 0x7 }
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
- #[must_use]
pub fn any(self) -> bool {
self.bitmask() != 0
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
- #[must_use]
pub fn all(self) -> bool {
self.bitmask() == 0x7
}
- /// Tests the value at `index`.
- ///
- /// Panics if `index` is greater than 2.
- #[inline]
- #[must_use]
- pub fn test(&self, index: usize) -> bool {
- match index {
- 0 => (self.bitmask() & (1 << 0)) != 0,
- 1 => (self.bitmask() & (1 << 1)) != 0,
- 2 => (self.bitmask() & (1 << 2)) != 0,
- _ => panic!("index out of bounds"),
- }
- }
-
- /// Sets the element at `index`.
- ///
- /// Panics if `index` is greater than 2.
- #[inline]
- pub fn set(&mut self, index: usize, value: bool) {
- use crate::Vec3A;
- let mut v = Vec3A(self.0);
- v[index] = f32::from_bits(MASK[value as usize]);
- *self = Self(v.0);
- }
-
#[inline]
- #[must_use]
fn into_bool_array(self) -> [bool; 3] {
let bitmask = self.bitmask();
[(bitmask & 1) != 0, (bitmask & 2) != 0, (bitmask & 4) != 0]
}
#[inline]
- #[must_use]
fn into_u32_array(self) -> [u32; 3] {
let bitmask = self.bitmask();
[