summaryrefslogtreecommitdiff
path: root/tests/ir/factorial.slang
blob: 0ceff29bdc9ae9d0274bdee8b7d03dcf77802fda (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:EVAL:

StructuredBuffer<int> input;
RWStructuredBuffer<int> output;

int factorial(int n)
{
    int result = 1;
    while(n > 0)
    {
        result *= n;
        n--;
    }
    return result;
}

[numthreads(1, 1, 1)]
void main(
    uint tid   : SV_DispatchThreadIndex)
{
    output[tid] = factorial(input[tid]);
}