diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-05-30 13:28:40 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 13:28:40 -0700 |
| commit | 1995721c2b3ad38dd58967ad4dac4480a1086b97 (patch) | |
| tree | b1f0f14e0614b2ee49d8978ab0debbfdea06c28c /tests/spirv/pointer-from-user-guide.slang | |
| parent | 523a637a7a44858140d6b22746daf9cf5281772e (diff) | |
Update document regarding pointer (#4248)
And also add an actual test case from the User Guide example.
Diffstat (limited to 'tests/spirv/pointer-from-user-guide.slang')
| -rw-r--r-- | tests/spirv/pointer-from-user-guide.slang | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/spirv/pointer-from-user-guide.slang b/tests/spirv/pointer-from-user-guide.slang new file mode 100644 index 000000000..662579c2b --- /dev/null +++ b/tests/spirv/pointer-from-user-guide.slang @@ -0,0 +1,31 @@ +//TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly + +// This test is to verify the example on the user guide +// and prevent any regressions. + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +struct MyType +{ + float a; +}; + +float test(MyType* pObj) +{ + //SPV: OpTypePointer + MyType* pNext = pObj + 1; + MyType* pNext2 = &pNext[1]; + return pNext.a + pNext->a + (*pNext2).a + pNext2[0].a; +} + +cbuffer Constants +{ + MyType *ptr; +}; + +[numthreads(1,1,1)] +void computeMain() +{ + outputBuffer[0] = test(ptr); +} |
