yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

skallweitNVenable more metal tests (#4326)712ce653d

master
822 B47 linesraw
1// property-decl.slang
2
3//TEST(compute):COMPARE_COMPUTE: -shaderobj
4
5// Test that users can declare properties and access them
6// with ordinary dot syntax.
7
8struct Test
9{
10    int storage;
11
12    property value : int
13    {
14        get { return storage; }
15        set(newValue) { storage = newValue; }
16    }
17}
18
19int test(int val)
20{
21    Test t;
22    t.storage = 0;
23
24    // setter
25    t.value = val ^ 0x100;
26
27    // getter + setter
28    t.value ^= 0x1;
29
30    // getter
31    int result = t.value;
32
33    return result;
34}
35
36
37//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
38RWStructuredBuffer<int> outputBuffer;
39
40[numthreads(4, 1, 1)]
41void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
42{
43    int tid = dispatchThreadID.x;
44    int inVal = tid;
45    int outVal = test(inVal);
46    outputBuffer[tid] = outVal;
47}