MDN states:
- [...] A WebGPU adapter effectively represents a physical GPU and driver available on the underlying system, in your code.
- A logical device is an abstraction via which a single web app can access GPU capabilities in a compartmentalized way. Logical devices are required to provide multiplexing capabilities. A physical device's GPU is used by many applications and processes concurrently, including potentially many web apps. Each web app needs to be able to access WebGPU in isolation for security and logic reasons.
So in short, GPUAdapter
is your actual physical GPU. And if your system has multiple GPUs requestAdapter()
might result in different GPUs being used depending on the options you provided.
GPUDevice
on the other hand exists only in order to provide isolation between applications. Your page should not be able to access the textures from another page and vice versa. But calling requestDevice()
multiple times from the same page is still allowed and enables you to maintain isolation between multiple components on your page.
The WebGPU explainer also has a good explanation:
A WebGPU "adapter" (GPUAdapter) is an object which identifies a particular WebGPU implementation on the system (e.g. a hardware accelerated implementation on an integrated or discrete GPU, or software implementation). Two different GPUAdapter objects on the same page could refer to the same underlying implementation, or to two different underlying implementations (e.g. integrated and discrete GPUs).
The set of adapters visible to the page is at the discretion of the user agent.
A WebGPU "device" (GPUDevice) represents a logical connection to a WebGPU adapter. It is called a "device" because it abstracts away the underlying implementation (e.g. video card) and encapsulates a single connection: code that owns a device can act as if it is the only user of the adapter. As part of this encapsulation, a device is the root owner of all WebGPU objects created from it (textures, etc.), which can be (internally) freed whenever the device is lost or destroyed. Multiple components on a single webpage can each have their own WebGPU device.
All WebGPU usage is done through a WebGPU device or objects created from it. In this sense, it serves a subset of the purpose of WebGLRenderingContext; however, unlike WebGLRenderingContext, it is not associated with a canvas object, and most commands are issued through "child" objects.