Skip to content

Commit 528fd47

Browse files
committed
cleanup: remove internal type F32x2 for glam::Vec2
1 parent 4352066 commit 528fd47

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

crates/spirv-std/src/float.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//! Traits and helper functions related to floats.
22
33
use crate::vector::Vector;
4-
use crate::vector::{create_dim, VectorOrScalar};
54
#[cfg(target_arch = "spirv")]
65
use core::arch::asm;
7-
use core::num::NonZeroUsize;
86

97
/// Abstract trait representing a SPIR-V floating point type.
108
///
@@ -63,34 +61,18 @@ pub fn f16x2_to_vec2<V: Vector<f32, 2>>(int: u32) -> V {
6361
result
6462
}
6563

66-
// We don't have access to a concrete vector type (cfg(feature = "glam") might not be enabled), so
67-
// synth up one manually.
68-
#[cfg_attr(target_arch = "spirv", repr(simd))]
69-
// sometimes dead because on cpu, the `gpu_only` macro nukes the method bodies
70-
#[allow(dead_code)]
71-
#[derive(Default)]
72-
struct F32x2 {
73-
x: f32,
74-
y: f32,
75-
}
76-
unsafe impl VectorOrScalar for F32x2 {
77-
type Scalar = f32;
78-
const DIM: NonZeroUsize = create_dim(2);
79-
}
80-
unsafe impl Vector<f32, 2> for F32x2 {}
81-
8264
/// Converts an f32 (float) into an f16 (half). The result is a u32, not a u16, due to GPU support
8365
/// for u16 not being universal - the upper 16 bits will always be zero.
8466
#[spirv_std_macros::gpu_only]
8567
pub fn f32_to_f16(float: f32) -> u32 {
86-
vec2_to_f16x2(F32x2 { x: float, y: 0.0 })
68+
vec2_to_f16x2(glam::Vec2::new(float, 0.))
8769
}
8870

8971
/// Converts an f16 (half) into an f32 (float). The parameter is a u32, due to GPU support for u16
9072
/// not being universal - the upper 16 bits are ignored.
9173
#[spirv_std_macros::gpu_only]
9274
pub fn f16_to_f32(packed: u32) -> f32 {
93-
f16x2_to_vec2::<F32x2>(packed).x
75+
f16x2_to_vec2::<glam::Vec2>(packed).x
9476
}
9577

9678
/// Packs a vec4 into 4 8-bit signed integers. See

0 commit comments

Comments
 (0)