File tree Expand file tree Collapse file tree 4 files changed +173
-0
lines changed
tests/compiletests/ui/glam Expand file tree Collapse file tree 4 files changed +173
-0
lines changed Original file line number Diff line number Diff line change
1
+ // build-fail
2
+
3
+ use core:: num:: NonZeroU32 ;
4
+ use spirv_std:: glam:: Vec2 ;
5
+ use spirv_std:: spirv;
6
+
7
+ #[ rust_gpu:: vector:: v1]
8
+ pub struct FewerFields {
9
+ _v : f32 ,
10
+ }
11
+
12
+ #[ rust_gpu:: vector:: v1]
13
+ pub struct TooManyFields {
14
+ _x : f32 ,
15
+ _y : f32 ,
16
+ _z : f32 ,
17
+ _w : f32 ,
18
+ _v : f32 ,
19
+ }
20
+
21
+ #[ rust_gpu:: vector:: v1]
22
+ pub struct NotVectorField {
23
+ _x : Vec2 ,
24
+ _y : Vec2 ,
25
+ }
26
+
27
+ #[ rust_gpu:: vector:: v1]
28
+ pub struct NotVectorField2 {
29
+ _x : NonZeroU32 ,
30
+ _y : NonZeroU32 ,
31
+ }
32
+
33
+ #[ rust_gpu:: vector:: v1]
34
+ pub struct DifferentTypes {
35
+ _x : f32 ,
36
+ _y : u32 ,
37
+ }
38
+
39
+ #[ spirv( fragment) ]
40
+ pub fn entry (
41
+ _: FewerFields ,
42
+ _: TooManyFields ,
43
+ _: NotVectorField ,
44
+ #[ spirv( flat) ] _: NotVectorField2 ,
45
+ #[ spirv( flat) ] _: DifferentTypes ,
46
+ ) {
47
+ }
Original file line number Diff line number Diff line change
1
+ error: `#[spirv(vector)]` must have 2, 3 or 4 members
2
+ --> $DIR/invalid_vector_type.rs:8:1
3
+ |
4
+ 8 | pub struct FewerFields {
5
+ | ^^^^^^^^^^^^^^^^^^^^^^
6
+
7
+ error: `#[spirv(vector)]` must have 2, 3 or 4 members
8
+ --> $DIR/invalid_vector_type.rs:13:1
9
+ |
10
+ 13 | pub struct TooManyFields {
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
12
+
13
+ error: `#[spirv(vector)]` type fields must all be floats, integers or bools
14
+ --> $DIR/invalid_vector_type.rs:22:1
15
+ |
16
+ 22 | pub struct NotVectorField {
17
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
18
+ |
19
+ = note: field type is f32x2
20
+
21
+ error: `#[spirv(vector)]` member types must all be the same
22
+ --> $DIR/invalid_vector_type.rs:34:1
23
+ |
24
+ 34 | pub struct DifferentTypes {
25
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
26
+
27
+ error: aborting due to 4 previous errors
28
+
Original file line number Diff line number Diff line change
1
+ // build-pass
2
+ // compile-flags: -C llvm-args=--disassemble
3
+ // normalize-stderr-test "OpSource .*\n" -> ""
4
+ // normalize-stderr-test "OpLine .*\n" -> ""
5
+ // normalize-stderr-test "%\d+ = OpString .*\n" -> ""
6
+ // normalize-stderr-test "; .*\n" -> ""
7
+ // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
8
+ // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
9
+ // ignore-vulkan1.0
10
+ // ignore-vulkan1.1
11
+
12
+ use spirv_std:: arch:: subgroup_shuffle_up;
13
+ use spirv_std:: spirv;
14
+
15
+ #[ repr( C ) ]
16
+ #[ derive( Copy , Clone , Default ) ]
17
+ #[ rust_gpu:: vector:: v1]
18
+ pub struct Vec3 {
19
+ x : f32 ,
20
+ y : f32 ,
21
+ z : f32 ,
22
+ }
23
+
24
+ #[ repr( C , align( 16 ) ) ]
25
+ #[ derive( Copy , Clone , Default ) ]
26
+ #[ rust_gpu:: vector:: v1]
27
+ pub struct Vec3A {
28
+ x : f32 ,
29
+ y : f32 ,
30
+ z : f32 ,
31
+ }
32
+
33
+ #[ repr( C ) ]
34
+ #[ derive( Copy , Clone , Default ) ]
35
+ pub struct Data < T > {
36
+ t : T ,
37
+ // this should generate two distinct structs where this member has different offsets
38
+ value : f32 ,
39
+ }
40
+
41
+ impl Vec3 {
42
+ pub fn to_vec3a ( & self ) -> Vec3A {
43
+ Vec3A {
44
+ x : self . x ,
45
+ y : self . y ,
46
+ z : self . z ,
47
+ }
48
+ }
49
+ }
50
+
51
+ #[ spirv( fragment) ]
52
+ pub fn main ( input : Data < Vec3 > , output : & mut Data < Vec3A > ) {
53
+ * output = Data {
54
+ t : input. t . to_vec3a ( ) ,
55
+ value : input. value ,
56
+ } ;
57
+ }
Original file line number Diff line number Diff line change
1
+ OpCapability Shader
2
+ OpMemoryModel Logical Simple
3
+ OpEntryPoint Fragment %1 "main" %2 %3
4
+ OpExecutionMode %1 OriginUpperLeft
5
+ OpName %5 "Data<Vec3>"
6
+ OpMemberName %5 0 "t"
7
+ OpMemberName %5 1 "value"
8
+ OpName %6 "Data<Vec3A>"
9
+ OpMemberName %6 0 "t"
10
+ OpMemberName %6 1 "value"
11
+ OpName %2 "input"
12
+ OpName %3 "output"
13
+ OpMemberDecorate %5 0 Offset 0
14
+ OpMemberDecorate %5 1 Offset 12
15
+ OpMemberDecorate %6 0 Offset 0
16
+ OpMemberDecorate %6 1 Offset 16
17
+ OpDecorate %2 Location 0
18
+ OpDecorate %3 Location 0
19
+ %7 = OpTypeFloat 32
20
+ %8 = OpTypeVector %7 3
21
+ %5 = OpTypeStruct %8 %7
22
+ %9 = OpTypePointer Input %5
23
+ %6 = OpTypeStruct %8 %7
24
+ %10 = OpTypePointer Output %6
25
+ %11 = OpTypeVoid
26
+ %12 = OpTypeFunction %11
27
+ %2 = OpVariable %9 Input
28
+ %3 = OpVariable %10 Output
29
+ %1 = OpFunction %11 None %12
30
+ %13 = OpLabel
31
+ %14 = OpLoad %5 %2
32
+ %15 = OpCompositeExtract %7 %14 0 0
33
+ %16 = OpCompositeExtract %7 %14 0 1
34
+ %17 = OpCompositeExtract %7 %14 0 2
35
+ %18 = OpCompositeConstruct %8 %15 %16 %17
36
+ %19 = OpCompositeExtract %7 %14 1
37
+ %20 = OpCompositeConstruct %6 %18 %19
38
+ OpStore %3 %20
39
+ OpNoLine
40
+ OpReturn
41
+ OpFunctionEnd
You can’t perform that action at this time.
0 commit comments