GPUQueue: submit() method
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.
Thesubmit() method of theGPUQueue interface schedules the execution of command buffers represented by one or moreGPUCommandBuffer objects by the GPU.
In this article
Syntax
submit(commandBuffers)Parameters
commandBuffersAn array of
GPUCommandBufferobjects containing the commands to be enqueued for processing by the GPU. The array must not contain duplicateGPUCommandBufferobjects — each one can only be submitted once persubmit()call.
Return value
None (Undefined).
Validation
The following criteria must be met when callingsubmit(), otherwise aGPUValidationError is generated and theGPUQueue becomes invalid:
- The array of
GPUCommandBufferobjects referenced in thesubmit()call does not contain duplicates. - Any
GPUBuffer,GPUTexture, andGPUQuerySetobjects used in the encoded commands are available for use, i.e., not unavailable (GPUBuffers are unavailable if they are currentlymapped) or destroyed (with thedestroy()method). - Any
GPUExternalTextureobjects used in the encoded commands are not expired (they expire automatically shortly after being imported viaimportExternalTexture()). - If a
GPUQuerySetobject used in an encoded command is of type"occlusion"query, it is not already used, except byGPURenderPassEncoder.beginOcclusionQuery().
Examples
In ourbasic render demo, a number of commands are recorded via aGPUCommandEncoder:
// …// Create GPUCommandEncoderconst commandEncoder = device.createCommandEncoder();// Create GPURenderPassDescriptor to tell WebGPU which texture to draw into, then initiate render passconst renderPassDescriptor = { colorAttachments: [ { clearValue: clearColor, loadOp: "clear", storeOp: "store", view: context.getCurrentTexture().createView(), }, ],};const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);// Draw a trianglepassEncoder.setPipeline(renderPipeline);passEncoder.setVertexBuffer(0, vertexBuffer);passEncoder.draw(3);// End the render passpassEncoder.end();// …The commands encoded by theGPUCommandEncoder are recoded 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.
device.queue.submit([commandEncoder.finish()]);Note:Study theWebGPU samples to find more queue examples.
Specifications
| Specification |
|---|
| WebGPU> # dom-gpuqueue-submit> |
Browser compatibility
See also
- TheWebGPU API