diff options
| author | Yong He <yonghe@outlook.com> | 2020-07-07 13:25:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-07 13:25:47 -0700 |
| commit | f8cc28c958e0d1d9701381448c05b6e79dfe4e99 (patch) | |
| tree | 8fa11f7e58f2b6d62d998e77683fa06480c8cee8 /tests/compute | |
| parent | 1301f6bc85f4005a548a5a63601689616d511d0b (diff) | |
Add a test case for dynamic dispatch with `This` type in interface decl. (#1431)
* Add a test case for dynamic dispatch with `This` type in interface decl.
* Update comments
* fix typo in comments
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/dynamic-dispatch-5.slang | 39 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-5.slang.expected.txt | 4 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/compute/dynamic-dispatch-5.slang b/tests/compute/dynamic-dispatch-5.slang new file mode 100644 index 000000000..6c403860b --- /dev/null +++ b/tests/compute/dynamic-dispatch-5.slang @@ -0,0 +1,39 @@ +//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -allow-dynamic-code +//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -allow-dynamic-code + +// Test dynamic dispatch code gen for general `This` type. + +interface IInterface +{ + int Compute(int inVal, This other); +}; + +int GenericCompute<T:IInterface>(int inVal, T obj, T other) +{ + return obj.Compute(inVal, other); +} + +struct Impl : IInterface +{ + int base; + int Compute(int inVal, This other) { return other.base + base + inVal; } +}; +int test(int inVal) +{ + Impl obj1, obj2; + obj1.base = 1; + obj2.base = 2; + return GenericCompute<Impl>(inVal, obj1, obj2); +} + +//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = outputBuffer[tid]; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/compute/dynamic-dispatch-5.slang.expected.txt b/tests/compute/dynamic-dispatch-5.slang.expected.txt new file mode 100644 index 000000000..dc5f2efd9 --- /dev/null +++ b/tests/compute/dynamic-dispatch-5.slang.expected.txt @@ -0,0 +1,4 @@ +3 +4 +5 +6 |
