pywgpu is a high-performance Python port of the wgpu-rs project. It provides a modern, safe, and strictly-typed interface for graphics and compute on the GPU, following the WebGPU standard.
The project is an exact structural copy of the original wgpu repository, divided into the following components:
pywgpu-hal: Hardware Abstraction Layer. Implements low-level backends (Vulkan, Metal, DX12, GLES) via CFFI.pywgpu-core: The "brain" of the library. Handles resource management, state tracking, and validation.pywgpu: High-level, user-facing Pythonic API (equivalent to thewgpucrate).naga: A pure Python port of the Naga shader translator (WGSL/SPIR-V translation and validation).pywgpu-types: Shared data structures and descriptors powered by Pydantic V2.
- Python 3.12+: Leveraging modern features like
typing.Protocoland improved generics. - Strict Static Typing: 100% type coverage. Verified with
pyrightin strict mode. - Pydantic V2: Robust validation for all GPU descriptors and state objects.
- CFFI: High-performance interaction with native graphics APIs.
- NumPy: Efficient zero-copy data handling for buffers and textures.
- SPECIFICATION.md: Detailed technical requirements and architecture goals.
- AGENTS.md: Guidelines and standards for AI-driven development.
The project is in a phase of active logic implementation, having moved significantly beyond the initial skeleton stage.
Key Achievements:
- ✓ Naga WGSL Frontend: Lowerer (AST to IR conversion) is fully complete.
- ✓ Constant Evaluator: Core infrastructure fully complete.
- ✓ Naga GLSL Frontend: Foundation (Types, Offset, Error, Token) complete.
- Architectural Identity: Every module mirrors its Rust counterpart.
- Type Safety First: No
Any, no implicit conversions. - Performance: Minimal overhead between Python and the GPU.