summaryrefslogtreecommitdiffstats
path: root/tests/spirv/pointer-from-user-guide.slang
blob: 662579c2b067be939664efc63a40d2154e455e5b (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
//TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly

// This test is to verify the example on the user guide
// and prevent any regressions.

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

struct MyType
{
    float a;
};

float test(MyType* pObj)
{
    //SPV: OpTypePointer
    MyType* pNext = pObj + 1;
    MyType* pNext2 = &pNext[1];
    return pNext.a + pNext->a + (*pNext2).a + pNext2[0].a;
}

cbuffer Constants
{
    MyType *ptr;
};

[numthreads(1,1,1)]
void computeMain()
{
    outputBuffer[0] = test(ptr);
}