yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jsmall-nvidiaSource embedding for output (#2889)972a93145

master
1016 B45 linesraw
1//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style binary-text -source-embed-name hello 
2
3// CHECK: const char hello[] =
4// CHECK: const size_t hello_sizeInBytes =
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
7RWStructuredBuffer<int> outputBuffer;
8
9// Test loop handling, with more complex structure
10
11int calcThing(int offset)
12{
13    int total = 0;
14    int another[2] = { 1, 2};
15    
16    for (int k = 0; k < 20; ++k)
17    {       
18        for (int i = 0; i < 17; ++i)
19        {
20            another[i & 1] += k + i;
21        }
22        
23        total += another[k & 1];
24        
25        if ((k + 7) % 5 == 4)
26        {
27            return 1;
28        }
29    }
30    
31    if (total > 4)
32    {
33        total = -total;
34    }
35    
36    return total;
37}
38
39[numthreads(4, 1, 1)]
40void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
41{    
42    int index = int(dispatchThreadID.x);
43
44    outputBuffer[index] = calcThing(index);
45}