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
923 B44 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj -output-using-type
3T simpleTest<T : IArithmetic>(T v0, T v1)
4{
5    if (v0 > T(0))
6    {
7        return v0 + v1;
8    }
9    else
10    {
11        return -v0 * v1;
12    }
13}
14
15interface IMyInterface : IArithmetic
16{
17    int myMethod();
18}
19
20extension float : IMyInterface
21{
22    int myMethod() { return 4; }
23}
24
25extension double : IMyInterface
26{
27    int myMethod() { return 8; }
28}
29
30int genTest<T : IMyInterface>(T v0, T v1)
31{
32    vector<T, 2> v = vector<T, 2>(v0, v1);
33    return (v.x + v.y).myMethod();
34}
35
36//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
37RWStructuredBuffer<int> outputBuffer;
38
39[numthreads(4, 1, 1)]
40void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
41{
42    int tid = dispatchThreadID.x;
43    outputBuffer[tid] = int(simpleTest<float>(1.0f, 2.0f)) + genTest<float>(1.0f, 2.0f);
44}