diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-17 22:41:56 -0700 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2020-06-17 23:47:11 -0700 |
| commit | 8c6e02bd094bbc0c9afb141265be9675f99ddb61 (patch) | |
| tree | 1c81d73c1b1eddcc3e00fe1ff28816d6dec0c032 /tests | |
| parent | d1a8cd23d15d0001131b6f01b0c9bc461279f760 (diff) | |
Dynamic dipatch non-static functions.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/dynamic-dispatch-1.slang | 38 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-1.slang.expected.txt | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/compute/dynamic-dispatch-1.slang b/tests/compute/dynamic-dispatch-1.slang new file mode 100644 index 000000000..9e63ee124 --- /dev/null +++ b/tests/compute/dynamic-dispatch-1.slang @@ -0,0 +1,38 @@ +//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -allow-dynamic-code + +// Test dynamic dispatch code gen for non-static member functions. + +interface IInterface +{ + int Compute(int inVal); +}; + +int GenericCompute<T:IInterface>(T obj, int inVal) +{ + return obj.Compute(inVal); +} + +struct Impl : IInterface +{ + int base; + int Compute(int inVal) { return base + inVal * inVal; } +}; + +int test(int inVal) +{ + Impl obj; + obj.base = 1; + return GenericCompute<Impl>(obj, inVal); +} + +//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-1.slang.expected.txt b/tests/compute/dynamic-dispatch-1.slang.expected.txt new file mode 100644 index 000000000..146ab3c8c --- /dev/null +++ b/tests/compute/dynamic-dispatch-1.slang.expected.txt @@ -0,0 +1,4 @@ +1 +2 +5 +A |
