A Python interface for the Dawn WebGPU engine.
Project description
dawn-python
ctypeslib based python bindings to the Dawn WebGPU engine with a focus on the compute pipeline. Besides the autogenerated bindings, a small utils interface (similar to wgpu-py) is provided to make it easier to run compute.
Chromium version used in pydawn: 133.0.6940.0
How to use
- Install from PyPI
pip install dawn-python
- Import utils, and webgpu
from pydawn import utils, webgpu
if __name__ == "__main__":
# Creating an adapter
adapter = utils.request_adapter_sync(power_preference=webgpu.WGPUPowerPreference_HighPerformance)
# Creating a device with a list of required features
dev = utils.request_device_sync(adapter, [webgpu.WGPUFeatureName_ShaderF16, webgpu.WGPUFeatureName_TimestampQuery])
For more details see examples/query_set.py
Generating bindings
- Build dawn or use the pre-built lib in the repo
pip install ctypeslib2clang2py -l libwebgpu_dawn.dylib webgpu.h --nm nm_patch.py -o webgpu.py
Examples
python3 examples/simple_compute.py
Supported platforms
- MacOS (arch: x86_64, arm64, optimal backend: Metal)
- Ubuntu (arch: x86_64, optimal backend: Vulkan)
- Windows (arch: x86_64, optimal backend: DirectX)
License
BSD 3-Clause, please see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dawn_python-0.3.0.tar.gz.
File metadata
- Download URL: dawn_python-0.3.0.tar.gz
- Upload date:
- Size: 19.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9950e6902d47513732981f92a98ff235d2269b3cb7bd6da8dbeb3e21b104c5e4
|
|
| MD5 |
369a9a6b93fd6f905a81989193187919
|
|
| BLAKE2b-256 |
0e4a1d9f130149dadcd95900911d6b457680cde265244ac73420e9262aa8ac04
|
File details
Details for the file dawn_python-0.3.0-py3-none-any.whl.
File metadata
- Download URL: dawn_python-0.3.0-py3-none-any.whl
- Upload date:
- Size: 19.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27b2878d60dc7c461f86283ec86981e781efec9f464b688c33aebd842e0854cc
|
|
| MD5 |
991b6607caa007869d3cd44fa319841d
|
|
| BLAKE2b-256 |
716079521bc4b9154d5c8521f462b67c0edc5a45e3387b3b8efa4e1666426296
|