Skip to content

Tags

Tags

v0.19.0

Toggle v0.19.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
release: v0.19.0 — enable swizzle_assignment (gogpu#90)

* docs: add star history chart (starhistory.io)

* fix(lint): remove dead nil checks on zeroLiteralForScalar (SA4023)

zeroLiteralForScalar always returns a non-nil LiteralValue (all scalar
kinds covered + default case). The nil checks were unreachable.

* fix(lint): remove remaining dead nil check in MatrixType path (SA4023)

* feat(wgsl): implement swizzle_assignment extension (gogpu#89, ADR-003)

enable swizzle_assignment; allows multi-component swizzle on assignment LHS:
  result.rgb = c.rgb;
  result.rgb += c.rgb * c.a;

Lowerer decomposes to load → per-component extract → construct → store
(Dawn pattern). All 5 backends work without changes. Spec-compliant
per W3C gpuweb/gpuweb#5268 (merged 2026-08-25). Ahead of Rust naga.

22 test cases + 2 integration tests. Without extension: clear error.

* test(wgsl): all 11 Dawn swizzle assignment patterns + false positive fix

Fix parseSwizzleMap treating struct member names (e.g. 'arr') as RGBA
swizzle patterns by rejecting duplicate indices. Restores pointers.wgsl
SPIR-V validation (172/172).

48 swizzle tests covering all Dawn patterns: single/multi/chained/indexed
(constant + dynamic), compound assignment, vec2/vec3/vec4, i32/u32/f32.

* docs: prepare release v0.19.0

* fix(lint): remove unused nolint directive in darwin test

v0.18.0

Toggle v0.18.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
release: v0.18.0 (gogpu#86)

* feat(wgsl): capability-based scalar width validation (gogpu#85)

Add Capabilities type (ir.CapFloat64, ir.CapShaderInt64, ir.CapShaderFloat16)
matching Rust naga valid::Capabilities bitflags. WGSL lowerer now rejects
f64/i64/u64/f16 unless the caller enables the corresponding capability.

LowerWithSource remains permissive (CapAll) for backward compatibility.
LowerWithCapabilities provides strict mode for runtime use.
CompileOptions.Capabilities defaults to 0 (strict).

32 test cases covering reject/accept per type, struct fields, function
params, constructors, vec/mat aliases, atomics, CapAll, combined caps.

* refactor: move capability validation to unified ir.Validator (ADR-002)

Capability checks now live in ir.ValidateWithCapabilities — the single
gate between lowerer and backends. Matches Rust naga architecture:
lowerer is permissive, validator enforces capabilities, backends trust
validated IR.

Removed checkScalarWidth from WGSL lowerer, removed LowerWithCapabilities
and LowerWithWarningsAndCapabilities. Validator checks Scalar, Vector,
Matrix, and Atomic types for width-capability compliance.

+84/-450 lines — less code, better architecture, zero duplication.

* docs: prepare release v0.18.0

v0.17.16

Toggle v0.17.16's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
release: v0.17.16 (gogpu#84)

* fix(msl): parenthesize binary expressions inside swizzle (gogpu#83)

writeSwizzle now wraps binary/select sub-expressions in parentheses,
matching Rust naga is_scoped=false semantics. Without this, C++ member
access (.) bound tighter than arithmetic operators, emitting
mat * vec.xyz instead of (mat * vec).xyz — a type error rejected by
Metal compiler. Discovered via g3d standard.wgsl on Apple M5.

* test(msl): add i64 rejection case for 64-bit atomic policy

Covers signed branch explicitly — atomicAdd on atomic<i64> must be
rejected the same as u64. Width == 8 handles both uniformly, but the
test makes the contract visible for future readers.

* docs: prepare release v0.17.16

v0.17.15

Toggle v0.17.15's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request gogpu#78 from gogpu/release/v0.17.15

docs: v0.17.15 patch release

v0.17.14

Toggle v0.17.14's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Merge pull request gogpu#76 from gogpu/feat/glsl-version-aware-binding

feat(glsl): version-aware binding + UniformInfo reflection (BUG-GLES-005)

v0.17.13

Toggle v0.17.13's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(dxil): PHI node ordering + coverage waves 3-4 (gogpu#75)

* fix(dxil): PHI nodes grouped at top of basic block — path_count.wgsl now VALID

mem2reg Phase B phi expressions had high handles, emitted after low-handle
regular expressions in merged StmtEmit runs. splitPhiRanges separates phi
ranges and emits them first. Fixes 'PHI nodes not grouped at top of basic
block' IDxcValidator error for Vello path_count.wgsl compute shader.

* docs: update for v0.17.13 — PHI ordering fix, coverage waves 3-4

v0.17.12

Toggle v0.17.12's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
refactor: ARCH-001 internal packages + 12/18 coverage ≥80% + 13 panic…

…s→errors (gogpu#72)

* refactor(glsl): move implementation to internal/codegen — DXIL pattern (ARCH-001)

All codegen moved to glsl/internal/codegen/ via git mv. Thin public
wrapper at glsl/glsl.go with type aliases (zero overhead). Public API
unchanged: Compile, Options, DefaultOptions, TranslationInfo, BindingMapKey.
Writer and Features types now internal. 0 lint issues, all tests pass.

* refactor(msl): move implementation to internal/codegen — DXIL pattern (ARCH-001)

All codegen moved to msl/internal/codegen/ via git mv. Thin public
wrapper at msl/msl.go with type aliases (zero overhead). Public API
unchanged: Compile, CompileWithPipeline, Options, DefaultOptions,
BoundsCheckPolicies, VertexFormat constants. 0 lint issues, all tests pass.

* refactor(hlsl): move implementation to internal/codegen — DXIL pattern (ARCH-001)

All codegen moved to hlsl/internal/codegen/ via git mv. Shared namer
logic (NeedsTrailingUnderscore, keyword maps) moved to internal/backend/
to avoid circular imports — both hlsl/internal/codegen and dxil/internal/emit
import from shared location. Public API unchanged via type aliases.
0 lint issues, all tests pass including DXIL.

* refactor(spirv): move implementation to internal/codegen — DXIL pattern (ARCH-001)

All codegen moved to spirv/internal/codegen/ via git mv. Thin public
wrapper at spirv/spirv.go with type aliases. Public API unchanged:
Backend, Options, DefaultOptions, ModuleBuilder, capabilities, opcodes.
SPIR-V val 172/172 (100%). 0 lint issues, all tests pass.

* refactor: extract shared textutil.IndentWriter — DRY across glsl/hlsl/msl (ARCH-001 Phase 0)

internal/textutil/textutil.go with IndentWriter (WriteLine, WriteIndent,
PushIndent, PopIndent). Embedded in all 3 text backend Writers. Eliminates
3× duplication of indent/output methods. 5 unit tests. 0 lint issues.

* refactor: replace type aliases with real types in public API — DXIL pattern (ARCH-001)

glsl: 8/8 aliases → real types + toCodegenOptions/fromCodegenTranslationInfo
msl: 22/22 aliases → real types + conversion functions
hlsl: 15/16 aliases → real types (Writer stays alias — implementation type)
spirv: 4/30 aliases → real types (implementation types stay — tightly coupled)
go doc now shows full struct definitions. 0 lint issues, all tests pass.

* refactor(wgsl): move to internal/parser + internal/lower — DXIL pattern (ARCH-001 Phase 2a)

parser/ contains lexer, token, parser, ast, deporder, errors.
lower/ contains the 16K LOC lowerer (imports parser for AST types).
Public API: REAL types (Module, Lexer, Tokens, Parser, ParseError, Span).
No type aliases. go doc shows full struct definitions.
0 lint issues, all tests pass.

* refactor(ir): move TypeRegistry to internal/registry — ARCH-001 Phase 2b

Registry moved to module-level internal/registry/ (not ir/internal/)
because wgsl/internal/lower/ needs access and Go internal visibility
restricts ir/internal/ to ir/ subtree only. compact.go and validate.go
stay in ir/ — circular import prevents moving. 0 lint issues.

* test(glsl): add 207 tests — coverage 57%→74.3% (COV-002)

5 test files, 5139 LOC. Covers: compile integration (100 tests),
statements (22), writer utils (24), features (33), types (28).
Table-driven, named subtests, real WGSL→GLSL output verification.

* test(msl): add 34 tests — coverage 38%→41.8% (COV-001 wave 1)

1341 LOC. Covers: Version.Less, BoundsCheckPolicies, blockEndsWithReturn,
builtinInputAttribute (19 builtins), resolveInterpolation, compile
integration (workgroup init, dual-source blend, storage buffers, etc.).

* test(glsl): wave 2 — coverage 74.3%→80.4%, 67 targeted tests (COV-002)

writeHelperFunctions 12%→100%, resolveTypeInner 18%→tested,
scanBlockForStages 16%→91%, tryConstEvalUnary 23%→100%,
writeUniformBlock 28%→improved, plus writeCallResult, writeAtomicResult,
formatConstResult, computeBlockNames, expandBoolVectorOp all from 0%.

* test(msl): wave 2 — coverage 41.8%→56.6%, 748 tests across 4 files (COV-001)

Integration tests via compileWGSL: math functions, expressions, control
flow, textures, atomics, pipeline constants, vertex pulling, bounds
checking. 3919 LOC new tests. Remaining gap: ray queries, subgroups,
external textures — specialized WGSL extensions.

* test(backend): coverage 35.1%→97.1% — namer, interface ordering, sig packing

hlsl_namer_test: EndsWithDigit, IsASCIIAlphanumeric, NeedsTrailingUnderscore (44 cases).
interface_order_test: MemberInterfaceLess, SortedArgIndices, SortFlatBindings.
sig_pack_binding_test: componentDimensions, SigElementInfoForBinding (13 cases),
PackStructMembers, PackSignatureElements edge cases.

* test(dxil/module): coverage 52%→100% — types, constants, serialization, float16

60+ tests: type system dedup, instruction constructors, aggregate/undef
constants, global variables, float32ToF16Bits (12 cases), full
serialization coverage (all instruction kinds, branches, phi, atomics,
GEP, value symtab, function decls). Enterprise quality.

* test(dxil/viewid): coverage 49.9%→83.0% — dataflow, taint, walker

analysis_test: scalarSet, componentTaint, giveUp fallback, expandTaint.
expressions_test: computeTaint for 15+ expression kinds, merge ops.
walker_test: walkStatement (if/switch/loop/block), handleStore,
rootLocalVar, resolveFlatRange. All tests verify actual scalar dataflow.

* test(ir): coverage 70.1%→81.1% — overrides, resolve, inline, validation

process_overrides: literalToFloat, evalBinary/Unary, cloneModule,
filterEmitsInBlock, overrideRemapExprHandles (18 kinds). resolve:
Load/Access/Splay/Swizzle type resolution, modf/frexp struct finding,
atomicResult, workGroupUniformLoad. inline: blockContainsReturn,
shouldAliasArgType. Core: StorageFormat, TypeSize, Validate errors.

* test(dxil/passes): DCE 88.6%, mem2reg 92.9%, SROA 83.0% — all above 80%

DCE: 27 tests — dead loop, side-effect roots, visitExprHandles (14 kinds),
stmtHasSideEffects (22 types), shared consumer tracking.
mem2reg: 17 tests — Phase B phi, loop disqualification, collectStores,
classifyStatements, promoteBlocks recursion, isBoolLocal.
SROA: 19 tests — nested stores, resolveStructLocal, allMembersDecomposable,
classify with control flow recursion, Compose-store.

* test(hlsl): coverage 32.1%→62.3%, 1308 tests across 5 files

Integration: entry points, math, textures, storage buffers, derivatives.
Unit: binaryOpStr, scalarKindToHLSL, continueCtx, mathFunction dispatch.
Types: hlslTypeSize, isDynamicallySized, struct padding, matCx2.
Advanced: 8 storage texture formats, interpolation, force loop bounding.
Remaining gap: ray tracing, subgroups, external textures — specialized IR.

* test(wgsl): parser 62%→83.8%, lower 31%→54.5%

Parser: overrides, bitcast, increment/decrement, 11 assign ops, all type
specs (atomic, sampler, 16 textures), DependencyOrder (12 cases), error
recovery, Token.String, SourceError formatting, AST Pos() (33 nodes).
Lower: overrides, globals, control flow, 30+ texture ops, atomics (10),
barriers, constant folding (40+ math builtins), type constructors,
abstract concretization, entry points, error cases, interpolation.

* test(spirv): coverage 70.4%→75.4%, 107 tests

StorageFormatToImageFormat (36 formats), float32ToF16Bits edge cases,
ModuleBuilder methods (12), atomicOpcode (12 ops), 50+ WGSL compilation
tests with SPIR-V binary assertions (OpSelect, OpKill, derivatives,
pack/unpack polyfills, interpolation, barriers, textures, builtins).
Remaining gap: subgroups, ray queries — WGSL extensions not supported.

* fix(glsl,msl): panic→error, unsupported stage validation

GLSL: exitLoop/exitSwitch return error instead of panic. writeEntryPoint
rejects StageMesh/StageTask with clear error. 6 unsupported feature tests
with hand-crafted IR (ray query, mesh/task shader, binding array).
MSL: writeEntryPoint rejects unsupported stages. 2 unsupported tests.

* fix(hlsl,spirv): 11 panics→errors — enterprise error handling

HLSL: exitLoop/exitSwitch return error instead of panic (2 panics).
SPIR-V: emitScalarType, addressSpaceToStorageClass, emitScalarConstant,
resolveScalarType, findTypeHandleByID, resolveTypeResolution,
emitInlineType + cascading caller updates (~200 sites). 8 error-path
tests. 0 panics remaining in hlsl, 4 remaining in spirv ray_query
(deep signature cascade, separate task).

* docs: update for v0.17.12 — ARCH-001 refactoring, 12/18 packages ≥80% coverage, 13 panics→errors

* fix: dead code cleanup + nilerr fixes — 11 unused functions removed, 2 swallowed errors fixed

Removed 11 unused functions from wgsl/internal/lower/lower.go.
Fixed 5 unused params (prefix _). Fixed 3 unused returns.
Fixed 2 nilerr in spirv/backend.go (silently swallowing errors).
0 unused/unparam/nilerr lint issues.

* style: fix gofmt in module_test.go, backend tests

* fix: update .golangci.yml paths for internal/ package structure

Exclusion paths updated after git mv: wgsl/parser.go → wgsl/internal/parser/,
wgsl/lower.go → wgsl/internal/lower/, msl/ → msl/internal/codegen/,
hlsl/ → hlsl/internal/codegen/, etc. Added internal/registry and
internal/backend/hlsl_keywords exclusions. 0 lint issues.

v0.17.11

Toggle v0.17.11's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(dxil): gg 61/61 — array-of-vector flattening, fine.wgsl fixed (BU…

…G-DXIL-041) (gogpu#71)

* fix(wgsl): validate math builtin argument count — SIGSEGV → error (gogpu#170)

Add mathMinArgs() that maps MathFunction to required argument count.
dot/cross/distance/reflect/step/pow/atan2 require 2, mix/smoothstep/
clamp/fma require 3. Catches dot(v) with 1 arg at lowering time instead
of crashing in SPIR-V backend with nil pointer dereference.

Fixes gogpu/wgpu#170

* fix(dxil): array-of-vector flattening — GEP scaling + multi-scalar load (BUG-DXIL-041)

fine.wgsl "Invalid record" caused by 3 bugs in flattened array<vec4,N>:
(1) GEP index not scaled by vecWidth, (2) single-scalar load instead
of vec4 load, (3) garbage component IDs from missing pendingComponents.
gg production: 58/59 → 61/61 (0 failures). Fixes BUG-DXIL-041.

* docs: update public docs — gg 61/61 (100%), fine.wgsl fixed, 105 diff=0

* fix: resolve all golangci-lint issues — goconst constants, nolint cleanup, tmp/ exclusion

Extract constants: errExpectedParameterName/MemberName/VariableName/Type
(parser.go), semPosition/semTarget (semantic.go), hlslFloat (resources.go),
samplerHeapName/comparisonSamplerHeapName (sampler_heap.go), outcomeSkip
(corpus.go). Remove 4 unused //nolint:gosec. Exclude wgsl/lexer.go and
wgsl/token.go keyword maps from goconst. Exclude tmp/ from lint.

v0.17.10

Toggle v0.17.10's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat(dxil): 105 golden diff=0, 55.1% parity — ViewID, workgroup decom…

…p, scheduling infra (gogpu#70)

* feat(dxil): alignment encoding fix, bitcast constant fold, TBAA normalizer — +47 lines parity

Alignment: log2(bytes)+1 for store/load/alloca/globalvar. Workgroup
vars get 8-byte alignment for i64/f64. Bitcast constant fold: float
constants in raw buffer stores folded to i32 literals via Float32bits.
Binary constant folding infrastructure. TBAA metadata stripped.
104 diff=0, 54.7% parity (was 54.5%).

* feat(dxil): constant fold int-to-float casts, mul-to-shl in CBV/UAV — +33 lines parity

tryFoldNumericCast for sitofp/uitofp const folding. addMulOrShlInstr
for CBV/UAV byte-offset stride. 104 diff=0, 54.8% parity (was 54.7%).
Remaining 78 shaders need architectural passes.

* feat(dxil): instruction scheduling infrastructure — eval-right-first, resource read detection

emitBinaryOperands evaluates right operand first when it leads to resource
read. exprLeadsToResourceRead walks Load/AccessIndex/GlobalVariable chains.
leafEmitPriority classifies reassociate leaves. No metric change yet —
blocked by StmtEmit range boundaries. Fix: merge consecutive emit ranges
within same basic block (future work).

* feat(dxil): merge consecutive StmtEmit ranges for cross-range reassociation

emitBlock detects adjacent StmtEmit statements and processes them via
emitMergedStmtEmit with gap-aware membership set. Enables reassociate
pass to see chains spanning emit range boundaries. +4 lines parity.
Full instruction scheduling needs scheduler pass for multi-use intermediates.

* feat(dxil): ViewID ExprAlias + ExprPhi taint — precise post-mem2reg dataflow, 105 diff=0

ViewID dataflow now handles ExprAlias (forward taint) and ExprPhi
(union incoming edges) instead of falling back to conservative
all-inputs→all-outputs. Fixes per-scalar tracking after mem2reg
SSA promotion. 105 diff=0 (was 104), 55.1% parity (was 54.8%).
Newly diff=0: interface/vertex_two_structs.

* feat(dxil): workgroup struct decomposition — per-member globals with MSVC names

Struct-typed workgroup globals decomposed into N separate addrspace(3)
globals with MSVC-mangled member suffix names matching DXC. Linkage
override for external decomposed members. +13 lines parity.
105 diff=0, 55.1% parity.

* docs: update public docs — 105 golden diff=0, 55.1% parity

v0.17.9

Toggle v0.17.9's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
feat(dxil): 104 golden diff=0, 54.5% parity — loadInput DCE, Quantize…

…F16, sigId fixes (gogpu#69)

* feat(dxil): zero-store promotion, cast elimination, strength reduction — +2 golden diff=0

Zero-store local promotion: unassigned struct members resolve to zero.
Same-type integer cast elimination: bitcast i32↔i32 is no-op.
Sub→add canonicalization: sub X,C → add X,-C for positive constants.
Mul→shl strength reduction: mul X,2^N → shl X,N.
Normalizer: strip nsw/nuw/exact integer flags, fast on fcmp.
96 diff=0 (was 94), 48.6% parity (was 48.1%), +125 lines.

* feat(dxil): per-member loadInput DCE via backwards reachability — +2 golden diff=0

usedStructMembers() with computeLiveExprs() backwards analysis eliminates
dx.op.loadInput calls for struct input members never consumed by shader body.
Handles post-inlining patterns where intermediate expressions fall outside
StmtEmit ranges. 98 diff=0 (was 96), 49.6% parity (was 48.6%), +288 lines.
Newly diff=0: skybox/fs_main, msl-vpt-formats-x1/render_vertex.

* feat(dxil): input sigId fix, ViewID StartCol, cross-arg ordering — 100 golden diff=0

Three bugs: (1) sigId used register row instead of element index — broke
packed inputs sharing same row. (2) ViewID inScalarToComp ignored StartCol
offset. (3) Cross-argument struct inputs emitted in declaration order,
DXC emits reverse signature order. 100 diff=0 (was 98), 49.6% parity.
Newly diff=0: unconsumed_vertex_outputs_frag/fs_main, mesh-shader/fs_main.

* feat(dxil): QuantizeF16 legacy ops, Int64 flag from bitcode, MSVC groupshared names — 103 golden diff=0

QuantizeF16 via dx.op.legacyF32ToF16/F16ToF32 (not fptrunc/fpext) —
eliminates NativeLowPrecision flag, fixes 13-shader header cascade.
Int64 flag scanned from emitted module, not IR types. AtomicInt64OnHeapResource
flag for 64-bit atomics on non-workgroup resources. MSVC name decoration
for workgroup variables. 103 diff=0 (was 100), 54.3% parity (was 49.6%).

* feat(dxil): createHandle legacy, SM version normalization — 104 golden diff=0

Always use createHandle (opcode 57), removed unused createHandleFromBinding
path + 9 dead functions. SM version normalized in golden comparison.
AtomicInt64OnHeapResource flag test. 104 diff=0 (was 103), 54.5% parity.

* docs: update public docs — 104 golden diff=0, 54.5% parity

* style: fix gofmt in opcodes.go and reassociate_test.go