summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/tuple/tuple-syntax.slang
blob: ec00f1661ca5b80125d2348c2eb4fab4d739bdae (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
// Test tuple construction syntax.

#language 2026

//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj

//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

void store(inout Tuple<int, float, uint> t)
{
    t._1_2 = (3.0, 4u);
}

struct MyType
{
    int x;
    int y;
    __init(Tuple<int, int> t){
        x = t._0;
        y = t._1;
    }
}

[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    var t = (1, 2.0, 3u);
    store(t);
    let y = t._1_2_0;

    // CHECK: 4
    outputBuffer[0] = y._1;

    // This should mean cast<MyType>(makeTuple(1,2))
    let m = (MyType)(1,2);
    // CHECK: 3
    outputBuffer[1] = m.x + m.y;
}