diff options
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/specialize-existential-in-generic.slang | 42 | ||||
| -rw-r--r-- | tests/bugs/specialize-existential-in-generic.slang.expected.txt | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/bugs/specialize-existential-in-generic.slang b/tests/bugs/specialize-existential-in-generic.slang new file mode 100644 index 000000000..31ef75512 --- /dev/null +++ b/tests/bugs/specialize-existential-in-generic.slang @@ -0,0 +1,42 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj + +[Specialize] +interface IAssoc +{ + int getInner(); +} + +interface IFoo +{ + associatedtype Assoc : IAssoc; + Assoc getValue(); +} + +struct Impl : IFoo +{ + struct Assoc : IAssoc { int getInner() { return 1; } } + Assoc getValue() { Assoc r; return r; } +} + +struct GenType<T : IFoo> +{ + T obj; + int doThing() + { + IAssoc soc = obj.getValue(); // "boxing" into an existential + + // a specialized version of this function should call specialized method instead of going through dynamic dispatch. + return soc.getInner(); + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer +RWStructuredBuffer<int> gOutputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + GenType<Impl> val; + gOutputBuffer[tid] = val.doThing(); +}
\ No newline at end of file diff --git a/tests/bugs/specialize-existential-in-generic.slang.expected.txt b/tests/bugs/specialize-existential-in-generic.slang.expected.txt new file mode 100644 index 000000000..ef529012e --- /dev/null +++ b/tests/bugs/specialize-existential-in-generic.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +1 +1
\ No newline at end of file |
