diff options
| author | Yong He <yonghe@outlook.com> | 2022-09-01 10:01:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-01 10:01:13 -0700 |
| commit | 4a94473eb34376dd8474f8ca3f2834b5c1daac14 (patch) | |
| tree | 218714e897a2821c2b09727590f364519afe3915 /tests | |
| parent | 3c0177134d126956336865623ea3d6861be59cfa (diff) | |
Deduplicate consts and IRSpecialize in IR, propagate type info for `IntVal`. (#2388)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/generic-type-duplication.slang | 33 | ||||
| -rw-r--r-- | tests/bugs/generic-type-duplication.slang.expected.txt | 4 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/generic-type-duplication.slang b/tests/bugs/generic-type-duplication.slang new file mode 100644 index 000000000..4117a7f81 --- /dev/null +++ b/tests/bugs/generic-type-duplication.slang @@ -0,0 +1,33 @@ +// Test that the same generic type specialization does not get emitted as different types in target code. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj + +struct MyGeneric<let addOne: bool> +{ + int value; + + [mutating] + void load(RWStructuredBuffer<MyGeneric<addOne>> buffer) + { + var m = buffer.Load(0); + if (addOne) + value = m.value + 1; + else + value = m.value; + } +}; + +//TEST_INPUT:set myBuffer = ubuffer(data=[1],stride=4) +RWStructuredBuffer<MyGeneric<true>> myBuffer; + +//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) +{ + MyGeneric<true> obj; + obj.load(myBuffer); + outputBuffer[dispatchThreadID.x] = obj.value; +} diff --git a/tests/bugs/generic-type-duplication.slang.expected.txt b/tests/bugs/generic-type-duplication.slang.expected.txt new file mode 100644 index 000000000..487b11653 --- /dev/null +++ b/tests/bugs/generic-type-duplication.slang.expected.txt @@ -0,0 +1,4 @@ +2 +2 +2 +2 |
