summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/constants/type-cast-const.slang
blob: d0291aa7d1586a3c4c1afd694ab5fb444ab4269e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//TEST(compute):COMPARE_COMPUTE: 
//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -profile cs_5_0

int check<let b : bool>(int x)
{
    // CHECK: int v{{.*}}[int(2)]
    int v[((int)b) + 1];
    for (int i = 0; i < ((int)b) + 1; i++)
        v[i] = i;
 	return (int)v[x];
}

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

[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal = tid;
    int outVal = check<true>(inVal + 1);
    outputBuffer[tid] = outVal;
}