Skip to main content

A Python interface for the Dawn WebGPU engine.

Project description

dawn-python

PyPI version

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

  1. Install from PyPI

pip install dawn-python

  1. 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

  1. Build dawn or use the pre-built lib in the repo
  2. pip install ctypeslib2
  3. clang2py -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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dawn_python-0.3.0.tar.gz (19.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dawn_python-0.3.0-py3-none-any.whl (19.2 MB view details)

Uploaded Python 3

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

Hashes for dawn_python-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9950e6902d47513732981f92a98ff235d2269b3cb7bd6da8dbeb3e21b104c5e4
MD5 369a9a6b93fd6f905a81989193187919
BLAKE2b-256 0e4a1d9f130149dadcd95900911d6b457680cde265244ac73420e9262aa8ac04

See more details on using hashes here.

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

Hashes for dawn_python-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27b2878d60dc7c461f86283ec86981e781efec9f464b688c33aebd842e0854cc
MD5 991b6607caa007869d3cd44fa319841d
BLAKE2b-256 716079521bc4b9154d5c8521f462b67c0edc5a45e3387b3b8efa4e1666426296

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page