summaryrefslogtreecommitdiffstats
path: root/tests/bugs/mutating/resource-specialization-inout.slang
blob: d2f9a3b9ec0c5c5ad5d88b0e884ebb86f7533355 (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
// Bug related to resource specialization on unused resource typed fields.

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj

//TEST_INPUT: Texture2D(size=4, content = one):name t2D
Texture2D t2D;

struct MyType
{
    Texture2D tex;
    int data;
    [mutating]
    void f(int val)
    {
        data += val;
    }
}

int test(int val)
{
    MyType t = {t2D, 0};
    t.f(val);
    return t.data;
}

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

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inputVal = tid;
    int outputVal = test(inputVal);
    gOutputBuffer[tid] = outputVal;
}