Skip to main content

instance

Function instance 

Source
pub fn instance() -> Instance
Expand description

Creates the wgpu instance a renderer’s adapter should come from.

The instance enables the primary backends only: Vulkan, Metal and DX12, and WebGPU on the web. The renderer needs compute shaders, which the OpenGL backend serves poorly, and enabling it loads the system’s OpenGL and EGL drivers next to the Vulkan one. A machine without a primary backend is usually better served by the CPU renderer. The WGPU_BACKEND environment variable still picks the backends when it is set.

When this instance finds no adapter, GpuRenderer::headless retries with every backend, OpenGL included, and so does a window that asks for the GPU renderer explicitly. A caller that requests its own adapter can do the same with an instance from InstanceDescriptor::new_without_display_handle_from_env.