diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-04-19 16:43:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-19 16:43:21 -0700 |
| commit | 2da28c50d9c3699692eccde4b86d0b8d2323e55c (patch) | |
| tree | 6c12a4673210f833c38c147e7b937f1a14dec519 /tests | |
| parent | e0aa53fb01aa550219c6f71644e6e7a1202b90b3 (diff) | |
Support arithmetics on generic arguments (#3968)
Resovles an issue #3935
Slang had to fold the generic arguments after specialization.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-3935.slang | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/bugs/gh-3935.slang b/tests/bugs/gh-3935.slang new file mode 100644 index 000000000..9c8e9f19c --- /dev/null +++ b/tests/bugs/gh-3935.slang @@ -0,0 +1,35 @@ +// Test if generic arguments using arithmetics are folded properly. + +//TEST:SIMPLE(filecheck=HLSL): -stage compute -entry computeMain -target hlsl + +RWStructuredBuffer<float> outputBuffer; + +__generic<let ArraySize:int> +struct MyStruct +{ + int elems[ArraySize]; +}; + +__generic<let ArraySize:int> +MyStruct<ArraySize / 2> Reduce(MyStruct<ArraySize> o) +{ + MyStruct<ArraySize / 2> result; + //HLSL:[[ReturnType:MyStruct_[0-9]*]] Reduce + //HLSL:[[ReturnType]] result + + result.elems[0] = o.elems[0]; + + // Error happened here as the return type differs + // from the type of "result". + return result; +} + +[numthreads(1, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + MyStruct<4> a; + a.elems[0] = 2; + + let result = Reduce(a); + outputBuffer[0] = result.elems[0]; +} |
