diff options
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/interfaces/interface-conjunction.slang | 49 | ||||
| -rw-r--r-- | tests/language-feature/interfaces/interface-conjunction.slang.expected.txt | 4 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/language-feature/interfaces/interface-conjunction.slang b/tests/language-feature/interfaces/interface-conjunction.slang new file mode 100644 index 000000000..b5ec708a5 --- /dev/null +++ b/tests/language-feature/interfaces/interface-conjunction.slang @@ -0,0 +1,49 @@ +// interface-conjunction.slang + +// Test that we can compose interfaces with `&` + +//TEST(compute):COMPARE_COMPUTE: -shaderobj + +interface IFirst +{ + int getFirst(); +} + +interface ISecond +{ + int getSecond(); +} + +struct Pair : IFirst, ISecond +{ + int first; + int second; + + int getFirst() { return first; } + int getSecond() { return second; } +} + +typealias IBoth = IFirst & ISecond; + +int add<T : IBoth>(T input) +{ + return 2*input.getFirst() + input.getSecond(); +} + +int test(int value) +{ + Pair p = { value, (value+1) * 256 }; + return add(p); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/interfaces/interface-conjunction.slang.expected.txt b/tests/language-feature/interfaces/interface-conjunction.slang.expected.txt new file mode 100644 index 000000000..23f910a90 --- /dev/null +++ b/tests/language-feature/interfaces/interface-conjunction.slang.expected.txt @@ -0,0 +1,4 @@ +100 +202 +304 +406 |
