Skip to content

Metal backend's wgpu_hal::Device::wait implementation polls instead of waiting #8119

@jimblandy

Description

@jimblandy

In wgpu_hal, <metal::Device as Device>::wait checks MTLCommandBuffer's status every 1ms until it is Completed or the timeout is reached. This is very mid (if that's not a contradiction in terms).

There is no "wait with timeout" operation in Metal, but there is an addCompletedHandler method on MTLCommandBuffer, which is called "on an undefined thread". wgpu_hal::metal::Device could have a shared condition variable protecting the fence value, Queue::submit could register an addCompletedHandler callback to advance the fence value, and Device::wait could use std::sync::CondVar::wait_timeout to wait for a given value.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions