diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-15 19:22:39 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-15 19:22:39 -0800 |
| commit | 68fd4485708bf98c66e27e330692138f3eb6f289 (patch) | |
| tree | b2bac3c7fdf9f1bd218e2b448a0fd5cf03a467fd /tests | |
| parent | 8abae0515d734c51e7d55c44ccfdadefea8c6802 (diff) | |
| parent | 513f56b85e3678bbaf40f74397e8d9a864761c08 (diff) | |
Merge pull request #367 from csyonghe/extension2
Support transitive interfaces
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/transitive-interface.slang | 66 | ||||
| -rw-r--r-- | tests/compute/transitive-interface.slang.expected.txt | 4 |
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/compute/transitive-interface.slang b/tests/compute/transitive-interface.slang new file mode 100644 index 000000000..04ececf93 --- /dev/null +++ b/tests/compute/transitive-interface.slang @@ -0,0 +1,66 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<float> outputBuffer; + +interface IAdd +{ + float addf(float u, float v); +} + +interface ISub +{ + float subf(float u, float v); +} + +interface IAddAndSub : IAdd, ISub +{ +} + +struct Simple : IAddAndSub +{ + float addf(float u, float v) + { + return u+v; + } + float subf(float u, float v) + { + return u-v; + } +}; + +float testAdd<T:IAdd>(T t) +{ + return t.addf(1.0, 1.0); +} + +interface IAssoc +{ + associatedtype AT : IAdd; +} + +struct AssocImpl : IAssoc +{ + typedef Simple AT; +}; + +float testAdd2<T:IAssoc>(T assoc) +{ + T.AT obj; + return obj.addf(1.0, 1.0); +} + +float testSub<T:ISub>(T t, float base) +{ + return t.subf(base, 1.0); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + AssocImpl s; + float outVal = testAdd2(s); + Simple s1; + outVal += testSub(s1, outVal); + outputBuffer[dispatchThreadID.x] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/transitive-interface.slang.expected.txt b/tests/compute/transitive-interface.slang.expected.txt new file mode 100644 index 000000000..e143b7f20 --- /dev/null +++ b/tests/compute/transitive-interface.slang.expected.txt @@ -0,0 +1,4 @@ +3F800000 +3F800000 +3F800000 +3F800000
\ No newline at end of file |
