yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyClean up the way that lookup "through" a base type is encoded (#1519)bc0d0f9e2

master
918 B53 linesraw
1// Note: disabled because extension of interfaces shouldn't
2// work the way this test assumes it does...
3
4//TEST_DISABLED(compute):COMPARE_COMPUTE:
5//TEST_DISABLED(compute):COMPARE_COMPUTE:-cpu
6
7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
8RWStructuredBuffer<float> outputBuffer;
9
10interface IOp
11{
12    float addf(float u, float v);
13}
14
15interface ISub
16{
17    float subf(float u, float v);
18}
19
20extension IOp : ISub
21{
22}
23
24struct Simple : IOp
25{
26    float base;
27    float addf(float u, float v)
28    {
29        return u+v;
30    }
31};
32
33__extension Simple : ISub
34{
35    float subf(float u, float v)
36    {
37        return base+u-v;
38    }
39};
40
41float testAddSub<T:IOp>(T t)
42{
43    return t.subf(t.addf(1.0, 1.0), 1.0);
44}
45
46[numthreads(4, 1, 1)]
47void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
48{
49    Simple s;
50    s.base = 0.0;
51	float outVal = testAddSub(s);
52	outputBuffer[dispatchThreadID.x] = outVal;
53}