Skip to content

wpmed92/pydawn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A Python interface for the Dawn WebGPU engine

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages