files/en-us/web/api/gpudevice/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The GPUDevice interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} represents a logical GPU device. This is the main interface through which the majority of WebGPU functionality is accessed.
A GPUDevice object is requested using the {{domxref("GPUAdapter.requestDevice()")}} method.
{{InheritanceDiagram}}
Inherits properties from its parent, {{DOMxRef("EventTarget")}}.
{{domxref("GPUDevice.adapterInfo", "adapterInfo")}} {{ReadOnlyInline}}
{{domxref("GPUDevice.features", "features")}} {{ReadOnlyInline}}
{{domxref("GPUDevice.label", "label")}}
{{domxref("GPUDevice.limits", "limits")}} {{ReadOnlyInline}}
{{domxref("GPUDevice.lost", "lost")}} {{ReadOnlyInline}}
{{domxref("GPUDevice.queue", "queue")}} {{ReadOnlyInline}}
Inherits methods from its parent, {{DOMxRef("EventTarget")}}.
{{domxref("GPUDevice.createBindGroup", "createBindGroup()")}}
{{domxref("GPUDevice.createBindGroupLayout", "createBindGroupLayout()")}}
{{domxref("GPUDevice.createBuffer", "createBuffer()")}}
{{domxref("GPUDevice.createCommandEncoder", "createCommandEncoder()")}}
{{domxref("GPUDevice.createComputePipeline", "createComputePipeline()")}}
{{domxref("GPUDevice.createComputePipelineAsync", "createComputePipelineAsync()")}}
{{domxref("GPUDevice.createPipelineLayout", "createPipelineLayout()")}}
{{domxref("GPUDevice.createQuerySet", "createQuerySet()")}}
{{domxref("GPUDevice.createRenderBundleEncoder", "createRenderBundleEncoder()")}}
{{domxref("GPUDevice.createRenderPipeline", "createRenderPipeline()")}}
{{domxref("GPUDevice.createRenderPipelineAsync", "createRenderPipelineAsync()")}}
{{domxref("GPUDevice.createSampler", "createSampler()")}}
{{domxref("GPUDevice.createShaderModule", "createShaderModule()")}}
{{domxref("GPUDevice.createTexture", "createTexture()")}}
{{domxref("GPUDevice.destroy", "destroy()")}}
{{domxref("GPUDevice.importExternalTexture", "importExternalTexture()")}}
{{domxref("GPUDevice.popErrorScope", "popErrorScope()")}}
null if no error occurred.{{domxref("GPUDevice.pushErrorScope", "pushErrorScope()")}}
async function init() {
if (!navigator.gpu) {
throw Error("WebGPU not supported.");
}
const adapter = await navigator.gpu.requestAdapter();
if (!adapter) {
throw Error("Couldn't request WebGPU adapter.");
}
const device = await adapter.requestDevice();
const shaderModule = device.createShaderModule({
code: shaders,
});
// …
}
See the individual member pages listed above and the following demo sites for a lot more examples of GPUDevice usage:
{{Specifications}}
{{Compat}}