diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-18 15:06:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 15:06:14 -0700 |
| commit | 515d8eb0cd719ae31db2f6e03751011a123bc0ba (patch) | |
| tree | 3e78893a74af856fb29158078bed7099a567f5dd /tests/compute/dynamic-dispatch-1.slang | |
| parent | e2d21026d115dc61296b47dcc990534f1844bc7f (diff) | |
| parent | aa6aca498cd1f7fbbdb143e72dd48b1d714c8fbb (diff) | |
Merge branch 'master' into feature/prelude-fix
Diffstat (limited to 'tests/compute/dynamic-dispatch-1.slang')
| -rw-r--r-- | tests/compute/dynamic-dispatch-1.slang | 38 |
1 files changed, 38 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; +} |
