diff options
| author | Yong He <yonghe@outlook.com> | 2024-07-31 17:35:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-31 17:35:08 -0700 |
| commit | 4c6b0a2831a7edd1419bd0b2e6edd089080e07be (patch) | |
| tree | 54557efa8bfc9e316014fe1555f07c94afa93cd4 /tests | |
| parent | bab4b821dc6bcee4ff86751743762584c17e9103 (diff) | |
Allow generic type deduction from ParameterBlock arguments. (#4766)
* Allow generic type deduction from ParameterBlock arguments.
* Fix test.
* Update expected failure list.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/expected-failure-github.txt | 2 | ||||
| -rw-r--r-- | tests/language-feature/generics/parameter-block-unify.slang | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt index f157d2b9a..524930f62 100644 --- a/tests/expected-failure-github.txt +++ b/tests/expected-failure-github.txt @@ -5,5 +5,3 @@ tests/language-feature/saturated-cooperation/fuse-product.slang (vk) tests/language-feature/saturated-cooperation/fuse.slang (vk) tests/bugs/byte-address-buffer-interlocked-add-f32.slang (vk) tests/serialization/obfuscated-serialized-module-test.slang.2 syn (mtl) -tests/render/cross-compile-entry-point.slang.2 syn (mtl) -tests/bindings/nested-parameter-block-2.slang.3 syn (mtl) diff --git a/tests/language-feature/generics/parameter-block-unify.slang b/tests/language-feature/generics/parameter-block-unify.slang new file mode 100644 index 000000000..b549f555b --- /dev/null +++ b/tests/language-feature/generics/parameter-block-unify.slang @@ -0,0 +1,33 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-mtl -compute -shaderobj -output-using-type -render-features argument-buffer-tier-2 + +struct TestStruct<Format:__BuiltinIntegerType, let count : int> +{ + Format f; +}; + +Format testFunction<Format : __BuiltinIntegerType, let count : int>(TestStruct<Format, count> data) +{ + return data.f + __int_cast<Format>(count); +} + +//TEST_INPUT: set testBlock = new TestStruct<int, 12>{1} +ParameterBlock<TestStruct<int, 12>> testBlock; + +//TEST_INPUT: set testBlock2 = new TestStruct<int, 12>{2} +ConstantBuffer<TestStruct<int, 2>> testBlock2; + +//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: 13 + outputBuffer[0] = testFunction(testBlock); + // CHECK: 13 + outputBuffer[1] = testFunction<int, 12>(testBlock); + // CHECK: 4 + outputBuffer[2] = testFunction(testBlock2); +}
\ No newline at end of file |
