Pointers As Function Parameters
Pointers can be passed into functions.
A few builtin functions take pointer parameters, such as arrayLength and the atomic builtins.
Pointer parameters to user-declared functions have some restrictions:
- Only pointers into
function
orprivate
address spaces are allowed. - Only pointers to whole variables can be used.
- You can’t pass the address of only part of a composite variable.
- Aliases are not allowed when there is a potential write through one of them.
We’ll explain more on the next page.
These constraints make it safe to translate WGSL pointer parameters as
inout
parameters in HLSL and GLSL.
The rules for passing pointers into builtin functions are less strict, and are not covered by this tour.