yum-mirror/slang

Making it easier to work with shaders

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

Yong HeInitial support for immutable lambda expressions. (#6914)7f1df9d0b

master
671 B30 linesraw
1
2//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type
3//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type
4
5//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4)
6RWStructuredBuffer<float> outputBuffer;
7
8struct Matrix
9{
10    float data[16];
11
12    [mutating]
13    void map(IFunc<float, float> f)
14    {
15        for (int i = 0; i < 16; ++i)
16        {
17            data[i] = f(data[i]);
18        }
19    }
20}
21
22[numthreads(1,1,1)]
23void computeMain()
24{
25    Matrix m = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
26    int c = 2;
27    m.map((float x) => (float)(x * c));
28    outputBuffer[0] = m.data[3];
29    // CHECK: 8.0
30}