summaryrefslogtreecommitdiff
path: root/tests/metal/nested-struct-fragment-input.slang
blob: 727b5b1e5e08ada89296b49e2af3966a9eb13b5f (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
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain

// METAL: COARSEVERTEX_7
// METAL: COARSEVERTEX_6

// Ensure each attribute which may vary only appears once.
// Ensure 1, 2, 3, 4 all appear

// METAL-DAG: [[ATTR1:COARSEVERTEX_(1|2|3|4)]]

// METAL-NOT: [[ATTR1]]
// METAL-DAG: [[ATTR2:COARSEVERTEX_(1|2|3|4)]]

// METAL: COARSEVERTEX{{(_0|())}}

// METAL-NOT: [[ATTR2]]
// METAL-DAG: [[ATTR3:COARSEVERTEX_(1|2|3|4)]]

// METAL-NOT: [[ATTR3]]
// METAL-DAG: [[ATTR4:COARSEVERTEX_(1|2|3|4)]]

// METALLIB: @fragmentMain

RWStructuredBuffer<float> outputBuffer;

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

struct MiddleFragment1
{
    float p1;
    BottomFragment1 p2;
    BottomFragment2 p3;
};
struct TopFragment
{
    float p1 : CoarseVertex7;
    MiddleFragment1 p2 : CoarseVertex6;
    MiddleFragment1 p3 : CoarseVertex0;
};

struct FragmentStageInput
{
	TopFragment	coarseVertex : CoarseVertex;
};

float4 fragmentMain(FragmentStageInput input)
{
    // 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{{.*}}=

    outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
    return float4(0, 0, 0, 0);
}