Releases: gogpu/naga
Releases · gogpu/naga
v0.14.6
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 identifiererrors (e.g.,msdf_atlas,msdf_sampler) for any shader with helper functions referencing global resources (gogpu/ui#23)
v0.14.5
Fixed
MSL Backend
- Buffer parameters use references (
&) instead of pointers (*) — buffer parameters now generateconstant Uniforms& u [[buffer(0)]](reference) instead ofconstant 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
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_Inputstruct with[[attribute(N)]]members and[[stage_in]]parameter; previously gated to fragment-only metal::discard_fragment()namespace — add requiredmetal::prefix; barediscard_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 globalIdBinding → globalIDBinding 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
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
OpStoreinstructions - Deferred store for
var x = atomicOp()— Atomic operation results in variable initialization now correctly generate deferred stores (NAGA-SPV-006) OpLogicalEqualfor 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
StmtStoreat the declaration point (NAGA-SPV-007)
Full Changelog: v0.14.2...v0.14.3
v0.14.2
Fixed
- GLSL: emit
GL_ARB_separate_shader_objectsfor 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
Fixed
HLSL Backend
row_majorqualifier for matrix struct members in cbuffer/uniform blocks — DX12M[i]column access was returning rows instead of columns, causing transposed transforms and invisible geometrymul(right, left)argument reversal forrow_majormatrices — HLSLmul()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
namedExpressionsbetween function compilations — expression handle names from one WGSL function were leaking into subsequent functions, causingundeclared identifiererrors in GLES shaders
Changed
- Refactored
writeEntryPointWithIOto reduce cognitive complexity (gocognit clean)
v0.14.0 — Essential 15 Reference Shaders
Major WGSL language coverage expansion: 15/15 Essential reference shaders from Rust naga test suite now compile to valid SPIR-V.
Highlights
- Abstract type constructors —
vec3(1,2,3),mat2x2(...),array(...)without template params - 48 short type aliases —
vec3f,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
SPIR-V OpArrayLength fix, comprehensive benchmarks, and compiler allocation optimization (−32%).
Fixed
- SPIR-V
OpArrayLength— Runtime-sized array length queries (arrayLength()) now emit correctOpArrayLengthinstruction. 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()andb.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()), sharedInstructionBuilderwithReset(), package-level lookup tables in lowerer (eliminates 6 map allocations per compile including 66-entrygetMathFunction), 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
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/outdeclarations 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 offloat[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/@locationmember bindings now correctly generate HLSL input structs with proper semantics
SPIR-V Backend
OpVectorTimesScalar— Vector-scalar multiplication now emits the dedicatedOpVectorTimesScalarinstruction instead of component-wise multiply- Opcode number corrections — Fixed incorrect opcode values for vector/scalar operations
- Bool-to-float conversion —
f32(bool_expr)now generates correctOpSelectinstead 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
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:
varinitialization from expressions, hex literal suffixes (0xFFu) - Linter: resolved all issues, removed unused nolint directives