|
| 1 | +#![crate_name = "scalars"] |
| 2 | + |
| 3 | +// Tests all the (supported) Rust integer/floating-point scalar types. |
| 4 | + |
| 5 | +// revisions: supported nocaps |
| 6 | +//[supported] build-pass |
| 7 | +//[supported] compile-flags: -C target-feature=+Int8,+Int16,+Int64,+Float64 |
| 8 | +//[nocaps] build-fail |
| 9 | + |
| 10 | +// compile-flags: -C llvm-args=--disassemble-globals |
| 11 | +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" |
| 12 | +// normalize-stderr-test "OpSource .*\n" -> "" |
| 13 | +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" |
| 14 | +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" |
| 15 | + |
| 16 | +// FIXME(eddyb) this should use revisions to track both the `vulkan1.2` output |
| 17 | +// and the pre-`vulkan1.2` output, but per-revision `{only,ignore}-*` directives |
| 18 | +// are not supported in `compiletest-rs`. |
| 19 | +// ignore-vulkan1.2 |
| 20 | + |
| 21 | +use spirv_std::spirv; |
| 22 | + |
| 23 | +#[spirv(fragment)] |
| 24 | +pub fn main( |
| 25 | + out: &mut u32, |
| 26 | + |
| 27 | + #[spirv(flat)] in_u8: u8, |
| 28 | + #[spirv(flat)] in_u16: u16, |
| 29 | + #[spirv(flat)] in_u32: u32, |
| 30 | + #[spirv(flat)] in_u64: u64, |
| 31 | + // FIXME(eddyb) support `u128` somehow! |
| 32 | + #[cfg(not(supported))] |
| 33 | + #[spirv(flat)] |
| 34 | + in_u128: u128, |
| 35 | + |
| 36 | + #[spirv(flat)] in_i8: i8, |
| 37 | + #[spirv(flat)] in_i16: i16, |
| 38 | + #[spirv(flat)] in_i32: i32, |
| 39 | + #[spirv(flat)] in_i64: i64, |
| 40 | + // FIXME(eddyb) support `i128` somehow! |
| 41 | + #[cfg(not(supported))] |
| 42 | + #[spirv(flat)] |
| 43 | + in_i128: i128, |
| 44 | + |
| 45 | + in_f32: f32, |
| 46 | + #[spirv(flat)] in_f64: f64, |
| 47 | +) { |
| 48 | + // HACK(eddyb) to make it more obvious in the disassembly, each type gets a |
| 49 | + // constant with its bit width, disambiguated for signed integers by negation. |
| 50 | + *out |= (in_u8 * 8) as u32; |
| 51 | + *out |= (in_u16 * 16) as u32; |
| 52 | + *out |= (in_u32 * 32) as u32; |
| 53 | + *out |= (in_u64 * 64) as u32; |
| 54 | + // FIXME(eddyb) support `u128` somehow! |
| 55 | + #[cfg(not(supported))] |
| 56 | + { |
| 57 | + // FIXME(eddyb) constants still emit zombies that get reported too early. |
| 58 | + // *out |= (in_u128 * 128) as u32; |
| 59 | + *out |= (in_u128 + in_u128) as u32; |
| 60 | + } |
| 61 | + |
| 62 | + *out |= (in_i8 * -8) as u32; |
| 63 | + *out |= (in_i16 * -16) as u32; |
| 64 | + *out |= (in_i32 * -32) as u32; |
| 65 | + *out |= (in_i64 * -64) as u32; |
| 66 | + // FIXME(eddyb) support `i128` somehow! |
| 67 | + #[cfg(not(supported))] |
| 68 | + { |
| 69 | + // FIXME(eddyb) constants still emit zombies that get reported too early. |
| 70 | + // *out |= (in_i128 * -128) as u32; |
| 71 | + *out |= (in_i128 + in_i128) as u32; |
| 72 | + } |
| 73 | + |
| 74 | + *out |= (in_f32 * 32.0) as u32; |
| 75 | + *out |= (in_f64 * 64.0) as u32; |
| 76 | +} |
0 commit comments