-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Labels
priority: highImportant for next releaseImportant for next releasetype: refactorCode cleanup, no behavior changeCode cleanup, no behavior change
Description
The public wgpu API layer was the last thing we built, and it shows. The HAL backends have mature logging (73 structured slog calls across Vulkan, Metal, DX12, GLES) and consistent validation — but the public layer that users actually interact with has none of that discipline.
This came up during PR #95 review — a contributor asked about validation style and we realized there isn't one. There are at least 4 different patterns in the same package.
What needs investigation
Logging:
- Public API layer has zero
slogcalls — no diagnostics at all - HAL backends log everything (resource creation, errors, debug messages)
- Users debugging issues get nothing from the layer they interact with
Validation:
WriteBuffer: compact combined nil checkReadBuffer: separate checks, different error formatdevice.go: sentinel errors +fmt.Errorfmixencoder.go: no validation at all, straight passthrough to HAL- No clear rule on what should be checked where
Error handling:
- Mixed formats:
"wgpu: queue not available"vs"wgpu: WriteBuffer: queue or buffer is nil"vs"wgpu: buffer descriptor is nil" - Some HAL errors wrapped with context, some passed through raw
- Sentinel errors (
ErrReleased) used inconsistently
What we need to figure out
- What should the public API layer actually validate vs delegate to HAL?
- Should we log at the public layer, and if so — what and at what level?
- One consistent error message format across all public methods
- How does Rust wgpu handle this? (spoiler: zero validation in public layer, everything in wgpu-core)
- Is our current split (public API → HAL) the right architecture, or do we need a core validation layer in between?
Deliverable
Research document + style guide before any code changes. We want to get this right, not just patch it.
Related
- [feat] Add WriteTexture to Queue #95 —
WriteTexturePR that exposed the inconsistency - research: assess type aliases in wgpu public API — problems and recommendations #96 — type aliases research (related public API design question)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: highImportant for next releaseImportant for next releasetype: refactorCode cleanup, no behavior changeCode cleanup, no behavior change