diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-03 12:56:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-03 12:56:31 -0700 |
| commit | 1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb (patch) | |
| tree | 6196d519190720fd2968ac7d4b373e3c967d5fe6 /tests/language-feature | |
| parent | 355bb4287861f96082751042f4e58ff3598b4e5e (diff) | |
Proper lowering of functiosn that returns NonCopyable values. (#3179)
* Proper lowering of functiosn that returns NonCopyable values.
* Fix tests.
* Fix clang errors.
* Fix.
* Fix clang error.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/non-copyable-return.slang | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/language-feature/non-copyable-return.slang b/tests/language-feature/non-copyable-return.slang new file mode 100644 index 000000000..20330c5f9 --- /dev/null +++ b/tests/language-feature/non-copyable-return.slang @@ -0,0 +1,37 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type +//TEST(compute):SIMPLE(filecheck=GLSL): -stage compute -entry computeMain -target glsl + +// Note: spirv_by_reference is only supported for passing opaque types, so this test won't produce +// expected result on vulkan. +//DISABLED_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type + +[__NonCopyableType] +struct MyType +{ + float x; + __init() { x = 1.0; } +} + +MyType myFunc1(float y) +{ + __return_val = MyType(); + __return_val.x += y; +} + +MyType myFunc0(float x) +{ + return myFunc1(x + 1.0); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) +{ + let f = myFunc0(2.0); + // CHECK: 4.0 + // GLSL: void myFunc1_0(float y{{.*}}, spirv_by_reference MyType_0 {{.*}}) + // GLSL: void myFunc0_0(float x{{.*}}, spirv_by_reference MyType_0 {{.*}}) + outputBuffer[0] = f.x; +} |
