Repository navigation
Open
Labels
area: coreCore WebGPU implCore WebGPU impleffort: 13Epic, 2+ weeksEpic, 2+ weekspriority: criticalRelease blocker, security, data lossRelease blocker, security, data lossstatus: confirmedVerified, ready for workVerified, ready for worktype: refactorCode cleanup, no behavior changeCode cleanup, no behavior change
Description
Summary
Move ALL implementation to internal/ — keep thin public adapter packages for backward compatibility. Zero breaking changes for ecosystem repos.
Principle: if implementation CAN be hidden — it MUST be hidden.
Current problem
38 public packages on pkg.go.dev. 14,753 LOC of implementation in root package. Backend implementation details publicly importable.
Approach: Thin Adapters + Internal Implementation
NOT a "move everything and break consumers" migration. Public packages stay but become thin adapters. Implementation moves to internal/.
Public (thin, stays): Internal (implementation):
wgpu/ wgpu/internal/
├── *.go (~2-3K LOC thin) ├── hal/vulkan/ ← actual 15K LOC
├── hal/ ├── hal/dx12/ ← actual 12K LOC
│ ├── vulkan/init.go (registration)├── hal/metal/ ← actual 8K LOC
│ ├── metal/init.go ├── hal/gles/ ← actual 10K LOC
│ ├── dx12/init.go ├── hal/software/ ← actual 8K LOC
│ ├── gles/init.go ├── core/ ← actual 13K LOC
│ └── allbackends/ ├── device/ ← from root
├── core/ (thin re-exports) └── ...
└── docs/
Who imports what (verified)
- gogpu:
_ "github.com/gogpu/wgpu/hal/vulkan"— blank import for registration → init.go stays public, keeps working - gg:
import "github.com/gogpu/wgpu/core"— typed GPU operations → thin re-exports stay public, keeps working - ui, g3d, naga: no hal/core imports
Migration plan (3 PRs)
| PR | What | Breaking |
|---|---|---|
| 1 | hal/ backends → internal/hal/ (keep thin init.go public) | None |
| 2 | core/ → internal/core/ (keep thin re-exports public) | None |
| 3+ | Root extraction by concern → internal/{device,queue,...}/ | None |
Result
- pkg.go.dev: ~5 clean packages instead of 38
- Root package: ~2-3K LOC (types + delegation)
- Zero runtime overhead (Go inlines)
- Zero breaking changes for ecosystem
ADR
Architecture Decision Record: ADR-070
Reacted by lkmavi
Metadata
Metadata
Assignees
Labels
area: coreCore WebGPU implCore WebGPU impleffort: 13Epic, 2+ weeksEpic, 2+ weekspriority: criticalRelease blocker, security, data lossRelease blocker, security, data lossstatus: confirmedVerified, ready for workVerified, ready for worktype: refactorCode cleanup, no behavior changeCode cleanup, no behavior change
Activity
[-]architecture: move core/ + hal/ to internal/ (ADR-070)[/-][+]architecture: move ALL implementation to internal/ (ADR-070)[/+]docs: update CONTRIBUTING.md + ARCHITECTURE.md — internal/ principle,…