Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv: impl Debug + Display, fix Affine::from_cols_array() #559

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions codegen/templates/affine.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

{% if dim == 2 %}
{% set size = 6 %}
{% set mat_size = 4 %}
{% set vec_size = 2 %}
{% elif dim == 3 %}
{% set size = 12 %}
{% set mat_size = 9 %}
{% set vec_size = 3 %}
{% endif %}

{% set components = ["x", "y", "z", "w"] | slice(end = dim + 1) %}
Expand Down Expand Up @@ -108,8 +112,16 @@ impl {{ self_t }} {
#[must_use]
pub fn from_cols_array(m: &[{{ scalar_t }}; {{ size }}]) -> Self {
Self {
matrix{{ dim }}: {{ mat_t }}::from_cols_slice(&m[0..{{ dim * dim }}]),
translation: {{ col_t }}::from_slice(&m[{{ dim * dim }}..{{ size }}]),
matrix{{ dim }}: {{ mat_t }}::from_cols_array(&[
{% for i in range(end = mat_size) %}
m[{{ i }}],
{%- endfor %}
]),
translation: {{ col_t }}::from_array([
{% for i in range(start = mat_size, end = mat_size + vec_size) %}
m[{{ i }}],
{%- endfor %}
]),
}
}

Expand Down Expand Up @@ -721,7 +733,6 @@ impl PartialEq for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl core::fmt::Debug for {{ self_t }} {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
fmt.debug_struct(stringify!({{ self_t }}))
Expand All @@ -731,7 +742,6 @@ impl core::fmt::Debug for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl core::fmt::Display for {{ self_t }} {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if let Some(p) = f.precision() {
Expand Down
3 changes: 0 additions & 3 deletions codegen/templates/mat.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ use crate::{
{{ scalar_t }}::math,
swizzles::*,
};
#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
Expand Down Expand Up @@ -2594,7 +2593,6 @@ impl core::ops::DerefMut for Mat2 {
}
{% endif %}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for {{ self_t }} {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct(stringify!({{ self_t }}))
Expand All @@ -2605,7 +2603,6 @@ impl fmt::Debug for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for {{ self_t }} {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(p) = f.precision() {
Expand Down
3 changes: 0 additions & 3 deletions codegen/templates/quat.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ use core::simd::*;
use core::arch::aarch64::*;
{% endif %}

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::iter::{Product, Sum};
use core::ops::{
Expand Down Expand Up @@ -1161,7 +1160,6 @@ impl {{ self_t }} {
{% endif %}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for {{ self_t }} {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple(stringify!({{ self_t }}))
Expand All @@ -1173,7 +1171,6 @@ impl fmt::Debug for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for {{ self_t }} {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(p) = f.precision() {
Expand Down
3 changes: 0 additions & 3 deletions codegen/templates/vec.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@
{% endif %}
};

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::iter::{Product, Sum};
use core::{f32, ops::*};
Expand Down Expand Up @@ -3841,7 +3840,6 @@ impl IndexMut<usize> for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for {{ self_t }} {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
{% if is_float %}
Expand All @@ -3868,7 +3866,6 @@ impl fmt::Display for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for {{ self_t }} {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_tuple(stringify!({{ self_t }}))
Expand Down
3 changes: 0 additions & 3 deletions codegen/templates/vec_mask.rs.tera
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

{% set components = ["x", "y", "z", "w"] | slice(end = dim) %}

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -543,7 +542,6 @@ impl From<{{ self_t }}> for {{ simd_t }} {
}
{% endif %}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for {{ self_t }} {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -557,7 +555,6 @@ impl fmt::Debug for {{ self_t }} {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for {{ self_t }} {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/bvec2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -183,15 +182,13 @@ impl Not for BVec2 {
}
}

#[cfg(not(target_arch = "spirv"))]
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])
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec2 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/bvec3.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -194,7 +193,6 @@ impl Not for BVec3 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec3 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -209,7 +207,6 @@ impl fmt::Debug for BVec3 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec3 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/bvec4.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -202,7 +201,6 @@ impl Not for BVec4 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec4 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -218,7 +216,6 @@ impl fmt::Debug for BVec4 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec4 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/coresimd/bvec3a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -204,7 +203,6 @@ impl From<BVec3A> for mask32x4 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -219,7 +217,6 @@ impl fmt::Debug for BVec3A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/coresimd/bvec4a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -215,7 +214,6 @@ impl From<BVec4A> for mask32x4 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -231,7 +229,6 @@ impl fmt::Debug for BVec4A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/neon/bvec3a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -223,7 +222,6 @@ impl From<BVec3A> for uint32x4_t {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -238,7 +236,6 @@ impl fmt::Debug for BVec3A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/neon/bvec4a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -234,7 +233,6 @@ impl From<BVec4A> for uint32x4_t {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -250,7 +248,6 @@ impl fmt::Debug for BVec4A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/scalar/bvec3a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -198,7 +197,6 @@ impl Not for BVec3A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -213,7 +211,6 @@ impl fmt::Debug for BVec3A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/scalar/bvec4a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -207,7 +206,6 @@ impl Not for BVec4A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -223,7 +221,6 @@ impl fmt::Debug for BVec4A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/sse2/bvec3a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -215,7 +214,6 @@ impl From<BVec3A> for __m128 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -230,7 +228,6 @@ impl fmt::Debug for BVec3A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec3A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
3 changes: 0 additions & 3 deletions src/bool/sse2/bvec4a.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated from vec_mask.rs.tera template. Edit the template, not the generated file.

#[cfg(not(target_arch = "spirv"))]
use core::fmt;
use core::ops::*;

Expand Down Expand Up @@ -227,7 +226,6 @@ impl From<BVec4A> for __m128 {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Debug for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_u32_array();
Expand All @@ -243,7 +241,6 @@ impl fmt::Debug for BVec4A {
}
}

#[cfg(not(target_arch = "spirv"))]
impl fmt::Display for BVec4A {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let arr = self.into_bool_array();
Expand Down
Loading