DEV Community

Cover image for naga v0.8.0: Pure Go Shader Compiler Reaches Stability Milestone
Andrey Kolkov
Andrey Kolkov

Posted on • Edited on

naga v0.8.0: Pure Go Shader Compiler Reaches Stability Milestone

Last updated: December 28, 2025

Announcing naga v0.8.0 — Stability Release

After eight releases and 32,000 lines of code, naga — the Pure Go shader compiler — has completed its rapid development phase. With v0.8.0, all four major GPU backends are production-ready, and the project transitions to long-term support and API stabilization.

naga compiles WGSL (WebGPU Shading Language) to:

  • SPIR-V — Vulkan
  • MSL — Metal (macOS/iOS)
  • GLSL — OpenGL 3.3+, ES 3.0+
  • HLSL — DirectX 11/12

Zero CGO. Zero external dependencies. Just go build.

Project Maturity

Backend Status Target Platform
SPIR-V Stable Vulkan
MSL Stable Metal (macOS/iOS)
GLSL Stable OpenGL 3.3+, ES 3.0+
HLSL Stable DirectX 11/12

The compiler now supports all major graphics APIs on all major platforms. This completes the initial vision for naga as a universal shader compilation solution for Go.

Development Timeline

Phase 1: Foundation (v0.1.0 - v0.2.0)

v0.1.0 established the core compiler infrastructure:

  • WGSL lexer (120 token types)
  • Recursive descent parser
  • Intermediate representation (25 expression types, 16 statement types)
  • SPIR-V binary writer (111 opcodes)
  • Public API: naga.Compile()

v0.2.0 added the type system:

  • Complete type inference engine
  • Type deduplication for SPIR-V compliance
  • Correct opcode selection for int/float/uint operations

Phase 2: Language Completeness (v0.3.0 - v0.4.0)

v0.3.0 implemented texture operations:

  • textureSample, textureLoad, textureStore
  • textureDimensions, textureNumLevels
  • SPIR-V image instructions

v0.4.0 added compute shader support:

  • Storage buffers with access modes (read, read_write)
  • Workgroup shared memory
  • Nine atomic operations (including atomicCompareExchangeWeak)
  • Four barrier types
  • Unused variable warnings

Phase 3: Backend Expansion (v0.5.0 - v0.7.0)

v0.5.0 — MSL backend (~3.3K LOC)

  • Metal Shading Language output
  • Stage attributes ([[vertex]], [[fragment]], [[kernel]])
  • Buffer bindings and argument tables

v0.6.0 — GLSL backend (~2.6K LOC)

  • OpenGL 3.3+ and ES 3.0+ support
  • Layout qualifiers and precision specifiers
  • Version directive handling

v0.7.0 — HLSL backend (~5.7K LOC)

  • DirectX 11 (Shader Model 5.1) and DirectX 12 (SM 6.0+)
  • HLSL semantics (SV_Position, TEXCOORD, SV_Target)
  • Buffer types (ByteAddressBuffer, StructuredBuffer, cbuffer)
  • 70+ intrinsic functions
  • Atomic operations (InterlockedAdd, etc.)

Phase 4: Stabilization (v0.8.0)

v0.8.0 focuses on correctness and code quality:

  • Fixed sign() opcode selection (SSign vs FSign)
  • Fixed atomicMin/Max signed vs unsigned handling
  • Added forward function reference resolution
  • Improved return type attribute parsing
  • Refactored SPIR-V atomic emission

Architecture

                         WGSL Source
                              │
                              ▼
                   ┌──────────────────────┐
                   │   Lexer (120 tokens) │
                   └──────────────────────┘
                              │
                              ▼
                   ┌──────────────────────┐
                   │  Parser (~1.4K LOC)  │
                   └──────────────────────┘
                              │
                              ▼
                   ┌──────────────────────┐
                   │  IR Lowering + Types │
                   │     (~2.6K LOC)      │
                   └──────────────────────┘
                              │
        ┌─────────────┬───────┴───────┬─────────────┐
        │             │               │             │
        ▼             ▼               ▼             ▼
  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐
  │  SPIR-V  │  │   MSL    │  │   GLSL   │  │   HLSL   │
  │  ~3.6K   │  │  ~3.3K   │  │  ~2.6K   │  │  ~5.7K   │
  └──────────┘  └──────────┘  └──────────┘  └──────────┘
        │             │               │             │
        ▼             ▼               ▼             ▼
     Vulkan        Metal          OpenGL       DirectX
Enter fullscreen mode Exit fullscreen mode

Usage

Library Integration

import (
    "github.com/gogpu/naga"
    "github.com/gogpu/naga/msl"
    "github.com/gogpu/naga/glsl"
    "github.com/gogpu/naga/hlsl"
)

func CompileShader(source string) error {
    // Parse once, compile to multiple targets
    ast, err := naga.Parse(source)
    if err != nil {
        return err
    }

    module, err := naga.Lower(ast)
    if err != nil {
        return err
    }

    // SPIR-V for Vulkan
    spirvBytes, _ := naga.GenerateSPIRV(module, spirv.Options{})

    // MSL for Metal
    mslCode, _, _ := msl.Compile(module, msl.DefaultOptions())

    // GLSL for OpenGL
    glslCode, _, _ := glsl.Compile(module, glsl.DefaultOptions())

    // HLSL for DirectX
    hlslCode, _, _ := hlsl.Compile(module, hlsl.DefaultOptions())

    return nil
}
Enter fullscreen mode Exit fullscreen mode

Command-Line Tool

go install github.com/gogpu/naga/cmd/nagac@latest

nagac shader.wgsl -o shader.spv              # SPIR-V (default)
nagac shader.wgsl -o shader.metal -f msl     # Metal
nagac shader.wgsl -o shader.glsl -f glsl     # GLSL
nagac shader.wgsl -o shader.hlsl -f hlsl     # HLSL
nagac shader.wgsl -debug -o shader.spv       # with debug symbols
Enter fullscreen mode Exit fullscreen mode

Supported Language Features

Category Features
Scalar Types f32, f64, i32, u32, bool
Vector Types vec2, vec3, vec4 (all scalar variants)
Matrix Types mat2x2 through mat4x4
Composite arrays, structs, atomics
Textures texture_2d, texture_3d, texture_cube, sampler
Shader Stages @vertex, @fragment, @compute
Bindings @location, @group/@binding, @builtin
Address Spaces uniform, storage (read/read_write), workgroup
Built-in Functions 35 (math, geometric, texture, atomic, barrier)
Control Flow if/else, for, while, loop, switch, break, continue

GoGPU Ecosystem

naga is part of a larger Pure Go GPU computing ecosystem:

Project Description Status
gogpu/wgpu Pure Go WebGPU implementation 86,638 LOC
gogpu/gg 2D graphics library 104,472 LOC
gogpu/naga Shader compiler 31,950 LOC
gogpu/gogpu Graphics framework 25,712 LOC
gogpu/ui GUI toolkit Planning
Total (released) 248,772 LOC

A quarter million lines of Pure Go for GPU computing — no CGO required.

gogpu/ui is the upcoming GUI toolkit for the ecosystem, currently in the planning stage. Join the discussion to share your ideas and requirements.

Transition to Long-Term Support

With v0.8.0, naga enters a new phase:

Completed Goals:

  • All four major backends implemented and tested
  • Complete type inference system
  • Compute shader support with atomics and barriers
  • 200+ tests across all components

Maintenance Phase Priorities:

  1. API Stability — No breaking changes without major version bump
  2. Bug Fixes — Correctness issues addressed promptly
  3. Specification Compliance — Gradual alignment with WGSL spec updates
  4. Performance — Optimization passes as needed

Future Extensions:
The following features are not currently on the roadmap, but may be considered based on community interest:

  • Ray tracing extensions
  • Mesh shaders
  • WebGPU-specific experimental features

If you need any of these capabilities, please open a GitHub issue to discuss.

The rapid development phase is complete. naga now provides a stable foundation for Go applications requiring shader compilation.

Installation

go get github.com/gogpu/naga@v0.8.0
Enter fullscreen mode Exit fullscreen mode

Contributing

The project welcomes contributions in these areas:

  • Test Cases — Real-world shaders from production applications
  • Bug Reports — Edge cases and specification compliance issues
  • Documentation — Usage examples and integration guides

Repository: github.com/gogpu/naga


Links

Top comments (0)