From 6b3095758679a7699dc26d1af5521b65ace2cc83 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Thu, 2 May 2024 19:01:43 -0400 Subject: Slang: update pointer related documentation (#4088) Slang does have some support for pointers. Remove an outdated comment stating the contratry, and update the section that describes pointer support to also list some relevant limitations. Fixes #3970 Co-authored-by: Yong He --- docs/user-guide/02-conventional-features.md | 3 +-- docs/user-guide/03-convenience-features.md | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/user-guide/02-conventional-features.md b/docs/user-guide/02-conventional-features.md index e50debd10..b748a72c0 100644 --- a/docs/user-guide/02-conventional-features.md +++ b/docs/user-guide/02-conventional-features.md @@ -18,8 +18,7 @@ Types Slang supports conventional shading language types including scalars, vectors, matrices, arrays, structures, enumerations, and resources. > #### Note #### -> Slang does not currently support pointer types as in C/C++. -> Pointers cannot be implemented robustly and completely on many of the target platforms Slang currently supports. +> Slang has limited support for pointers when targeting platforms with native pointer support, including SPIRV, C++, and CUDA. ### Scalar Types diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index e4732436e..ef43341f1 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -361,7 +361,7 @@ float4 myPackedVector = reinterpret(myVal); `reinterpret` can pack any type into any other type as long as the target type is no smaller than the source type. -## Pointers +## Pointers (limited) Slang supports pointers when generating code for SPIRV, C++ and CUDA targets. The syntax for pointers is similar to C, with the exception that operator `.` can also be used to dereference a member from a pointer. For example: ```csharp @@ -375,8 +375,15 @@ int test(MyType* pObj) Pointer types can also be specified using the generic syntax: `Ptr` is equivalent to `MyType*`. -> #### Note -> Slang currently does not support pointers to immutable values, i.e. `const T*`. +### Limitations + +- 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 + +- Custom alignment specification is unsupported. + +- Slang currently does not support pointers to immutable values, i.e. `const T*`. ## `struct` inheritance (limited) -- cgit v1.2.3