Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. GPUQueue

GPUQueue

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is available inWeb Workers.

TheGPUQueue interface of theWebGPU API controls execution of encoded commands on the GPU.

A device's primary queue is accessed via theGPUDevice.queue property.

Instance properties

label

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

Instance methods

copyExternalImageToTexture()

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

onSubmittedWorkDone()

Returns aPromise that resolves when all the work submitted to the GPU via thisGPUQueue at the point the method is called has been processed.

submit()

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

writeBuffer()

Writes a provided data source into a givenGPUBuffer.

writeTexture()

Writes a provided data source into a givenGPUTexture.

Examples

In ourbasic render demo, we define some vertex data in aFloat32Array 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 aGPUBuffer. 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 thewriteBuffer() 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 aGPUCommandBuffer using theGPUCommandEncoder.finish() method. The command buffer is then passed into the queue via asubmit() call, ready to be processed by the GPU.

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

Note:Study theWebGPU samples to find more queue examples.

Specifications

Specification
WebGPU
# gpuqueue

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp