diff options
| author | Yong He <yonghe@outlook.com> | 2022-09-05 00:38:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-05 00:38:45 -0700 |
| commit | ea0845285b0307d153a91d6f0a5010fc2d7219ed (patch) | |
| tree | bf2d8f7258b2681deddf3391c551c5ff2b1a7918 /tests/language-feature/operators | |
| parent | 2a869c105dcc23ede8f5e6e16b08261f45aa5aad (diff) | |
Multi parameter `__subscript` (#2392)
* Multi parameter `__subscript`
* Fix.
* Fix bugs.
* Fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature/operators')
| -rw-r--r-- | tests/language-feature/operators/subscript-multi-dimension.slang | 31 | ||||
| -rw-r--r-- | tests/language-feature/operators/subscript-multi-dimension.slang.expected.txt | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/language-feature/operators/subscript-multi-dimension.slang b/tests/language-feature/operators/subscript-multi-dimension.slang new file mode 100644 index 000000000..c15e390dc --- /dev/null +++ b/tests/language-feature/operators/subscript-multi-dimension.slang @@ -0,0 +1,31 @@ +//TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj -output-using-type + +struct S +{ + int4 data; + __subscript(int x, int y) -> int + { + [__unsafeForceInlineEarly] get { return data[y * 2 + x]; } + [__unsafeForceInlineEarly] set { data[y * 2 + x] = newValue;} + } +} + +int test() +{ + S s = {}; + s[1, 0] = 1; + s[1, 1] = 2; + let b = s[1, 0] + s[1, 1]; + return b; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + outputBuffer[tid] = test(); +} diff --git a/tests/language-feature/operators/subscript-multi-dimension.slang.expected.txt b/tests/language-feature/operators/subscript-multi-dimension.slang.expected.txt new file mode 100644 index 000000000..2640fdeb6 --- /dev/null +++ b/tests/language-feature/operators/subscript-multi-dimension.slang.expected.txt @@ -0,0 +1,5 @@ +type: int32_t +3 +3 +3 +3 |
