Tour of WGSL

Specifying a pointer type

A pointer refers to the memory associated with all or part of a variable.

In more detail, a pointer refers to:

  • a set of memory locations,
  • an interpretation of those memory locations as a WGSL type, consistent with the variable’s type,
  • an access mode matching the variable’s access mode, and
  • a memory model reference, matching that of the variable.

A pointer type is written as ptr<AS,T,AM> or ptr<AS,T> , where

  • AS is an address space,
  • T is a type, known as the store type, and
  • AM is an access mode. Only write this when AS is storage.

Pointers into storage address space can use read or read_write access modes, with the default being read.

Don’t write the access mode in other cases. They always use the default for the address space.