var<function>
var<function> declares a mutable variable in the function address-space.
A var<function> can only be declared within a function.
A var<function> declaration must have an explicit type, an initializer,
or both type and initializer:
| |
A var<function> with no initializer will be automatically initialized with
the zero value for the variable’s type.
There are no restrictions for the
evaluation stage
of the initializer of a var<function>.
A var declared within a function has the default address-space of function,
and so most developers will simply omit the <function> and just type var:
| |
Each shader invocation will have a unique instance of a var in function address-space.
Uses of a var<function> will always result in a
runtime expression.