yum-mirror/slang

Making it easier to work with shaders

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

skallweitNVenable more metal tests (#4326)712ce653d

master
831 B29 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
3
4T sum<T:IFloat>(IArray<T> array)
5{
6    T result = T(0);
7    for (int i = 0; i < array.getCount(); i++)
8    {
9        result = result + array[i];
10    }
11    return result;
12}
13
14//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
15RWStructuredBuffer<float> outputBuffer;
16
17[numthreads(1, 1, 1)]
18void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
19{
20    float arr[3] = { 1.0, 2.0, 3.0 };
21    float4 v = float4(1.0, 2.0, 3.0, 4.0);
22    float2x2 m = float2x2(1.0, 2.0, 3.0, 4.0);
23    outputBuffer[0] = sum(arr);
24    outputBuffer[1] = sum(v);
25    outputBuffer[2] = sum(sum(m));
26    // CHECK: 6.0
27    // CHECK: 10.0
28    // CHECK: 10.0
29}