The submit()
method of the GPUQueue
interface schedules the execution of command buffers represented by one or more GPUCommandBuffer
objects by the GPU.
The following criteria must be met when calling submit()
, otherwise a GPUValidationError
is generated and the GPUQueue
becomes invalid:
In our basic render demo, a number of commands are recorded via a GPUCommandEncoder
:
const commandEncoder = device.createCommandEncoder();
const renderPassDescriptor = {
colorAttachments: [
{
clearValue: clearColor,
loadOp: "clear",
storeOp: "store",
view: context.getCurrentTexture().createView(),
},
],
};
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setPipeline(renderPipeline);
passEncoder.setVertexBuffer(0, vertexBuffer);
passEncoder.draw(3);
passEncoder.end();
The commands encoded by the GPUCommandEncoder
are recoded 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.
device.queue.submit([commandEncoder.finish()]);