Types Overview

WGSL supports a wide range of types to enable efficient GPU programming:

  • Basic Scalars: Standard concrete scalar types including bool, i32, u32, and f32.
  • Abstract Numerics: Compile-time high-precision abstract-int and abstract-float types.
  • Vectors: Multi-component vector types (vec2, vec3, vec4), aliases, constructors, and swizzling.
  • Matrices: Column-major matrix types (dimensions \(2 \times 2\) through \(4 \times 4\)) and matrix-vector operations.
  • Arrays: Statically-sized and runtime-sized collections of uniform elements.
  • Structures: Custom user-defined types, alignment properties, and member layout configurations.
  • Pointers: Pointer syntax, address spaces, access modes, and strict pointer aliasing rules.
  • Atomics: Safe lock-free concurrent memory operations and thread coordination.