mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-25 16:25:25 +00:00
tests: adjust for lack of PassMode::{Indirect, Cast}
.
This commit is contained in:
parent
2dc88f26ac
commit
28313a2029
16
tests/ui/dis/entry-pass-mode-cast-array.rs
Normal file
16
tests/ui/dis/entry-pass-mode-cast-array.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// This is a similar setup to the `issue-731` test, but instead of "just" the
|
||||||
|
// missing copy out of the global (`Input`) `OpVariable`, small enough types
|
||||||
|
// would fail much earlier (by generating 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 as _;
|
||||||
|
|
||||||
|
#[spirv(fragment)]
|
||||||
|
pub fn main(mut in_array: [f32; 2], out_array: &mut [f32; 2]) {
|
||||||
|
in_array[0] += 1.0;
|
||||||
|
*out_array = in_array;
|
||||||
|
}
|
21
tests/ui/dis/entry-pass-mode-cast-array.stderr
Normal file
21
tests/ui/dis/entry-pass-mode-cast-array.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
%1 = OpFunction %2 None %3
|
||||||
|
%4 = OpLabel
|
||||||
|
%5 = OpVariable %6 Function
|
||||||
|
%7 = OpVariable %6 Function
|
||||||
|
OpLine %8 13 12
|
||||||
|
%9 = OpLoad %10 %11
|
||||||
|
OpLine %8 13 0
|
||||||
|
OpStore %5 %9
|
||||||
|
OpLine %8 14 4
|
||||||
|
%12 = OpInBoundsAccessChain %13 %5 %14
|
||||||
|
%15 = OpInBoundsAccessChain %13 %5 %14
|
||||||
|
%16 = OpLoad %17 %15
|
||||||
|
%18 = OpFAdd %17 %16 %19
|
||||||
|
OpStore %12 %18
|
||||||
|
OpLine %8 15 17
|
||||||
|
OpCopyMemory %7 %5
|
||||||
|
OpLine %8 15 4
|
||||||
|
OpCopyMemory %20 %7
|
||||||
|
OpLine %8 16 1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
23
tests/ui/dis/issue-373.rs
Normal file
23
tests/ui/dis/issue-373.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Test that returning a single-scalar-field `#[repr(C)] struct` doesn't generate
|
||||||
|
// unsupported pointer casts (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 as _;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct S {
|
||||||
|
x: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() -> S {
|
||||||
|
S { x: 2.0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[spirv(fragment)]
|
||||||
|
pub fn main(out: &mut f32) {
|
||||||
|
*out = f().x;
|
||||||
|
}
|
11
tests/ui/dis/issue-373.stderr
Normal file
11
tests/ui/dis/issue-373.stderr
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
%1 = OpFunction %2 None %3
|
||||||
|
%4 = OpLabel
|
||||||
|
OpLine %5 22 11
|
||||||
|
%6 = OpFunctionCall %7 %8
|
||||||
|
OpLine %5 22 11
|
||||||
|
%9 = OpCompositeExtract %10 %6 0
|
||||||
|
OpLine %5 22 4
|
||||||
|
OpStore %11 %9
|
||||||
|
OpLine %5 23 1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
@ -1,17 +0,0 @@
|
|||||||
// Test that interface (global) `OpVariable`s mentioned by `OpEntryPoint` don't
|
|
||||||
// have to be used by the shader, for storage class inference to succeed.
|
|
||||||
|
|
||||||
// NOTE(eddyb) this test will likely become useless (won't fail without the fix)
|
|
||||||
// once we start doing the copy out of the `Input` and into a `Function`-scoped
|
|
||||||
// `OpVariable` (see #731), that's why there is another `issue-723-*` test.
|
|
||||||
|
|
||||||
// build-pass
|
|
||||||
// compile-flags: -C llvm-args=--disassemble-globals
|
|
||||||
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
|
|
||||||
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
|
|
||||||
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
|
|
||||||
|
|
||||||
use spirv_std as _;
|
|
||||||
|
|
||||||
#[spirv(fragment)]
|
|
||||||
pub fn main(/* unused Input */ _: [f32; 3]) {}
|
|
@ -1,23 +0,0 @@
|
|||||||
OpCapability Float64
|
|
||||||
OpCapability Int16
|
|
||||||
OpCapability Int64
|
|
||||||
OpCapability Int8
|
|
||||||
OpCapability ShaderClockKHR
|
|
||||||
OpCapability Shader
|
|
||||||
OpExtension "SPV_KHR_shader_clock"
|
|
||||||
OpMemoryModel Logical Simple
|
|
||||||
OpEntryPoint Fragment %1 "main" %2
|
|
||||||
OpExecutionMode %1 OriginUpperLeft
|
|
||||||
%3 = OpString "$OPSTRING_FILENAME/issue-723-indirect-input.rs"
|
|
||||||
OpName %4 "issue_723_indirect_input::main"
|
|
||||||
OpDecorate %5 ArrayStride 4
|
|
||||||
OpDecorate %2 Location 0
|
|
||||||
%6 = OpTypeVoid
|
|
||||||
%7 = OpTypeFloat 32
|
|
||||||
%8 = OpTypeInt 32 0
|
|
||||||
%9 = OpConstant %8 3
|
|
||||||
%5 = OpTypeArray %7 %9
|
|
||||||
%10 = OpTypeFunction %6 %5
|
|
||||||
%11 = OpTypeFunction %6
|
|
||||||
%12 = OpTypePointer Input %5
|
|
||||||
%2 = OpVariable %12 Input
|
|
14
tests/ui/dis/issue-731.rs
Normal file
14
tests/ui/dis/issue-731.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Test that non-immediate (i.e. not one of scalar/scalar-pair/vector) inputs
|
||||||
|
// get properly copied out of the global (`Input`) `OpVariable` and mutation is
|
||||||
|
// only ever done on `fn`-local `OpVariable`s, not on the original global.
|
||||||
|
|
||||||
|
// build-pass
|
||||||
|
// compile-flags: -C llvm-args=--disassemble-entry=main
|
||||||
|
|
||||||
|
use spirv_std as _;
|
||||||
|
|
||||||
|
#[spirv(fragment)]
|
||||||
|
pub fn main(mut in_array: [f32; 3], out_array: &mut [f32; 3]) {
|
||||||
|
in_array[0] += 1.0;
|
||||||
|
*out_array = in_array;
|
||||||
|
}
|
21
tests/ui/dis/issue-731.stderr
Normal file
21
tests/ui/dis/issue-731.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
%1 = OpFunction %2 None %3
|
||||||
|
%4 = OpLabel
|
||||||
|
%5 = OpVariable %6 Function
|
||||||
|
%7 = OpVariable %6 Function
|
||||||
|
OpLine %8 11 12
|
||||||
|
%9 = OpLoad %10 %11
|
||||||
|
OpLine %8 11 0
|
||||||
|
OpStore %5 %9
|
||||||
|
OpLine %8 12 4
|
||||||
|
%12 = OpInBoundsAccessChain %13 %5 %14
|
||||||
|
%15 = OpInBoundsAccessChain %13 %5 %14
|
||||||
|
%16 = OpLoad %17 %15
|
||||||
|
%18 = OpFAdd %17 %16 %19
|
||||||
|
OpStore %12 %18
|
||||||
|
OpLine %8 13 17
|
||||||
|
OpCopyMemory %7 %5
|
||||||
|
OpLine %8 13 4
|
||||||
|
OpCopyMemory %20 %7
|
||||||
|
OpLine %8 14 1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
30
tests/ui/dis/pass-mode-cast-struct.rs
Normal file
30
tests/ui/dis/pass-mode-cast-struct.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// 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 as _;
|
||||||
|
|
||||||
|
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(in_packed: u64, out_sum: &mut u32) {
|
||||||
|
let foo = Foo::unpack(in_packed);
|
||||||
|
*out_sum = foo.a + (foo.b + foo.c) as u32;
|
||||||
|
}
|
22
tests/ui/dis/pass-mode-cast-struct.stderr
Normal file
22
tests/ui/dis/pass-mode-cast-struct.stderr
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
%1 = OpFunction %2 None %3
|
||||||
|
%4 = OpLabel
|
||||||
|
OpLine %5 27 12
|
||||||
|
%6 = OpLoad %7 %8
|
||||||
|
OpLine %5 28 14
|
||||||
|
%9 = OpFunctionCall %10 %11 %6
|
||||||
|
OpLine %5 29 15
|
||||||
|
%12 = OpCompositeExtract %13 %9 0
|
||||||
|
OpLine %5 29 24
|
||||||
|
%14 = OpCompositeExtract %15 %9 1
|
||||||
|
OpLine %5 29 32
|
||||||
|
%16 = OpCompositeExtract %15 %9 2
|
||||||
|
OpLine %5 29 23
|
||||||
|
%17 = OpIAdd %15 %14 %16
|
||||||
|
OpLine %5 29 23
|
||||||
|
%18 = OpUConvert %13 %17
|
||||||
|
OpLine %5 29 4
|
||||||
|
%19 = OpIAdd %13 %12 %18
|
||||||
|
OpStore %20 %19
|
||||||
|
OpLine %5 30 1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
Loading…
Reference in New Issue
Block a user