2.2 KiB
2.2 KiB
WSG - WGPU Simple Graphics Library
Project Type
Rust workspace (2024 edition) wrapping wgpu for simple 3D drawing operations.
Workspace Structure
Cargo.toml # workspace root — no dependencies here
lib/Cargo.toml # wsg-lib crate: wgpu 30.0.0, winit 0.30
examples/Cargo.toml # depends on wsg-lib via path reference
lib/lib.rs # lib entry point
lib/context.rs # Context type (aggregates wgpu objects: Instance, Surface, Adapter, Device, Queue)
lib/renderer.rs # renderer implementation
examples/src/main.rs # example binary
Key convention: wsg-lib is referenced from examples/ via relative path (path = "../lib"). Do not publish this to crates.io as-is — it uses a local path dependency.
Essential Commands
| Action | Command |
|---|---|
| Build everything | cargo build --workspace |
| Run examples | cargo run -p examples |
| Test | cargo test --workspace |
| Check | cargo check --workspace |
| Format | cargo fmt --all |
No custom scripts or linting tooling beyond standard Cargo conventions.
Architecture Overview
The library's purpose is to abstract the five core wgpu objects into a single Context:
- Instance — GPU backend selection (Vulkan/Metal/DX12)
- Surface — window rendering surface (via winit)
- Adapter — physical/logical GPU device
- Device — buffer/texture/pipeline creation
- Queue — command submission
WGPU doesn't have a native "Context" object — this type groups them together for a simpler user API. See README.md for the French documentation of each component.
Gotchas
- Rust 2024 edition is used. Ensure your Rust toolchain supports it (
rustup update). - wgpu 30.0.0 is pinned in
lib/Cargo.toml. The comment says "check the latest version" — verify compatibility before upgrading. - No feature flags, no dev-dependencies, no tests yet. Adding any requires updating both
Cargo.tomlfiles if the dependency spans crates. - The workspace has no
[workspace.dependencies]section. Dependencies are declared per-crate rather than centrally.
lean-ctx
Prefer lean-ctx MCP tools over native equivalents for token savings. Full rules: @LEAN-CTX.md