Skip to content

SYSTEM Cited by 1 source

WGSL

WGSL (WebGPU Shading Language) is the shading language defined by the WebGPU specification. All WebGPU shader code must be WGSL — it's the only shader language WebGPU APIs accept.

WGSL is a new language, not a dialect of GLSL or HLSL. It borrows syntactic ideas from Rust (explicit type annotations, attributes, pipelined semantics), but is its own spec maintained at W3C.

Differences from WebGL 1 GLSL (relevant to migration)

  • Uniform blocks required. Individual uniform declarations from WebGL 1 GLSL don't translate; uniforms must be grouped into explicit blocks. See concepts/uniform-buffer.
  • Explicit binding / group decorators. Each resource in a shader must declare its @binding(n) @group(n) slot.
  • Type-first syntaxvar<uniform> x: vec3f rather than GLSL's uniform vec3 x.
  • Enforced struct layouts for buffer-backed data.

These differences are why a migrating codebase with WebGL 1 GLSL shaders can't just do naïve text translation — the source language often needs to be upgraded to a newer GLSL version first, then handed to a translator like naga.

Seen in

Last updated · 200 distilled / 1,178 read