diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-16 10:52:10 -0800 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-01-16 10:52:10 -0800 |
| commit | 59691aeeb013c5bb7cdaa31a6fc572eebd8be610 (patch) | |
| tree | 310754847c4c83ffa8fd97fcaadc7cdf7b14c253 /tests | |
| parent | 68fd4485708bf98c66e27e330692138f3eb6f289 (diff) | |
Allow extension on interface (#369)
This completes item 5 in issue #361.
The interesting change is that when checking for interface conformance, we include the requirements (include transitive interfaces) defined in extensions as well. (check.cpp line 1946)
All the other changes are for one thing: reoder the semantic checkings to two explicit stages: check header and check body. In check header phase, we check everything except function bodies, register all extensions with their target decls, then check interface conformances for all concrete types. In body checking phase, we look inside the function bodies and check concrete statements/expressions. This change ensures that we take extension into consideration in all places where it should be.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/extension-on-interface.slang | 49 | ||||
| -rw-r--r-- | tests/compute/extension-on-interface.slang.expected.txt | 4 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/compute/extension-on-interface.slang b/tests/compute/extension-on-interface.slang new file mode 100644 index 000000000..1d3fb5e30 --- /dev/null +++ b/tests/compute/extension-on-interface.slang @@ -0,0 +1,49 @@ +//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 IOp +{ + float addf(float u, float v); +} + +interface ISub +{ + float subf(float u, float v); +} + +extension IOp : ISub +{ +} + +struct Simple : IOp +{ + float base; + float addf(float u, float v) + { + return u+v; + } +}; + +__extension Simple : ISub +{ + float subf(float u, float v) + { + return base+u-v; + } +}; + +float testAddSub<T:IOp>(T t) +{ + return t.subf(t.addf(1.0, 1.0), 1.0); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + Simple s; + s.base = 0.0; + float outVal = testAddSub(s); + outputBuffer[dispatchThreadID.x] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/extension-on-interface.slang.expected.txt b/tests/compute/extension-on-interface.slang.expected.txt new file mode 100644 index 000000000..cc5e55ab6 --- /dev/null +++ b/tests/compute/extension-on-interface.slang.expected.txt @@ -0,0 +1,4 @@ +3F800000 +3F800000 +3F800000 +3F800000 |
