diff options
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; +} |
