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 /docs/user-guide | |
| parent | 523a637a7a44858140d6b22746daf9cf5281772e (diff) | |
Update document regarding pointer (#4248)
And also add an actual test case from the User Guide example.
Diffstat (limited to 'docs/user-guide')
| -rw-r--r-- | docs/user-guide/03-convenience-features.md | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index 420db18c1..a145c407c 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -422,6 +422,23 @@ int test(MyType* pObj) MyType* pNext2 = &pNext[1]; return pNext.a + pNext->a + (*pNext2).a + pNext2[0].a; } + +cbuffer Constants +{ + MyType *ptr; +}; + +int validTest() +{ + return test(ptr); +} + +int invalidTest() +{ + // cannot produce a pointer from a local variable + MyType obj; + return test(&obj); // !! ERROR !! +} ``` Pointer types can also be specified using the generic syntax: `Ptr<MyType>` is equivalent to `MyType*`. @@ -430,9 +447,13 @@ Pointer types can also be specified using the generic syntax: `Ptr<MyType>` is e - Slang supports pointers to global memory, but not shared or local memory. For example, it is invalid to define a pointer to a local variable. -- Coherent load/stores are unsupported +- Slang supports pointers that are defined as shader parameters (e.g. as a constant buffer field). + +- Slang can produce pointers using the & operator from data in global memory. + +- Slang doesn't support coherent load/stores. -- Custom alignment specification is unsupported. +- Slang doesn't support custom alignment specification. - Slang currently does not support pointers to immutable values, i.e. `const T*`. |
