diff options
| author | Yong He <yonghe@outlook.com> | 2023-11-01 22:49:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-01 22:49:30 -0700 |
| commit | e712ebd93aa9a2845bde3ea541aaa7cd415548b7 (patch) | |
| tree | 14d2bf34cb35e7433a80abc8feb612184f6a52ec /tests/language-feature/enums | |
| parent | 6aca3813c4ccc496c0f9b2db293acb546aa11d2d (diff) | |
Add mnemonic parsing for `intrinsic_type` modifier. (#3306)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature/enums')
| -rw-r--r-- | tests/language-feature/enums/strongly-typed-id.slang | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/language-feature/enums/strongly-typed-id.slang b/tests/language-feature/enums/strongly-typed-id.slang new file mode 100644 index 000000000..70f655538 --- /dev/null +++ b/tests/language-feature/enums/strongly-typed-id.slang @@ -0,0 +1,44 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj + +enum MyId : uint {} +extension MyId { uint get() { return (uint)this; } } + +int test(MyId id) +{ + if (id.get() == 4) + { + return (int)id; + } + return 0; +} + +__intrinsic_type(UInt) +struct MyId2 +{ + __init(uint val) { this = __slang_noop_cast<MyId2>(val); } + + __intrinsic_op(0) int get(); +} + +int test2(MyId2 id) +{ + if (id.get() == 4) + { + return id.get(); + } + return 0; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + uint inVal = tid; + uint outVal = test(MyId(4)) + test2(MyId2(4)); + // CHECK: 8 + outputBuffer[tid] = outVal; +} + |
