Removed rust-gpu support for Vector bool for glam

This commit is contained in:
Sylvester Hesp 2022-11-03 10:47:08 +01:00 committed by Eduard-Mihai Burtescu
parent 53ad54add3
commit 83d6c0b9fe
6 changed files with 42 additions and 28 deletions

View File

@ -7,13 +7,6 @@
/// should not be done.
pub unsafe trait Vector<T: crate::scalar::Scalar, const N: usize>: Default {}
#[cfg(feature = "glam")]
unsafe impl Vector<bool, 2> for glam::BVec2 {}
#[cfg(feature = "glam")]
unsafe impl Vector<bool, 3> for glam::BVec3 {}
#[cfg(feature = "glam")]
unsafe impl Vector<bool, 4> for glam::BVec4 {}
#[cfg(feature = "glam")]
unsafe impl Vector<f32, 2> for glam::Vec2 {}
#[cfg(feature = "glam")]

View File

@ -1,9 +1,27 @@
// build-pass
#![feature(repr_simd)]
use spirv_std::spirv;
use spirv_std::{scalar::Scalar, vector::Vector};
/// HACK(shesp). Rust doesn't allow us to declare regular (tuple-)structs containing `bool` members
/// as `#[repl(simd)]`. But we need this for `spirv_std::arch::any()` and `spirv_std::arch::all()`
/// to work.
/// Fortunaly, this requirement isn't checked on generic structs, so we have a way to work around
/// it (for now at least)
#[repr(simd)]
struct Vec2<T>(T, T);
unsafe impl<T: Scalar> Vector<T, 2> for Vec2<T> {}
impl<T: Scalar> Default for Vec2<T> {
fn default() -> Vec2<T> {
Vec2(T::default(), T::default())
}
}
#[spirv(fragment)]
pub fn main() {
let vector = glam::BVec2::new(true, true);
pub fn main(#[spirv(flat)] output: &mut u32) {
let vector = Vec2(true, true);
assert!(spirv_std::arch::all(vector));
}

View File

@ -1,7 +0,0 @@
error: error:0:0 - Expected operand to be vector bool: All
|
= note: spirv-val failed
= note: module `$TEST_BUILD_DIR/arch/all.stage-id.spv.dir/module`
error: aborting due to previous error

View File

@ -1,9 +1,26 @@
// build-pass
#![feature(repr_simd)]
use spirv_std::spirv;
use spirv_std::{scalar::Scalar, vector::Vector};
/// HACK(shesp). Rust doesn't allow us to declare regular (tuple-)structs containing `bool` members
/// as `#[repl(simd)]`. But we need this for `spirv_std::arch::any()` and `spirv_std::arch::all()`
/// to work.
/// Fortunaly, this requirement isn't checked on generic structs, so we have a way to work around
/// it (for now at least)
#[repr(simd)]
struct Vec2<T>(T, T);
unsafe impl<T: Scalar> Vector<T, 2> for Vec2<T> {}
impl<T: Scalar> Default for Vec2<T> {
fn default() -> Vec2<T> {
Vec2(T::default(), T::default())
}
}
#[spirv(fragment)]
pub fn main() {
let vector = glam::BVec2::new(true, false);
let vector = Vec2(false, true);
assert!(spirv_std::arch::any(vector));
}

View File

@ -1,7 +0,0 @@
error: error:0:0 - Expected operand to be vector bool: Any
|
= note: spirv-val failed
= note: module `$TEST_BUILD_DIR/arch/any.stage-id.spv.dir/module`
error: aborting due to previous error

View File

@ -106,15 +106,15 @@ error[E0277]: the trait bound `{float}: Vector<f32, 2>` is not satisfied
| required by a bound introduced by this call
|
= help: the following other types implement trait `Vector<T, N>`:
<BVec2 as Vector<bool, 2>>
<BVec3 as Vector<bool, 3>>
<BVec4 as Vector<bool, 4>>
<DVec2 as Vector<f64, 2>>
<DVec3 as Vector<f64, 3>>
<DVec4 as Vector<f64, 4>>
<IVec2 as Vector<i32, 2>>
<IVec3 as Vector<i32, 3>>
and 8 others
<IVec4 as Vector<i32, 4>>
<UVec2 as Vector<u32, 2>>
<UVec3 as Vector<u32, 3>>
and 5 others
note: required by a bound in `debug_printf_assert_is_vector`
--> $SPIRV_STD_SRC/lib.rs:144:8
|