Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

218
vendor/glam/src/bool/bvec2.rs vendored Normal file
View File

@@ -0,0 +1,218 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
/// Creates a 2-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec2(x: bool, y: bool) -> BVec2 {
BVec2::new(x, y)
}
/// A 2-dimensional `bool` vector mask.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(1))]
pub struct BVec2 {
pub x: bool,
pub y: bool,
}
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec2 {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool) -> Self {
Self { x, y }
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 2]) -> Self {
Self::new(a[0], a[1])
}
/// Returns a bitmask with the lowest 2 bits set from the elements of `self`.
///
/// 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 {
(self.x as u32) | ((self.y as u32) << 1)
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn any(self) -> bool {
self.x || self.y
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn all(self) -> bool {
self.x && self.y
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 1.
#[inline]
#[must_use]
pub fn test(&self, index: usize) -> bool {
match index {
0 => self.x,
1 => self.y,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 1.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
match index {
0 => self.x = value,
1 => self.y = value,
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 2] {
[self.x, self.y]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 2] {
[MASK[self.x as usize], MASK[self.y as usize]]
}
}
impl Default for BVec2 {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl BitAnd for BVec2 {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self {
x: self.x & rhs.x,
y: self.y & rhs.y,
}
}
}
impl BitAndAssign for BVec2 {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec2 {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self {
x: self.x | rhs.x,
y: self.y | rhs.y,
}
}
}
impl BitOrAssign for BVec2 {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec2 {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self {
x: self.x ^ rhs.x,
y: self.y ^ rhs.y,
}
}
}
impl BitXorAssign for BVec2 {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec2 {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self {
x: !self.x,
y: !self.y,
}
}
}
impl fmt::Debug for BVec2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(f, "{}({:#x}, {:#x})", stringify!(BVec2), arr[0], arr[1])
}
}
impl fmt::Display for BVec2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}]", arr[0], arr[1])
}
}
impl From<[bool; 2]> for BVec2 {
#[inline]
fn from(a: [bool; 2]) -> Self {
Self::from_array(a)
}
}
impl From<BVec2> for [bool; 2] {
#[inline]
fn from(mask: BVec2) -> Self {
mask.into_bool_array()
}
}
impl From<BVec2> for [u32; 2] {
#[inline]
fn from(mask: BVec2) -> Self {
mask.into_u32_array()
}
}

236
vendor/glam/src/bool/bvec3.rs vendored Normal file
View File

@@ -0,0 +1,236 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3(x: bool, y: bool, z: bool) -> BVec3 {
BVec3::new(x, y, z)
}
/// A 3-dimensional `bool` vector mask.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(1))]
pub struct BVec3 {
pub x: bool,
pub y: bool,
pub z: bool,
}
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3 {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Self { x, y, z }
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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 {
(self.x as u32) | ((self.y as u32) << 1) | ((self.z as u32) << 2)
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn any(self) -> bool {
self.x || self.y || self.z
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn all(self) -> bool {
self.x && self.y && self.z
}
/// 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.x,
1 => self.y,
2 => self.z,
_ => 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) {
match index {
0 => self.x = value,
1 => self.y = value,
2 => self.z = value,
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 3] {
[self.x, self.y, self.z]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 3] {
[
MASK[self.x as usize],
MASK[self.y as usize],
MASK[self.z as usize],
]
}
}
impl Default for BVec3 {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl BitAnd for BVec3 {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self {
x: self.x & rhs.x,
y: self.y & rhs.y,
z: self.z & rhs.z,
}
}
}
impl BitAndAssign for BVec3 {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3 {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self {
x: self.x | rhs.x,
y: self.y | rhs.y,
z: self.z | rhs.z,
}
}
}
impl BitOrAssign for BVec3 {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3 {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self {
x: self.x ^ rhs.x,
y: self.y ^ rhs.y,
z: self.z ^ rhs.z,
}
}
}
impl BitXorAssign for BVec3 {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3 {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self {
x: !self.x,
y: !self.y,
z: !self.z,
}
}
}
impl fmt::Debug for BVec3 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3 {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3> for [bool; 3] {
#[inline]
fn from(mask: BVec3) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3> for [u32; 3] {
#[inline]
fn from(mask: BVec3) -> Self {
mask.into_u32_array()
}
}

245
vendor/glam/src/bool/bvec4.rs vendored Normal file
View File

@@ -0,0 +1,245 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4(x: bool, y: bool, z: bool, w: bool) -> BVec4 {
BVec4::new(x, y, z, w)
}
/// A 4-dimensional `bool` vector mask.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(1))]
pub struct BVec4 {
pub x: bool,
pub y: bool,
pub z: bool,
pub w: bool,
}
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4 {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Self { x, y, z, w }
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 {
(self.x as u32) | ((self.y as u32) << 1) | ((self.z as u32) << 2) | ((self.w as u32) << 3)
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn any(self) -> bool {
self.x || self.y || self.z || self.w
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn all(self) -> bool {
self.x && self.y && self.z && self.w
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
#[must_use]
pub fn test(&self, index: usize) -> bool {
match index {
0 => self.x,
1 => self.y,
2 => self.z,
3 => self.w,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
match index {
0 => self.x = value,
1 => self.y = value,
2 => self.z = value,
3 => self.w = value,
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
[self.x, self.y, self.z, self.w]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
[
MASK[self.x as usize],
MASK[self.y as usize],
MASK[self.z as usize],
MASK[self.w as usize],
]
}
}
impl Default for BVec4 {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl BitAnd for BVec4 {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self {
x: self.x & rhs.x,
y: self.y & rhs.y,
z: self.z & rhs.z,
w: self.w & rhs.w,
}
}
}
impl BitAndAssign for BVec4 {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4 {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self {
x: self.x | rhs.x,
y: self.y | rhs.y,
z: self.z | rhs.z,
w: self.w | rhs.w,
}
}
}
impl BitOrAssign for BVec4 {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4 {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self {
x: self.x ^ rhs.x,
y: self.y ^ rhs.y,
z: self.z ^ rhs.z,
w: self.w ^ rhs.w,
}
}
}
impl BitXorAssign for BVec4 {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4 {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self {
x: !self.x,
y: !self.y,
z: !self.z,
w: !self.w,
}
}
}
impl fmt::Debug for BVec4 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4 {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4> for [bool; 4] {
#[inline]
fn from(mask: BVec4) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4> for [u32; 4] {
#[inline]
fn from(mask: BVec4) -> Self {
mask.into_u32_array()
}
}

2
vendor/glam/src/bool/coresimd.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
pub mod bvec3a;
pub mod bvec4a;

246
vendor/glam/src/bool/coresimd/bvec3a.rs vendored Normal file
View File

@@ -0,0 +1,246 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::simd::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec3A,
}
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3a(x: bool, y: bool, z: bool) -> BVec3A {
BVec3A::new(x, y, z)
}
/// A 3-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec3A(pub(crate) mask32x4);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
unsafe {
UnionCast {
a: [MASK[x as usize], MASK[y as usize], MASK[z as usize], 0],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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 {
(self.0.to_bitmask() & 0x7) as u32
}
/// 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 {
self.0.test(index)
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 2.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
self.0.set(index, value)
}
#[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();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
]
}
}
impl Default for BVec3A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec3A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec3A {}
impl core::hash::Hash for BVec3A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec3A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl BitAndAssign for BVec3A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl BitOrAssign for BVec3A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(self.0 ^ rhs.0)
}
}
impl BitXorAssign for BVec3A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(!self.0)
}
}
impl From<BVec3A> for mask32x4 {
#[inline]
fn from(t: BVec3A) -> Self {
t.0
}
}
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3A),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3A {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3A> for [bool; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3A> for [u32; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_u32_array()
}
}

258
vendor/glam/src/bool/coresimd/bvec4a.rs vendored Normal file
View File

@@ -0,0 +1,258 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::simd::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec4A,
}
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4a(x: bool, y: bool, z: bool, w: bool) -> BVec4A {
BVec4A::new(x, y, z, w)
}
/// A 4-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec4A(pub(crate) mask32x4);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
unsafe {
UnionCast {
a: [
MASK[x as usize],
MASK[y as usize],
MASK[z as usize],
MASK[w as usize],
],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 {
self.0.to_bitmask() as u32
}
/// 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() == 0xf
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
#[must_use]
pub fn test(&self, index: usize) -> bool {
self.0.test(index)
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
self.0.set(index, value)
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
let bitmask = self.bitmask();
[
(bitmask & 1) != 0,
(bitmask & 2) != 0,
(bitmask & 4) != 0,
(bitmask & 8) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
let bitmask = self.bitmask();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
MASK[((bitmask >> 3) & 1) as usize],
]
}
}
impl Default for BVec4A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec4A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec4A {}
impl core::hash::Hash for BVec4A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec4A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl BitAndAssign for BVec4A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl BitOrAssign for BVec4A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(self.0 ^ rhs.0)
}
}
impl BitXorAssign for BVec4A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(!self.0)
}
}
impl From<BVec4A> for mask32x4 {
#[inline]
fn from(t: BVec4A) -> Self {
t.0
}
}
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4A),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4A {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4A> for [bool; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4A> for [u32; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_u32_array()
}
}

2
vendor/glam/src/bool/neon.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
pub mod bvec3a;
pub mod bvec4a;

265
vendor/glam/src/bool/neon/bvec3a.rs vendored Normal file
View File

@@ -0,0 +1,265 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::arch::aarch64::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec3A,
}
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3a(x: bool, y: bool, z: bool) -> BVec3A {
BVec3A::new(x, y, z)
}
/// A 3-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec3A(pub(crate) uint32x4_t);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
unsafe {
UnionCast {
a: [MASK[x as usize], MASK[y as usize], MASK[z as usize], 0],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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 {
let movemask = unsafe {
let mma = vandq_u32(self.0, vld1q_u32([1, 2, 4, 8].as_ptr())); // [0 1 2 3]
let mmb = vextq_u32(mma, mma, 2); // [2 3 0 1]
let mmc = vorrq_u32(mma, mmb); // [0+2 1+3 0+2 1+3]
let mmd = vextq_u32(mmc, mmc, 3); // [1+3 0+2 1+3 0+2]
let mme = vorrq_u32(mmc, mmd); // [0+1+2+3 ...]
vgetq_lane_u32(mme, 0)
};
movemask & 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) {
self.0 = match index {
0 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 0) },
1 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 1) },
2 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 2) },
_ => panic!("index out of bounds"),
}
}
#[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();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
]
}
}
impl Default for BVec3A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec3A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec3A {}
impl core::hash::Hash for BVec3A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec3A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(unsafe { vandq_u32(self.0, rhs.0) })
}
}
impl BitAndAssign for BVec3A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(unsafe { vorrq_u32(self.0, rhs.0) })
}
}
impl BitOrAssign for BVec3A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(unsafe { veorq_u32(self.0, rhs.0) })
}
}
impl BitXorAssign for BVec3A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(unsafe { vmvnq_u32(self.0) })
}
}
impl From<BVec3A> for uint32x4_t {
#[inline]
fn from(t: BVec3A) -> Self {
t.0
}
}
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3A),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3A {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3A> for [bool; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3A> for [u32; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_u32_array()
}
}

277
vendor/glam/src/bool/neon/bvec4a.rs vendored Normal file
View File

@@ -0,0 +1,277 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::arch::aarch64::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec4A,
}
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4a(x: bool, y: bool, z: bool, w: bool) -> BVec4A {
BVec4A::new(x, y, z, w)
}
/// A 4-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec4A(pub(crate) uint32x4_t);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
unsafe {
UnionCast {
a: [
MASK[x as usize],
MASK[y as usize],
MASK[z as usize],
MASK[w as usize],
],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 {
let mma = vandq_u32(self.0, vld1q_u32([1, 2, 4, 8].as_ptr())); // [0 1 2 3]
let mmb = vextq_u32(mma, mma, 2); // [2 3 0 1]
let mmc = vorrq_u32(mma, mmb); // [0+2 1+3 0+2 1+3]
let mmd = vextq_u32(mmc, mmc, 3); // [1+3 0+2 1+3 0+2]
let mme = vorrq_u32(mmc, mmd); // [0+1+2+3 ...]
vgetq_lane_u32(mme, 0)
}
}
/// 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() == 0xf
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[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,
3 => (self.bitmask() & (1 << 3)) != 0,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
self.0 = match index {
0 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 0) },
1 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 1) },
2 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 2) },
3 => unsafe { vsetq_lane_u32(MASK[value as usize], self.0, 3) },
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
let bitmask = self.bitmask();
[
(bitmask & 1) != 0,
(bitmask & 2) != 0,
(bitmask & 4) != 0,
(bitmask & 8) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
let bitmask = self.bitmask();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
MASK[((bitmask >> 3) & 1) as usize],
]
}
}
impl Default for BVec4A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec4A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec4A {}
impl core::hash::Hash for BVec4A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec4A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(unsafe { vandq_u32(self.0, rhs.0) })
}
}
impl BitAndAssign for BVec4A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(unsafe { vorrq_u32(self.0, rhs.0) })
}
}
impl BitOrAssign for BVec4A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(unsafe { veorq_u32(self.0, rhs.0) })
}
}
impl BitXorAssign for BVec4A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(unsafe { vmvnq_u32(self.0) })
}
}
impl From<BVec4A> for uint32x4_t {
#[inline]
fn from(t: BVec4A) -> Self {
t.0
}
}
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4A),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4A {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4A> for [bool; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4A> for [u32; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_u32_array()
}
}

2
vendor/glam/src/bool/scalar.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
pub mod bvec3a;
pub mod bvec4a;

240
vendor/glam/src/bool/scalar/bvec3a.rs vendored Normal file
View File

@@ -0,0 +1,240 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3a(x: bool, y: bool, z: bool) -> BVec3A {
BVec3A::new(x, y, z)
}
/// A 3-dimensional `u32` vector mask.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(16))]
pub struct BVec3A {
pub x: u32,
pub y: u32,
pub z: u32,
}
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Self {
x: MASK[x as usize],
y: MASK[y as usize],
z: MASK[z as usize],
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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 {
(self.x & 0x1) | ((self.y & 0x1) << 1) | ((self.z & 0x1) << 2)
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn any(self) -> bool {
((self.x | self.y | self.z) & 0x1) != 0
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn all(self) -> bool {
((self.x & self.y & self.z) & 0x1) != 0
}
/// 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.x & 0x1) != 0,
1 => (self.y & 0x1) != 0,
2 => (self.z & 0x1) != 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) {
match index {
0 => self.x = MASK[value as usize],
1 => self.y = MASK[value as usize],
2 => self.z = MASK[value as usize],
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 3] {
[
(self.x & 0x1) != 0,
(self.y & 0x1) != 0,
(self.z & 0x1) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 3] {
[self.x, self.y, self.z]
}
}
impl Default for BVec3A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl BitAnd for BVec3A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self {
x: self.x & rhs.x,
y: self.y & rhs.y,
z: self.z & rhs.z,
}
}
}
impl BitAndAssign for BVec3A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self {
x: self.x | rhs.x,
y: self.y | rhs.y,
z: self.z | rhs.z,
}
}
}
impl BitOrAssign for BVec3A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self {
x: self.x ^ rhs.x,
y: self.y ^ rhs.y,
z: self.z ^ rhs.z,
}
}
}
impl BitXorAssign for BVec3A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self {
x: !self.x,
y: !self.y,
z: !self.z,
}
}
}
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3A),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3A {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3A> for [bool; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3A> for [u32; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_u32_array()
}
}

250
vendor/glam/src/bool/scalar/bvec4a.rs vendored Normal file
View File

@@ -0,0 +1,250 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4a(x: bool, y: bool, z: bool, w: bool) -> BVec4A {
BVec4A::new(x, y, z, w)
}
/// A 4-dimensional `u32` vector mask.
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
#[repr(C, align(16))]
pub struct BVec4A {
pub x: u32,
pub y: u32,
pub z: u32,
pub w: u32,
}
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Self {
x: MASK[x as usize],
y: MASK[y as usize],
z: MASK[z as usize],
w: MASK[w as usize],
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 {
(self.x & 0x1) | ((self.y & 0x1) << 1) | ((self.z & 0x1) << 2) | ((self.w & 0x1) << 3)
}
/// Returns true if any of the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn any(self) -> bool {
((self.x | self.y | self.z | self.w) & 0x1) != 0
}
/// Returns true if all the elements are true, false otherwise.
#[inline]
#[must_use]
pub fn all(self) -> bool {
((self.x & self.y & self.z & self.w) & 0x1) != 0
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
#[must_use]
pub fn test(&self, index: usize) -> bool {
match index {
0 => (self.x & 0x1) != 0,
1 => (self.y & 0x1) != 0,
2 => (self.z & 0x1) != 0,
3 => (self.w & 0x1) != 0,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
match index {
0 => self.x = MASK[value as usize],
1 => self.y = MASK[value as usize],
2 => self.z = MASK[value as usize],
3 => self.w = MASK[value as usize],
_ => panic!("index out of bounds"),
}
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
[
(self.x & 0x1) != 0,
(self.y & 0x1) != 0,
(self.z & 0x1) != 0,
(self.w & 0x1) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
[self.x, self.y, self.z, self.w]
}
}
impl Default for BVec4A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl BitAnd for BVec4A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self {
x: self.x & rhs.x,
y: self.y & rhs.y,
z: self.z & rhs.z,
w: self.w & rhs.w,
}
}
}
impl BitAndAssign for BVec4A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self {
x: self.x | rhs.x,
y: self.y | rhs.y,
z: self.z | rhs.z,
w: self.w | rhs.w,
}
}
}
impl BitOrAssign for BVec4A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self {
x: self.x ^ rhs.x,
y: self.y ^ rhs.y,
z: self.z ^ rhs.z,
w: self.w ^ rhs.w,
}
}
}
impl BitXorAssign for BVec4A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self {
x: !self.x,
y: !self.y,
z: !self.z,
w: !self.w,
}
}
}
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4A),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4A {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4A> for [bool; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4A> for [u32; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_u32_array()
}
}

2
vendor/glam/src/bool/sse2.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
pub mod bvec3a;
pub mod bvec4a;

257
vendor/glam/src/bool/sse2/bvec3a.rs vendored Normal file
View File

@@ -0,0 +1,257 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec3A,
}
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3a(x: bool, y: bool, z: bool) -> BVec3A {
BVec3A::new(x, y, z)
}
/// A 3-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec3A(pub(crate) __m128);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
unsafe {
UnionCast {
a: [MASK[x as usize], MASK[y as usize], MASK[z as usize], 0],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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.0 = 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();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
]
}
}
impl Default for BVec3A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec3A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec3A {}
impl core::hash::Hash for BVec3A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec3A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(unsafe { _mm_and_ps(self.0, rhs.0) })
}
}
impl BitAndAssign for BVec3A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(unsafe { _mm_or_ps(self.0, rhs.0) })
}
}
impl BitOrAssign for BVec3A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(unsafe { _mm_xor_ps(self.0, rhs.0) })
}
}
impl BitXorAssign for BVec3A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(unsafe { _mm_andnot_ps(self.0, _mm_set_ps1(f32::from_bits(0xff_ff_ff_ff))) })
}
}
impl From<BVec3A> for __m128 {
#[inline]
fn from(t: BVec3A) -> Self {
t.0
}
}
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3A),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3A {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3A> for [bool; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3A> for [u32; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_u32_array()
}
}

270
vendor/glam/src/bool/sse2/bvec4a.rs vendored Normal file
View File

@@ -0,0 +1,270 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;
#[repr(C)]
union UnionCast {
a: [u32; 4],
v: BVec4A,
}
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4a(x: bool, y: bool, z: bool, w: bool) -> BVec4A {
BVec4A::new(x, y, z, w)
}
/// A 4-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec4A(pub(crate) __m128);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
unsafe {
UnionCast {
a: [
MASK[x as usize],
MASK[y as usize],
MASK[z as usize],
MASK[w as usize],
],
}
.v
}
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 }
}
/// 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() == 0xf
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[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,
3 => (self.bitmask() & (1 << 3)) != 0,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
use crate::Vec4;
let mut v = Vec4(self.0);
v[index] = f32::from_bits(MASK[value as usize]);
self.0 = v.0;
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
let bitmask = self.bitmask();
[
(bitmask & 1) != 0,
(bitmask & 2) != 0,
(bitmask & 4) != 0,
(bitmask & 8) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
let bitmask = self.bitmask();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
MASK[((bitmask >> 3) & 1) as usize],
]
}
}
impl Default for BVec4A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec4A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec4A {}
impl core::hash::Hash for BVec4A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec4A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(unsafe { _mm_and_ps(self.0, rhs.0) })
}
}
impl BitAndAssign for BVec4A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(unsafe { _mm_or_ps(self.0, rhs.0) })
}
}
impl BitOrAssign for BVec4A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(unsafe { _mm_xor_ps(self.0, rhs.0) })
}
}
impl BitXorAssign for BVec4A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(unsafe { _mm_andnot_ps(self.0, _mm_set_ps1(f32::from_bits(0xff_ff_ff_ff))) })
}
}
impl From<BVec4A> for __m128 {
#[inline]
fn from(t: BVec4A) -> Self {
t.0
}
}
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4A),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4A {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4A> for [bool; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4A> for [u32; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_u32_array()
}
}

2
vendor/glam/src/bool/wasm32.rs vendored Normal file
View File

@@ -0,0 +1,2 @@
pub mod bvec3a;
pub mod bvec4a;

248
vendor/glam/src/bool/wasm32/bvec3a.rs vendored Normal file
View File

@@ -0,0 +1,248 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::arch::wasm32::*;
/// Creates a 3-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec3a(x: bool, y: bool, z: bool) -> BVec3A {
BVec3A::new(x, y, z)
}
/// A 3-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec3A(pub(crate) v128);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec3A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool) -> Self {
Self(u32x4(
MASK[x as usize],
MASK[y as usize],
MASK[z as usize],
0,
))
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 3]) -> Self {
Self::new(a[0], a[1], a[2])
}
/// Returns a bitmask with the lowest 3 bits set from the elements of `self`.
///
/// 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 {
(u32x4_bitmask(self.0) & 0x7) as u32
}
/// 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.0 = 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();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
]
}
}
impl Default for BVec3A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec3A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec3A {}
impl core::hash::Hash for BVec3A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec3A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(v128_and(self.0, rhs.0))
}
}
impl BitAndAssign for BVec3A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec3A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(v128_or(self.0, rhs.0))
}
}
impl BitOrAssign for BVec3A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec3A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(v128_xor(self.0, rhs.0))
}
}
impl BitXorAssign for BVec3A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec3A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(v128_not(self.0))
}
}
impl From<BVec3A> for v128 {
#[inline]
fn from(t: BVec3A) -> Self {
t.0
}
}
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x})",
stringify!(BVec3A),
arr[0],
arr[1],
arr[2]
)
}
}
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}]", arr[0], arr[1], arr[2])
}
}
impl From<[bool; 3]> for BVec3A {
#[inline]
fn from(a: [bool; 3]) -> Self {
Self::from_array(a)
}
}
impl From<BVec3A> for [bool; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec3A> for [u32; 3] {
#[inline]
fn from(mask: BVec3A) -> Self {
mask.into_u32_array()
}
}

256
vendor/glam/src/bool/wasm32/bvec4a.rs vendored Normal file
View File

@@ -0,0 +1,256 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.
use core::fmt;
use core::ops::*;
use core::arch::wasm32::*;
/// Creates a 4-dimensional `bool` vector mask.
#[inline(always)]
#[must_use]
pub const fn bvec4a(x: bool, y: bool, z: bool, w: bool) -> BVec4A {
BVec4A::new(x, y, z, w)
}
/// A 4-dimensional SIMD vector mask.
///
/// This type is 16 byte aligned.
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct BVec4A(pub(crate) v128);
const MASK: [u32; 2] = [0, 0xff_ff_ff_ff];
impl BVec4A {
/// All false.
pub const FALSE: Self = Self::splat(false);
/// All true.
pub const TRUE: Self = Self::splat(true);
/// Creates a new vector mask.
#[inline(always)]
#[must_use]
pub const fn new(x: bool, y: bool, z: bool, w: bool) -> Self {
Self(u32x4(
MASK[x as usize],
MASK[y as usize],
MASK[z as usize],
MASK[w as usize],
))
}
/// Creates a vector mask with all elements set to `v`.
#[inline]
#[must_use]
pub const fn splat(v: bool) -> Self {
Self::new(v, v, v, v)
}
/// Creates a new vector mask from a bool array.
#[inline]
#[must_use]
pub const fn from_array(a: [bool; 4]) -> Self {
Self::new(a[0], a[1], a[2], a[3])
}
/// Returns a bitmask with the lowest 4 bits set from the elements of `self`.
///
/// 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 {
u32x4_bitmask(self.0) as u32
}
/// 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() == 0xf
}
/// Tests the value at `index`.
///
/// Panics if `index` is greater than 3.
#[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,
3 => (self.bitmask() & (1 << 3)) != 0,
_ => panic!("index out of bounds"),
}
}
/// Sets the element at `index`.
///
/// Panics if `index` is greater than 3.
#[inline]
pub fn set(&mut self, index: usize, value: bool) {
use crate::Vec4;
let mut v = Vec4(self.0);
v[index] = f32::from_bits(MASK[value as usize]);
self.0 = v.0;
}
#[inline]
#[must_use]
fn into_bool_array(self) -> [bool; 4] {
let bitmask = self.bitmask();
[
(bitmask & 1) != 0,
(bitmask & 2) != 0,
(bitmask & 4) != 0,
(bitmask & 8) != 0,
]
}
#[inline]
#[must_use]
fn into_u32_array(self) -> [u32; 4] {
let bitmask = self.bitmask();
[
MASK[(bitmask & 1) as usize],
MASK[((bitmask >> 1) & 1) as usize],
MASK[((bitmask >> 2) & 1) as usize],
MASK[((bitmask >> 3) & 1) as usize],
]
}
}
impl Default for BVec4A {
#[inline]
fn default() -> Self {
Self::FALSE
}
}
impl PartialEq for BVec4A {
#[inline]
fn eq(&self, rhs: &Self) -> bool {
self.bitmask().eq(&rhs.bitmask())
}
}
impl Eq for BVec4A {}
impl core::hash::Hash for BVec4A {
#[inline]
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.bitmask().hash(state);
}
}
impl BitAnd for BVec4A {
type Output = Self;
#[inline]
fn bitand(self, rhs: Self) -> Self {
Self(v128_and(self.0, rhs.0))
}
}
impl BitAndAssign for BVec4A {
#[inline]
fn bitand_assign(&mut self, rhs: Self) {
*self = self.bitand(rhs);
}
}
impl BitOr for BVec4A {
type Output = Self;
#[inline]
fn bitor(self, rhs: Self) -> Self {
Self(v128_or(self.0, rhs.0))
}
}
impl BitOrAssign for BVec4A {
#[inline]
fn bitor_assign(&mut self, rhs: Self) {
*self = self.bitor(rhs);
}
}
impl BitXor for BVec4A {
type Output = Self;
#[inline]
fn bitxor(self, rhs: Self) -> Self {
Self(v128_xor(self.0, rhs.0))
}
}
impl BitXorAssign for BVec4A {
#[inline]
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.bitxor(rhs);
}
}
impl Not for BVec4A {
type Output = Self;
#[inline]
fn not(self) -> Self {
Self(v128_not(self.0))
}
}
impl From<BVec4A> for v128 {
#[inline]
fn from(t: BVec4A) -> Self {
t.0
}
}
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
write!(
f,
"{}({:#x}, {:#x}, {:#x}, {:#x})",
stringify!(BVec4A),
arr[0],
arr[1],
arr[2],
arr[3]
)
}
}
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
write!(f, "[{}, {}, {}, {}]", arr[0], arr[1], arr[2], arr[3])
}
}
impl From<[bool; 4]> for BVec4A {
#[inline]
fn from(a: [bool; 4]) -> Self {
Self::from_array(a)
}
}
impl From<BVec4A> for [bool; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_bool_array()
}
}
impl From<BVec4A> for [u32; 4] {
#[inline]
fn from(mask: BVec4A) -> Self {
mask.into_u32_array()
}
}