yum-mirror/slang

Making it easier to work with shaders

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

jsmall-nvidiaLanguage experiments (#2068)447b7e0e2

master
878 B41 linesraw
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2
3/* Find max algorithm. 
4
5Doesn't work because, can't compare T as it is any type.
6
7.slang(15): error 39999: no overload for '>' applicable to arguments of type (T, T)
8        if (arr[i] > m)
9                   ^
10core.meta.slang(2572): note 39999: candidate: func >(uint64_t, uint64_t) -> bool
11
12 */
13
14//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
15RWStructuredBuffer<float> outputBuffer;
16
17T findMax<T, let SIZE : int>(T arr[SIZE])
18{
19    T m = arr[0];
20    for (int i = 1; i < 8; ++i)
21    {
22        if (arr[i] > m)
23        {
24            m = arr[i];
25        }
26    }
27    return i;
28}
29
30
31[numthreads(4, 1, 1)]
32void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
33{
34    int index = dispatchThreadID.x;
35
36    int values[] = { 1, 3, - 1};
37    
38	outputBuffer[index] = findMax(values);
39}
40
41