diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-04 10:18:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-04 10:18:44 -0700 |
| commit | 8f962894fd38edb47d782d303ac9ff87b3a3bb6a (patch) | |
| tree | 449d0d58ca7d90a11759372c9dc82650a565f96a /tests | |
| parent | 5e10f1b4f0654515af1fcb29e8d1f35e691c8aa3 (diff) | |
Allow mixing unspecialized and specialized existential parameters. (#1533)
* Allow mixing unspecialized and specialized existential parameters.
* Fixes.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/dynamic-dispatch-12.slang | 43 | ||||
| -rw-r--r-- | tests/compute/dynamic-dispatch-12.slang.expected.txt | 4 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/compute/dynamic-dispatch-12.slang b/tests/compute/dynamic-dispatch-12.slang new file mode 100644 index 000000000..67598033d --- /dev/null +++ b/tests/compute/dynamic-dispatch-12.slang @@ -0,0 +1,43 @@ +// Test using interface typed shader parameters with dynamic dispatch. + +//TEST(compute):COMPARE_COMPUTE:-cpu +//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -disable-specialization + +[anyValueSize(8)] +interface IInterface +{ + int run(int input); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer<int> gOutputBuffer; + +//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb +ConstantBuffer<IInterface> gCb; + +//TEST_INPUT:cbuffer(data=[rtti(MyImpl) witness(MyImpl, IInterface) 1 0], stride=4):name=gCb1 +ConstantBuffer<IInterface> gCb1; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + let tid = dispatchThreadID.x; + + let inputVal : int = tid; + let outputVal = gCb.run(inputVal) + gCb1.run(inputVal); + + gOutputBuffer[tid] = outputVal; +} + +// Specialize gCb1, but not gCb2 +//TEST_INPUT: globalExistentialType MyImpl +//TEST_INPUT: globalExistentialType __Dynamic +// Type must be marked `public` to ensure it is visible in the generated DLL. +public struct MyImpl : IInterface +{ + int val; + int run(int input) + { + return input + val; + } +}; diff --git a/tests/compute/dynamic-dispatch-12.slang.expected.txt b/tests/compute/dynamic-dispatch-12.slang.expected.txt new file mode 100644 index 000000000..628d2a8fd --- /dev/null +++ b/tests/compute/dynamic-dispatch-12.slang.expected.txt @@ -0,0 +1,4 @@ +2 +4 +6 +8 |
