summaryrefslogtreecommitdiffstats
path: root/tests/spirv/debug-type-pointer.slang
blob: ff6d5e6b8fe7d24008d81bb32fd704cc39f1e6a6 (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
//TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -g2
//TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -g2 -zero-initialize

// This test is to check if DebugTypePointer is emitted when "-g2" option is used

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

//SPV: [[STRING_float:%[1-9][0-9]*]] = OpString "float"
//SPV: [[STRING_pValue:%[1-9][0-9]*]] = OpString "pValue"
//SPV: [[STRING_uint64:%[1-9][0-9]*]] = OpString "uint64"
//SPV: [[STRING_pNext:%[1-9][0-9]*]] = OpString "pNext"

struct LinkedNode
{
    float value;

    //SPV: [[TYPE_float:%[1-9][0-9]*]] = OpExtInst %void %{{[0-9]*}} DebugTypeBasic [[STRING_float]]
    //SPV: [[TYPE_float_ptr:%[1-9][0-9]*]] = OpExtInst %void %{{[0-9]*}} DebugTypePointer [[TYPE_float]]
    //SPV: DebugTypeMember [[STRING_pValue]] [[TYPE_float_ptr]]
    float *pValue;

    //SPV: [[TYPE_uint64:%[1-9][0-9]*]] = OpExtInst %void %{{[0-9]*}} DebugTypeBasic [[STRING_uint64]]
    //SPV: DebugTypeMember [[STRING_pNext]] [[TYPE_uint64]]
    LinkedNode *pNext;
};

float test(LinkedNode *pNode)
{
    //SPV: DebugValue %pNodeNext
    LinkedNode *pNodeNext = pNode->pNext;
    return *(pNode->pValue) + pNodeNext->value;
}

cbuffer Constants
{
    LinkedNode *head;
};

[numthreads(1,1,1)]
void computeMain()
{
    LinkedNode node; // required to emit DebugTypeXXX
    outputBuffer[0] = test(head);
}