Skip to content

Allow checking type of wgpu::Instance's context #5142

@Wumpf

Description

@Wumpf

I ran into a situation where WebGPU adapter creation fails and I want to retry with WebGL (Chrome Linux 121 advertises WebGPU support but can't create adapters -.-)

Turns out though it's actually not easily possible to programmatically determine that this was the error: If the instance is created with both WebGPU & WebGL enabled and adapter creation fails subsequently,it might mean that either of the context type (webgpu or wgpu-core) was picked and failed. Only in the case of a webgpu-instance do I want to retry instance creation.
One hacky way to check for this is the result of as_hal, but this method is only available when wgpu_core compilation is enabled, and in the context I'm in (egui's guts) I don't know this.

Proposing to add this simple method on wgpu::Instance :
is_webgpu_instance() -> bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apiIssues related to API surface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions