Skip to content

Releases: gogpu/naga

v0.14.6

06 Mar 00:39
f4f2f36

Choose a tag to compare

Fixed

MSL Backend

  • Pass-through globals for helper functions — textures, samplers, uniforms, and storage buffers used by non-entry-point functions are now passed as extra parameters and arguments at call sites; previously MSL helper functions could not access entry point resource bindings, causing undeclared identifier errors (e.g., msdf_atlas, msdf_sampler) for any shader with helper functions referencing global resources (gogpu/ui#23)

v0.14.5

04 Mar 18:12
de99217

Choose a tag to compare

Fixed

MSL Backend

  • Buffer parameters use references (&) instead of pointers (*) — buffer parameters now generate constant Uniforms& u [[buffer(0)]] (reference) instead of constant Uniforms* u [[buffer(0)]] (pointer); pointer syntax required -> for member access while the expression writer generates . access, causing Metal compilation errors on Apple Silicon (gogpu/ui#23)

v0.14.4 — MSL Backend Fixes

01 Mar 20:19
bb5e4a5

Choose a tag to compare

v0.14.4 — MSL Backend Fixes

Fix two MSL backend bugs that caused Metal shader compilation failures on Apple Silicon (reported in gogpu/ui#23):

Bug Fixes

  • Vertex [[stage_in]] for struct-typed arguments — vertex shaders with struct inputs (e.g., fn vs_main(in: VertexInput)) now correctly generate a synthesized _Input struct with [[attribute(N)]] members and [[stage_in]] parameter; previously gated to fragment-only
  • metal::discard_fragment() namespace — add required metal:: prefix; bare discard_fragment() was rejected by Metal compiler

Files Changed

File Change
msl/functions.go Remove fragment-only gate, use binding-based attribute generation
msl/statements.go Add metal:: prefix to discard_fragment()
msl/statements_test.go Update TestMSL_Kill expected output
glsl/expressions_test.go Fix globalIdBindingglobalIDBinding lint (pre-existing)
snapshot/testdata/golden/msl/vertex_colors.msl Update golden with vs_main_Input struct
CHANGELOG.md Add v0.14.4 entry

Full Changelog: v0.14.3...v0.14.4

v0.14.3

25 Feb 12:50
2a8e5cf

Choose a tag to compare

SPIR-V Compute Shader Bug Fixes

5 SPIR-V backend fixes for compute shader correctness, discovered during Vello compute pipeline development:

Fixed

  • Deferred store for multiple call results — Variables initialized from expressions containing multiple function call results now correctly emit deferred OpStore instructions
  • Deferred store for var x = atomicOp() — Atomic operation results in variable initialization now correctly generate deferred stores (NAGA-SPV-006)
  • OpLogicalEqual for bool comparisons — Boolean equality expressions now emit correct opcode; transitive deferred stores propagate through boolean comparison chains
  • Atomic result type for atomic<i32> struct fields — Atomic operations on signed integer struct members now use correct result type
  • Prologue var init splitting — Variable initializations referencing local variables are now split from the function prologue into StmtStore at the declaration point (NAGA-SPV-007)

Full Changelog: v0.14.2...v0.14.3

v0.14.2

22 Feb 17:02
7d94d37

Choose a tag to compare

Fixed

  • GLSL: emit GL_ARB_separate_shader_objects for desktop GLSL < 4.10 — layout(location) on inter-stage varyings requires this extension; NVIDIA drivers reject generated code without it (#31)
  • SPIR-V: deterministic output — replaced map with slices for entry point interface variables

Added

  • Golden snapshot test system (~118 files across 4 backends)
  • 20 new reference shaders (collatz, atomics, workgroup_memory, uniforms_mvp, math_builtins, etc.)
  • 76 WGSL error case tests (39 parse + 37 lowering errors)
  • 47 IR validator semantic tests
  • 13 SPIR-V capability tracking tests

v0.14.1

21 Feb 10:54
ab82318

Choose a tag to compare

Fixed

HLSL Backend

  • row_major qualifier for matrix struct members in cbuffer/uniform blocks — DX12 M[i] column access was returning rows instead of columns, causing transposed transforms and invisible geometry
  • mul(right, left) argument reversal for row_major matrices — HLSL mul() semantics differ from WGSL * operator when layout changes
  • Unique entry point names — prevent HLSL duplicate function errors when multiple entry points reference the same function
  • Typed call results — function calls now use correct return type instead of void

GLSL Backend

  • Clear namedExpressions between function compilations — expression handle names from one WGSL function were leaking into subsequent functions, causing undeclared identifier errors in GLES shaders

Changed

  • Refactored writeEntryPointWithIO to reduce cognitive complexity (gocognit clean)

v0.14.0 — Essential 15 Reference Shaders

20 Feb 23:27
97fe275

Choose a tag to compare

Major WGSL language coverage expansion: 15/15 Essential reference shaders from Rust naga test suite now compile to valid SPIR-V.

Highlights

  • Abstract type constructorsvec3(1,2,3), mat2x2(...), array(...) without template params
  • 48 short type aliasesvec3f, mat4x4f, vec2i, etc.
  • 25 new SPIR-V math functions — bit manipulation, pack/unpack, quantize
  • 17 reference shader regression tests — 15 Essential + 2 bonus (skybox, water)
  • 20+ SPIR-V codegen fixes — vector/scalar promotion, matrix multiply, let semantics, loop continuing, storage textures, atomics

Full Changelog

See CHANGELOG.md for complete details.

v0.13.1

17 Feb 21:14
8ed2b77

Choose a tag to compare

SPIR-V OpArrayLength fix, comprehensive benchmarks, and compiler allocation optimization (−32%).

Fixed

  • SPIR-V OpArrayLength — Runtime-sized array length queries (arrayLength()) now emit correct OpArrayLength instruction. Handles both bare storage arrays (wrapped in synthetic struct) and struct member arrays. Fixes "unsupported expression kind: ExprArrayLength" crash in compute shaders with dynamic buffer sizes.

Added

  • Comprehensive compiler benchmarks — 68 benchmarks across all 7 packages (root, wgsl, spirv, glsl, hlsl, msl, ir) with ReportAllocs() and b.SetBytes() throughput metrics. Covers full pipeline (lex→parse→lower→validate→generate), cross-backend comparison, and per-stage isolation. Table-driven by shader complexity (small/medium/large).

Changed

  • Compiler allocation reduction (−32.3%) — Large PBR shader: 1384→937 allocs, 203KB→134KB. Word arena for SPIR-V instructions (eliminates per-instruction make()), shared InstructionBuilder with Reset(), package-level lookup tables in lowerer (eliminates 6 map allocations per compile including 66-entry getMathFunction), capacity hints in parser/lexer/backend. SPIR-V generate stage: −58.4% allocs. Lowerer bytes: −68.6%.
  • golangci-lint v2.10 compatibility — updated config exclusions, fixed staticcheck QF1012, cleaned up stale nolint directives.

See CHANGELOG.md for full details.

v0.13.0

15 Feb 11:00
01978e0

Choose a tag to compare

GLSL backend improvements, HLSL struct entry point fix, and SPIR-V vector/scalar multiply and bool conversion fixes.

Added

GLSL Backend

  • UBO blocks for struct uniforms — Struct uniform variables now emit layout(std140) uniform BlockName { ... } blocks instead of bare uniform declarations
  • Entry point struct I/O — Vertex/fragment entry points with struct parameters and return types now correctly emit in/out declarations for each struct member

Testing

  • SPIR-V loop iteration regression tests — Tests verifying correct loop codegen
  • SPIR-V conditional call result regression tests — Tests for function calls inside if/return blocks

Fixed

GLSL Backend

  • Array syntax — Array declarations now use correct GLSL syntax (float name[3] instead of float[3] name)
  • Built-in mappings — WGSL builtins correctly mapped to GLSL equivalents (gl_Position, gl_VertexID, etc.)
  • Entry point generation — Correct void main() generation with proper layout qualifiers
  • Local variable initializers — Variables with initializers now emit correct GLSL initialization

HLSL Backend

  • Struct entry point arguments with member bindings — Entry points accepting struct parameters with @builtin/@location member bindings now correctly generate HLSL input structs with proper semantics

SPIR-V Backend

  • OpVectorTimesScalar — Vector-scalar multiplication now emits the dedicated OpVectorTimesScalar instruction instead of component-wise multiply
  • Opcode number corrections — Fixed incorrect opcode values for vector/scalar operations
  • Bool-to-float conversionf32(bool_expr) now generates correct OpSelect instead of failing with "unsupported conversion"
  • Variable initialization from expressions — Additional fixes for var x = expr; patterns
  • Math function argument handling — Improved argument ordering for smoothstep, clamp, select, abs, min, max

Changed

  • Removed unused test helper validateSPIRVBinaryBasic

Full Changelog: v0.12.0...v0.13.0

v0.12.0

09 Feb 22:43
219a20b

Choose a tag to compare

Added

  • OpFunctionCall — SPIR-V function call support for non-entry-point functions
  • SPIR-V codegen analysis tests for SDF compute shaders (~2000 LOC)

Fixed

  • Compute shader codegen: var initialization from expressions, hex literal suffixes (0xFFu)
  • Linter: resolved all issues, removed unused nolint directives