GPU¶
- class wgpu.GPU¶
Bases:
object
The entrypoint to the wgpu API.
The starting point of your wgpu-adventure is always to obtain an adapter. This is the equivalent to browser’s
navigator.gpu
. When a backend is loaded, thewgpu.gpu
object is replaced with a backend-specific implementation.- enumerate_adapters()¶
Get a list of adapter objects available on the current system.
An adapter can then be selected (e.g. using it’s summary), and a device then created from it.
Note that the same device may be present with different backends (e.g. vulkan/d3d12/opengl).
- async enumerate_adapters_async()¶
Async version of enumerate_adapters.
- get_preferred_canvas_format()¶
Not implemented in wgpu-py; use GPUCanvasContext.get_preferred_format() instead. The WebGPU spec defines this function, but in wgpu there are different kinds of canvases which may each prefer/support a different format.
- request_adapter(**parameters)¶
Create a
GPUAdapter
, the object that represents an abstract wgpu implementation, from which one can request aGPUDevice
.- Parameters:
power_preference (PowerPreference) – “high-performance” or “low-power”.
force_fallback_adapter (bool) – whether to use a (probably CPU-based) fallback adapter.
canvas (WgpuCanvasInterface) – The canvas that the adapter should be able to render to. This can typically be left to None.
- async request_adapter_async(**parameters)¶
Async version of
request_adapter()
.
- property wgsl_language_features¶
A set of strings representing the WGSL language extensions supported by all adapters. Returns an empty set for now.