Skip to content

Interoperability for multiple libraries using wgpu #704

@almarklein

Description

@almarklein

We cannot interoperate with data structures based on OpenGL/OpenCL, but we can make sure that multiple libraries that use wgpu-py can interoperate. With that I mainly mean that buffers and textures created by one tool can be consumed by another. E.g. write a shadertoy, and use the resulting texture in Pygfx or Fastplotlib. Now that we're looking into compute more (see pygfx/pygfx#1063) this becomes more relevant; being able to use the GPU to do compute, and use resulting buffers/textures to render stuff. Or render stuff and run compute on the result.

To make this work we basically need two things:

  • Libs need to make use of the same device object. So we need a central place where the device object is obtained, and where libs can express the need for features and limits. We already have the notion of "default device" in wgpu.utils. We could expand that.
  • Libs need to be able to obtain the "native" (i.e. wgpu-py) object from the library-specific class. E.g. get a GPUBuffer from a pygfx.Buffer. We could implement something similar to the Python array protocol. This comes down to defining a spec at wgpu-py, and implementing it in Pygfx and others.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions