yum-mirror/slang

Making it easier to work with shaders

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

Darren WihandiFix exact-match witness synthesis for static functions (#6204)cf66563cf

master
1.0 KiB45 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute  -output-using-type
2
3//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0 0], stride=4);
4RWStructuredBuffer<int> outputBuffer;
5
6interface Base
7{
8    int getValue();
9    int getValue(float a);
10}
11
12struct Impl1 : Base
13{
14    // This is static and allowed to implement interface's non-static method.
15    static int getValue() { return 5; }
16    int getValue(float a) { return int(a) + 5; }
17}
18
19struct Impl2 : Base
20{
21    // This is static with one default parameter and allowed to implement interface's non-static method.
22    static int getValue(int a = 3) { return a + 5; }
23    int getValue(float a) { return int(a) + 5; }
24}
25
26int callGet<T : Base>(T t)
27{
28    return t.getValue();
29}
30
31[numthreads(1, 1, 1)]
32void computeMain()
33{
34    Impl1 impl1;
35    Impl2 impl2;
36
37    uint index = 0;
38
39    outputBuffer[index++] = Impl1::getValue();
40    outputBuffer[index++] = callGet(impl1);
41
42    outputBuffer[index++] = Impl2::getValue();
43    outputBuffer[index++] = callGet(impl2);
44    outputBuffer[index++] = impl2.getValue(5);
45}