yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix compile failures when using debug symbol. (#4069)9043bc552

master
1.1 KiB55 linesraw
1//TEST(compute):COMPARE_COMPUTE:-cpu -g0
2
3// Tests slang-llvm can deal with large items on stack. 
4// On some targets this requires special handling (_chkstk on windows for example) 
5
6struct LargeStruct
7{
8    int values[4096];
9};
10
11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
12RWStructuredBuffer<int> outputBuffer;
13
14//TEST_INPUT:ubuffer(data=[9 1000 27 34], stride=4):name inputBuffer
15StructuredBuffer<int> inputBuffer;
16
17LargeStruct _calcStruct(int a)
18{
19    LargeStruct s;
20    
21    int t = a;
22    
23    for (int i = 0; i < 4096; ++i)
24    {
25        s.values[i] = t;
26        
27        // Munge
28        t = t ^ (i * t) + (i - a) * 17 + inputBuffer[t & 3];
29    }
30    
31    return s;
32}
33
34int _calcValue(LargeStruct s)
35{
36    int v = 0;
37    for (int i = 0; i < 4096; ++i)
38    {
39        v ^= s.values[i];
40    }
41    return v + 1;
42}
43
44int _calc1(int a)
45{    
46    return _calcValue(_calcStruct(_calcValue(_calcStruct(_calcValue(_calcStruct(a ^ 19))))));
47}
48
49[numthreads(4, 1, 1)]
50void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
51{
52    int index = int(dispatchThreadID.x);
53    
54    outputBuffer[index] = _calc1(index) + 1;
55}