WGSL

WGSL as a Companion Specification

WebGPU shaders are written in WGSL, the WebGPU Shading Language, which the working group publishes as a separate specification on the same track: First Public Working Draft on 18 May 2021, Candidate Recommendation Snapshot on 19 December 2024, and a Candidate Recommendation Draft since, the latest dated 21 September 2026.

The group could have accepted SPIR-V, Vulkan's binary shader format, or WHLSL, Apple's HLSL-based proposal. It chose a new text language whose every rule the browser can validate before a driver sees it, which matters for security (GPU Sandbox). Chrome 1 enforces the choice: its chrome://gpu page lists the Dawn 1,149 toggle disallow_spirv, "so that only WGSL is used for shader modules". The syntax borrows from Rust, and new capabilities arrive as language extensions you can test for, much as WebGL pages test for extensions (Checking Extensions). The set Chrome 154 reports on this book's machine:

Listing the WGSL language extensions the browser supportsHTMLLive
<script>
  const names = [...navigator.gpu.wgslLanguageFeatures].sort();
  console.log(`${names.length} WGSL language extensions:`);
  for (let i = 0; i < names.length; i += 2) {
    console.log('  ' + names.slice(i, i + 2).join(', '));
  }
</script>

WGSL Types to Bindings and Diagnostics teach the language, and Migrating GLSL Shaders to WGSL maps GLSL constructs onto it.