Skip to main content

GPUDevice

The GPUDevice interface of the WebGPU API represents a logical GPU device. This is the main interface through which the majority of WebGPU functionality is accessed. Available only in secure contexts.

MDN Reference

Extends​

Methods​

addEventListener()​

Call Signature​

addEventListener<K>(
type,
listener,
options?
): void;

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

Type Parameters​
Type Parameter
K extends "uncapturederror"
Parameters​
ParameterType
typeK
listener(this, ev) => any
options?boolean | AddEventListenerOptions
Returns​

void

Overrides​

EventTarget.addEventListener

Call Signature​

addEventListener(
type,
listener,
options?
): void;

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

Parameters​
ParameterType
typestring
listenerEventListenerOrEventListenerObject
options?boolean | AddEventListenerOptions
Returns​

void

Overrides​
EventTarget.addEventListener

createBindGroup()​

createBindGroup(descriptor): GPUBindGroup;

The createBindGroup() method of the GPUDevice interface creates a GPUBindGroup based on a GPUBindGroupLayout that defines a set of resources to be bound together in a group and how those resources are used in shader stages.

MDN Reference

Parameters​

ParameterType
descriptorGPUBindGroupDescriptor

Returns​

GPUBindGroup


createBindGroupLayout()​

createBindGroupLayout(descriptor): GPUBindGroupLayout;

The createBindGroupLayout() method of the GPUDevice interface creates a GPUBindGroupLayout that defines the structure and purpose of related GPU resources such as buffers that will be used in a pipeline, and is used as a template when creating GPUBindGroups.

MDN Reference

Parameters​

ParameterType
descriptorGPUBindGroupLayoutDescriptor

Returns​

GPUBindGroupLayout


createBuffer()​

createBuffer(descriptor): GPUBuffer;

The createBuffer() method of the GPUDevice interface creates a GPUBuffer in which to store raw data to use in GPU operations.

MDN Reference

Parameters​

ParameterType
descriptorGPUBufferDescriptor

Returns​

GPUBuffer


createCommandEncoder()​

createCommandEncoder(descriptor?): GPUCommandEncoder;

The createCommandEncoder() method of the GPUDevice interface creates a GPUCommandEncoder, used to encode commands to be issued to the GPU.

MDN Reference

Parameters​

ParameterType
descriptor?GPUCommandEncoderDescriptor

Returns​

GPUCommandEncoder


createComputePipeline()​

createComputePipeline(descriptor): GPUComputePipeline;

The createComputePipeline() method of the GPUDevice interface creates a GPUComputePipeline that can control the compute shader stage and be used in a GPUComputePassEncoder.

MDN Reference

Parameters​

ParameterType
descriptorGPUComputePipelineDescriptor

Returns​

GPUComputePipeline


createComputePipelineAsync()​

createComputePipelineAsync(descriptor): Promise<GPUComputePipeline>;

The createComputePipelineAsync() method of the GPUDevice interface returns a Promise that fulfills with a GPUComputePipeline, which can control the compute shader stage and be used in a GPUComputePassEncoder, once the pipeline can be used without any stalling.

MDN Reference

Parameters​

ParameterType
descriptorGPUComputePipelineDescriptor

Returns​

Promise<GPUComputePipeline>


createPipelineLayout()​

createPipelineLayout(descriptor): GPUPipelineLayout;

The createPipelineLayout() method of the GPUDevice interface creates a GPUPipelineLayout that defines the GPUBindGroupLayouts used by a pipeline. GPUBindGroups used with the pipeline during command encoding must have compatible GPUBindGroupLayouts.

MDN Reference

Parameters​

ParameterType
descriptorGPUPipelineLayoutDescriptor

Returns​

GPUPipelineLayout


createQuerySet()​

createQuerySet(descriptor): GPUQuerySet;

The createQuerySet() method of the GPUDevice interface creates a GPUQuerySet that can be used to record the results of queries on passes, such as occlusion or timestamp queries.

MDN Reference

Parameters​

ParameterType
descriptorGPUQuerySetDescriptor

Returns​

GPUQuerySet


createRenderBundleEncoder()​

createRenderBundleEncoder(descriptor): GPURenderBundleEncoder;

The createRenderBundleEncoder() method of the GPUDevice interface creates a GPURenderBundleEncoder that can be used to pre-record bundles of commands. These can be reused in GPURenderPassEncoders via the executeBundles() method, as many times as required.

MDN Reference

Parameters​

ParameterType
descriptorGPURenderBundleEncoderDescriptor

Returns​

GPURenderBundleEncoder


createRenderPipeline()​

createRenderPipeline(descriptor): GPURenderPipeline;

The createRenderPipeline() method of the GPUDevice interface creates a GPURenderPipeline that can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder.

MDN Reference

Parameters​

ParameterType
descriptorGPURenderPipelineDescriptor

Returns​

GPURenderPipeline


createRenderPipelineAsync()​

createRenderPipelineAsync(descriptor): Promise<GPURenderPipeline>;

The createRenderPipelineAsync() method of the GPUDevice interface returns a Promise that fulfills with a GPURenderPipeline, which can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder, once the pipeline can be used without any stalling.

MDN Reference

Parameters​

ParameterType
descriptorGPURenderPipelineDescriptor

Returns​

Promise<GPURenderPipeline>


createSampler()​

createSampler(descriptor?): GPUSampler;

The createSampler() method of the GPUDevice interface creates a GPUSampler, which controls how shaders transform and filter texture resource data.

MDN Reference

Parameters​

ParameterType
descriptor?GPUSamplerDescriptor

Returns​

GPUSampler


createShaderModule()​

createShaderModule(descriptor): GPUShaderModule;

The createShaderModule() method of the GPUDevice interface creates a GPUShaderModule from a string of WGSL source code.

MDN Reference

Parameters​

ParameterType
descriptorGPUShaderModuleDescriptor

Returns​

GPUShaderModule


createTexture()​

createTexture(descriptor): GPUTexture;

The createTexture() method of the GPUDevice interface creates a GPUTexture in which to store 1D, 2D, or 3D arrays of data, such as images, to use in GPU rendering operations.

MDN Reference

Parameters​

ParameterType
descriptorGPUTextureDescriptor

Returns​

GPUTexture


destroy()​

destroy(): void;

The destroy() method of the GPUDevice interface destroys the device, preventing further operations on it.

MDN Reference

Returns​

void


dispatchEvent()​

dispatchEvent(event): boolean;

The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

MDN Reference

Parameters​

ParameterType
eventEvent

Returns​

boolean

Inherited from​

EventTarget.dispatchEvent


importExternalTexture()​

importExternalTexture(descriptor): GPUExternalTexture;

The importExternalTexture() method of the GPUDevice interface takes an HTMLVideoElement or a VideoFrame object as an input and returns a GPUExternalTexture wrapper object containing a snapshot of the video that can be used as a frame in GPU rendering operations.

MDN Reference

Parameters​

ParameterType
descriptorGPUExternalTextureDescriptor

Returns​

GPUExternalTexture


popErrorScope()​

popErrorScope(): Promise<GPUError | null>;

The popErrorScope() method of the GPUDevice interface pops an existing GPU error scope from the error scope stack (originally pushed using GPUDevice.pushErrorScope()) and returns a Promise that resolves to an object describing the first error captured in the scope, or null if no error occurred.

MDN Reference

Returns​

Promise<GPUError | null>


pushErrorScope()​

pushErrorScope(filter): void;

The pushErrorScope() method of the GPUDevice interface pushes a new GPU error scope onto the device's error scope stack, allowing you to capture errors of a particular type.

MDN Reference

Parameters​

ParameterType
filterGPUErrorFilter

Returns​

void


removeEventListener()​

Call Signature​

removeEventListener<K>(
type,
listener,
options?
): void;

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

MDN Reference

Type Parameters​
Type Parameter
K extends "uncapturederror"
Parameters​
ParameterType
typeK
listener(this, ev) => any
options?boolean | EventListenerOptions
Returns​

void

Overrides​

EventTarget.removeEventListener

Call Signature​

removeEventListener(
type,
listener,
options?
): void;

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

MDN Reference

Parameters​
ParameterType
typestring
listenerEventListenerOrEventListenerObject
options?boolean | EventListenerOptions
Returns​

void

Overrides​
EventTarget.removeEventListener

Properties​

adapterInfo​

readonly adapterInfo: GPUAdapterInfo;

The adapterInfo read-only property of the GPUDevice interface returns a GPUAdapterInfo object containing identifying information about the device's originating adapter.

MDN Reference


features​

readonly features: GPUSupportedFeatures;

The features read-only property of the GPUDevice interface returns a GPUSupportedFeatures object that describes additional functionality supported by the device. Only features requested during the creation of the device (i.e., when GPUAdapter.requestDevice() is called) are included.

MDN Reference


label​

label: string;

MDN Reference

Inherited from​

GPUObjectBase.label


limits​

readonly limits: GPUSupportedLimits;

The limits read-only property of the GPUDevice interface returns a GPUSupportedLimits object that describes the limits supported by the device. All limit values will be included, and the limits requested during the creation of the device (i.e., when GPUAdapter.requestDevice() is called) will be reflected in those values.

MDN Reference


lost​

readonly lost: Promise<GPUDeviceLostInfo>;

The lost read-only property of the GPUDevice interface contains a Promise that remains pending throughout the device's lifetime and resolves with a GPUDeviceLostInfo object when the device is lost.

MDN Reference


onuncapturederror​

onuncapturederror: ((this, ev) => any) | null;

MDN Reference


queue​

readonly queue: GPUQueue;

The queue read-only property of the GPUDevice interface returns the primary GPUQueue for the device.

MDN Reference