rust-gpu/tests/ui/dis/pass-mode-cast-struct.rs
2022-10-27 11:42:23 +03:00

31 lines
759 B
Rust

// Test that a small enough `struct` doesn't generate unsupported pointer casts.
// (Just like `issue-373`, the problem was the use of `PassMode::Cast`, through
// the default Rust ABI adjustments, that we now override through query hooks)
// build-pass
// compile-flags: -C llvm-args=--disassemble-entry=main
use spirv_std::spirv;
struct Foo {
a: u32,
b: u8,
c: u8,
}
impl Foo {
fn unpack(data: u64) -> Self {
Self {
a: (data >> 16 & 0xffffff) as u32,
b: (data & 0xff >> 8) as u8,
c: (data & 0xff) as u8,
}
}
}
#[spirv(fragment)]
pub fn main(#[spirv(flat)] in_packed: u64, out_sum: &mut u32) {
let foo = Foo::unpack(in_packed);
*out_sum = foo.a + (foo.b + foo.c) as u32;
}