How to use the wgpu.wgpu_ffi function in wgpu

To help you get started, we’ve selected a few wgpu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almarklein / wgpu-py / examples / test-wgpu.py View on Github external
inColor: input vec3 0,
    outColor: output vec4 0,
) {
    outColor = vec4(inColor, 1.0)
}
"""

##

# Instantiate gl-based wgpu context
if BACKEND == "GL":
    ctx = wgpu.wgpu_gl.GlWGPU()
elif BACKEND == "CTYPES":
    ctx = wgpu.wgpu_ctypes.RsWGPU()
elif BACKEND == "FFI":
    ctx = wgpu.wgpu_ffi.RsWGPU()
else:
    raise RuntimeError(f"Invalid backend {BACKEND}")


adapter_id = ctx.request_adapter(
    ctx.create_RequestAdapterOptions(
        power_preference=ctx.PowerPreference_Default,
        #backends = 1 | 2 | 4 | 8  # modern, but Dx12 is still buggy
        backends = 2 | 4  # Vulkan or Metal
        # on HP laptop: 2 and 8 are available, but 2 does not work. 8 works, but it wants zero bind groups :/
        # 1 => Backend::Empty,
        # 2 => Backend::Vulkan,
        # 4 => Backend::Metal,
        # 8 => Backend::Dx12,
        # 16 => Backend::Dx11,
        # 32 => Backend::Gl,
github almarklein / wgpu-py / visvis2 / _renderer.py View on Github external
def __init__(self):
        self._pipelines = []

        ffi = wgpu.wgpu_ffi.ffi

        # todo: this context is not really a context, its just an API, maybe keep it that way, or make it a context by including device_id
        ctx = wgpu.wgpu_ffi.RsWGPU()
        self._ctx = ctx

        self._surface_size = 0, 0
        # backends = 1 | 2 | 4 | 8  # modern, but Dx12 is still buggy
        backends = 2 | 4  # Vulkan or Metal
        # on HP laptop: 2 and 8 are available, but 2 does not work. 8 works, but it wants zero bind groups :/
        # 1 => Backend::Empty,
        # 2 => Backend::Vulkan,
        # 4 => Backend::Metal,
        # 8 => Backend::Dx12,
        # 16 => Backend::Dx11,
        # 32 => Backend::Gl,

        # Initialize adapter id. It will be set from the callback that we pass
        # to request_adapter_async. At the moment, the callback will be called
        # directly (in-line), but this will change in the future when wgpu also