refactor: ARCH-001 internal packages + 12/18 coverage ≥80% + 13 panics→errors#72
Merged
Conversation
…n (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.
… (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.
…n (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.
…rn (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.
…/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.
…attern (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.
…rn (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.
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.
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.
1341 LOC. Covers: Version.Less, BoundsCheckPolicies, blockEndsWithReturn, builtinInputAttribute (19 builtins), resolveInterpolation, compile integration (workgroup init, dual-source blend, storage buffers, etc.).
writeHelperFunctions 12%→100%, resolveTypeInner 18%→tested, scanBlockForStages 16%→91%, tryConstEvalUnary 23%→100%, writeUniformBlock 28%→improved, plus writeCallResult, writeAtomicResult, formatConstResult, computeBlockNames, expandBoolVectorOp all from 0%.
…OV-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.
…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.
…n, 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.
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.
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.
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.
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.
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.
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.
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.
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).
… coverage, 13 panics→errors
…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.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ARCH-001: Enterprise internal packages refactoring + test coverage + error handling.
Architecture (DXIL pattern applied to all backends)
internal/codegen/(9 files)internal/codegen/(10 files)internal/codegen/+ shared namer ininternal/backend/internal/codegen/(5 files)internal/parser/+internal/lower/internal/registry/extractedTest coverage (12/18 packages ≥80%)
| 100% | textutil, dxil/module |
| 83-97% | backend, mem2reg, dce, parser, bitcode, viewid, sroa, ir, container, glsl |
Error handling
Metrics (unchanged)
Test plan
go build ./...