EasyGPU
Status: 0.1.1 — command encoding + FakeGPU complete; real backend on the roadmap.
EasyGPU is a Python wrapper for WebGPU with a built-in FakeGPU that
lets you TDD your command-encoding logic without a GPU.
What works in 0.1.1
- ✅
GPUProtocol (73 methods) +configure/get_gpu - ✅
FakeGPU— records and asserts command encoding without a GPU, includingrender_pass_sequence()/compute_pass_sequence()call trees - ✅ Core objects —
Buffer,Texture/TextureView/Sampler,ShaderModule,RenderPipeline/ComputePipeline,BindGroup+PipelineLayout,QuerySet,Adapter/Device/Queue - ✅ Complete render pipeline — depth/stencil, blend, multisample + A2C, indexed draws, viewport/scissor, MRT via multiple color targets
- ✅ Compute pipeline — storage buffers, dispatch, indirect dispatch
- ✅ Render bundles — reusable draw batches
- ✅ Indirect draws on render passes
- ✅ Query sets — timestamp/occlusion +
resolve_query_set - ✅ Buffer mapping —
map_async/get_mapped_range/unmap - ✅ Texture ops —
write_texture,copy_texture_to_*,generate_mipmap - ✅ Context managers —
with encoder.begin_render_pass(...):auto-ends - ✅ Spec-aligned enums — IDL flags for
ShaderStage/BufferUsage/TextureUsage - ✅ Zero runtime dependencies —
struct.packfor data, pure-Pythoneasygpu.matrix - ✅ 13 examples — 11
webgpu-samplesports + 2 self-authored (triangle, alpha_to_coverage)
What does NOT work in 0.1.1
- ❌ No real GPU backend — the
GPUProtocol is the deliverable; the wrappers raiseGPUValidationErrorunless youconfigure()a fake or real backend - ❌ No swapchain / window output (examples bind color attachment handle
0) - ❌ No dynamic-offset bind groups (subset-range bindings work via
BufferSlice; seetwo_cubes) - ❌ No numpy integration: vertex data is raw
bytes(float sequences are struct-packed); the numpy upload path is deferred - ❌ WGSL execution (FakeGPU records calls, it does not run shaders)
Examples
All examples live in the examples/
directory of the repository and are not shipped in the wheel — run them from
a clone or from the source distribution. They run from the repository root;
use Python's -m form (e.g. uv run python -m examples.triangle) so the
shared helper modules under examples/ resolve.
Ports of webgpu-samples, each
encoding one frame against FakeGPU and verified by a pytest. 11
webgpu-samples ports + 2 self-authored examples (triangle,
alpha_to_coverage); some ports are simplified (wireframe, reversed_z).
WGSL and data are inlined/adapted (no browser, no image assets).
| Example | What it teaches |
|---|---|
examples/triangle.py |
minimal vertex/fragment pipeline |
examples/rotating_cube.py |
perspective, MVP uniforms, depth24plus |
examples/two_cubes.py |
one uniform buffer, two bind groups at 256-byte offsets |
examples/instanced_cube.py |
instancing, array<mat4x4f, 16>, instance_index |
examples/textured_cube.py |
texture + sampler + write_texture |
examples/cameras.py |
look-at view matrix, cube.wgsl |
examples/points.py |
Fibonacci sphere, instanced billboards, blending, 4 pipelines |
examples/wireframe.py |
set_index_buffer + draw_indexed, depth bias line overlay (simplified) |
examples/reversed_z.py |
reversed-Z depth precision, split viewport (color mode) |
examples/blending.py |
source-over blend state + set_blend_constant |
examples/alpha_to_coverage.py |
4x MSAA + alpha-to-coverage + resolve target |
examples/shadow_mapping.py |
dual-pass shadow mapping, depth32float, comparison sampler |
examples/compute_boids.py |
compute pipeline, storage ping-pong, instanced sprites |
Run one directly, e.g.:
uv run python -m examples.textured_cube
uv run pytest tests/test_textured_cube.py -v
Quickstart
From source (contributors)
uv sync
uv run pytest # headless, no GPU needed
uv run python -m examples.triangle
From PyPI (users)
pip install easygpu
python -c "from easygpu.fake_gpu import FakeGPU; print(FakeGPU())"
Note: importing
easygpuemits aUserWarningexplaining that 0.1.1 ships no real backend. It will go away once one lands.
Roadmap
- 0.1.0: command encoding +
FakeGPU, 13 examples, zero runtime deps - 0.1.1 (current): README fix — examples run as modules (
python -m examples.xxx) - 0.2.0: real backend behind the
GPUProtocol (wgpu-py), keeping the Protocol stable - 0.3.0: swapchain + windowed output
- 0.4.0: dynamic-offset bind groups, GPU timing readback
- Later: more
webgpu-samplesports
Project layout
src/easygpu/— library (Protocol seam + wrapper objects +fake_gpu.py)examples/— 13 runnable examples (11webgpu-samplesports + 2 self-authored), plus shared helper modules (shaders.py,shadow_shaders.py,boids_shaders.py,cube_mesh.py,textures.py) that the examples importtests/— pytest suite for the library and every example (headless)
The layout above describes the source repository. The published wheel contains only
src/easygpu/—examples/andtests/live in the repository and in the source distribution (easygpu-0.1.1.tar.gz).
Metadata
Release files for EasyGPU 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| easygpu-0.1.1.tar.gz | 61.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easygpu-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 92.6 kB
Release files / easygpu-0.1.1.tar.gz
| Download URL | easygpu-0.1.1.tar.gz |
|---|---|
| Size | 61.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83b7dfcd809b6af14a79c431aeea2c0b909fbd363498f9fcb7defd43a5fc2c2d
|
|
BLAKE2b-256 checksum How to use checksums |
4cfe6c527a90ad75122966f1cd5136724557ef09cae2b9c28b1bd33094133e5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / easygpu-0.1.1-py3-none-any.whl
| Download URL | easygpu-0.1.1-py3-none-any.whl |
|---|---|
| Size | 30.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a42946094bf459ad5707f55dbb85eb98187640081a05fee398ca1216c7813609
|
|
BLAKE2b-256 checksum How to use checksums |
20a87f15538f8e5025ba6d9f4be57edd52c625ea0a45c46e53ba742ff5468ac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|