diff options
| author | Yong He <yonghe@outlook.com> | 2025-05-29 08:05:57 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-29 08:05:57 -0700 |
| commit | faf042ecc3e688a1a3ffbe1ac44d18dd7ddf441a (patch) | |
| tree | b54abb2e65b7791d74335ead396cf762f805ab5c /tests/language-feature/tuple | |
| parent | 45d794f57d453a5564a7360400c5bfc04bf12b31 (diff) | |
Language version + tuple syntax. (#7230)
* Language version + tuple syntax.
* Fix compile error.
* regenerate documentation Table of Contents
* Fix.
* regenerate command line reference
* Fix.
* Fix.
* Fix more test failures.
* revert empty line change,
* Retrigger CI
* #version->#lang
* Update source/core/slang-type-text-util.cpp
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
* Remove comments.
* Fix parsing logic.
* Fix parser.
* Fix parser.
* update test comment
* Update options.
* regenerate documentation Table of Contents
* regenerate command line reference
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
Diffstat (limited to 'tests/language-feature/tuple')
| -rw-r--r-- | tests/language-feature/tuple/tuple-syntax.slang | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/language-feature/tuple/tuple-syntax.slang b/tests/language-feature/tuple/tuple-syntax.slang new file mode 100644 index 000000000..1d0a42b40 --- /dev/null +++ b/tests/language-feature/tuple/tuple-syntax.slang @@ -0,0 +1,42 @@ +// Test tuple construction syntax. + +#language 2026 + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil -shaderobj +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +void store(inout Tuple<int, float, uint> t) +{ + t._1_2 = (3.0, 4u); +} + +struct MyType +{ + int x; + int y; + __init(Tuple<int, int> t){ + x = t._0; + y = t._1; + } +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + var t = (1, 2.0, 3u); + store(t); + let y = t._1_2_0; + + // CHECK: 4 + outputBuffer[0] = y._1; + + // This should mean cast<MyType>(makeTuple(1,2)) + let m = (MyType)(1,2); + // CHECK: 3 + outputBuffer[1] = m.x + m.y; +} |
