W3cubDocs

/Web APIs

GPUQueue

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The GPUQueue interface of the WebGPU API controls execution of encoded commands on the GPU.

A device's primary queue is accessed via the GPUDevice.queue property.

Instance properties

label Experimental

A string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.

Instance methods

copyExternalImageToTexture() Experimental

Copies a snapshot taken from a source image, video, or canvas into a given GPUTexture.

onSubmittedWorkDone() Experimental

Returns a Promise that resolves when all the work submitted to the GPU via this GPUQueue at the point the method is called has been processed.

submit() Experimental

Schedules the execution of command buffers represented by one or more GPUCommandBuffer objects by the GPU.

writeBuffer() Experimental

Writes a provided data source into a given GPUBuffer.

writeTexture() Experimental

Writes a provided data source into a given GPUTexture.

Examples

In our basic render demo, we define some vertex data in a Float32Array that we'll use to draw a triangle:

js

const vertices = new Float32Array([
  0.0, 0.6, 0, 1, 1, 0, 0, 1, -0.5, -0.6, 0, 1, 0, 1, 0, 1, 0.5, -0.6, 0, 1, 0,
  0, 1, 1,
]);

To use this data in a render pipeline, we need to put it into a GPUBuffer. First we'll create the buffer:

js

const vertexBuffer = device.createBuffer({
  size: vertices.byteLength, // make it big enough to store vertices in
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
});

To get the data into the buffer we can use the writeBuffer() function, which lets the user agent determine most efficient way to copy the data over:

js

device.queue.writeBuffer(vertexBuffer, 0, vertices, 0, vertices.length);

Later on, a set of commands is encoded into a GPUCommandBuffer using the GPUCommandEncoder.finish() method. The command buffer is then passed into the queue via a submit() call, ready to be processed by the GPU.

js

device.queue.submit([commandEncoder.finish()]);

Note: Study the WebGPU samples to find more queue examples.

Specifications

Specification
WebGPU
# gpu-queue

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
GPUQueue
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
copyExternalImageToTexture
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
label
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
onSubmittedWorkDone
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
No No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
submit
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
writeBuffer
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No
writeTexture
113Currently supported on ChromeOS, macOS, and Windows only.
113Currently supported on ChromeOS, macOS, and Windows only.
previewCurrently supported on Linux and Windows only.
No
99Currently supported on ChromeOS, macOS, and Windows only.
No No No No No No No

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPUQueue