summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/properties/property-decl.slang
blob: ac0cee666433369c31703718ad53aad09cc7810c (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
// property-decl.slang

//TEST(compute):COMPARE_COMPUTE: -shaderobj

// Test that users can declare properties and access them
// with ordinary dot syntax.

struct Test
{
    int storage;

    property value : int
    {
        get { return storage; }
        set(newValue) { storage = newValue; }
    }
}

int test(int val)
{
    Test t;
    t.storage = 0;

    // setter
    t.value = val ^ 0x100;

    // getter + setter
    t.value ^= 0x1;

    // getter
    int result = t.value;

    return result;
}


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

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal = tid;
    int outVal = test(inVal);
    outputBuffer[tid] = outVal;
}