summaryrefslogtreecommitdiffstats
path: root/tests/metal/nested-struct-fragment-output.slang
blob: d13b3cdbf53118ebd072f90fbb88f39d8d3f6284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain

//METAL-DAG: color(0)
//METAL-DAG: color(1)
//METAL-DAG: color(2)
//METAL-DAG: color(3)
//METAL-DAG: color(4)
//METAL-DAG: color(5)
//METAL-DAG: color(6)
//METAL-NOT: color(7)

//WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(5) [[VAR5:[A-Za-z_0-9]+]]
//WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]]
//WGSL-NOT:@location(7)

//METALLIB: @fragmentMain
//WGSLSPIRV: %fragmentMain = OpFunction %void None

RWStructuredBuffer<float> outputBuffer;

struct BottomFragment1
{
    float p1;
};
struct BottomFragment2
{
    float p1;
};

struct MiddleFragment1
{
    float p1;
    BottomFragment1 p2;
    BottomFragment2 p3;
};
struct TopFragment
{
    float p1;
    MiddleFragment1 p2;
    MiddleFragment1 p3;
};

struct FragmentStageInput
{
	float4	coarseVertex	: CoarseVertex;
};

struct FragmentStageOutput
{
	TopFragment fragment	: SV_Target;
};

//WGSL: fn fragmentMain{{.*}}-> [[ReturnType:FragmentStageOutput[_0-9]+]]
FragmentStageOutput fragmentMain(FragmentStageInput input)
{
    FragmentStageOutput output;
    output.fragment.p1 = 1;

    output.fragment.p2.p1 = 3;
    output.fragment.p2.p2.p1 = 4;
    output.fragment.p2.p3.p1 = 5;

    output.fragment.p3.p1 = 8;
    output.fragment.p3.p2.p1 = 9;
    output.fragment.p3.p3.p1 = 10;

    // METAL-DAG: ={{.*}}.p1

    // METAL-DAG: ={{.*}}.p2{{.*}}.p1
    // METAL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}.p1
    // METAL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}.p1

    // METAL-DAG: ={{.*}}.p3{{.*}}.p1
    // METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
    // METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1

    // WGSL: var [[ReturnVar:[A-Za-z_0-9]+]] : [[ReturnType]]
    // WGSL-DAG: [[ReturnVar]].[[VAR0]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR1]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR2]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR3]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR4]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR5]]{{.*}} = {{.*}};
    // WGSL-DAG: [[ReturnVar]].[[VAR6]]{{.*}} = {{.*}};

    outputBuffer[0] = 1;
    return output;
}