You request a GPU device by calling the requestDevice() method on a GPUAdapter instance, which returns a Promise that resolves to a GPUDevice object . This GPUDevice is the primary interface for communicating with the GPU . To obtain the GPUAdapter object itself, you first use the GPU.requestAdapter() method .
A basic implementation involves checking for WebGPU support via navigator.gpu, requesting the adapter, and then requesting the device from that adapter . For more specific requirements, you can pass an options object to requestDevice() that includes requiredFeatures (such as texture-compression-astc), requiredLimits (such as maxBindGroups), and a defaultQueue configuration . You can also request unknown limits without causing an error, as they will simply be undefined, which makes the code more resilient to changes in available limits .
These details are drawn from the MDN Web Docs reference for the GPUAdapter interface and its requestDevice() method. Note that WebGPU features and limit support can vary between browsers and hardware, so it is advisable to check the current official documentation for up-to-date compatibility information.