home/ atoms/ webgpu-command-encoder-submit

WebGPU commands are recorded into a command buffer and submitted to a queue — the GPU does nothing until submit() is called

WebGPU follows a record-then-submit model. Create a GPUCommandEncoder, call methods to record commands (begin render pass, draw, end pass), then call encoder.finish() to produce an opaque GPUCommandBuffer, and submit it via device.queue.submit([commandBuffer]). Nothing runs on the GPU until submit() is called. A command buffer cannot be reused after submission — each frame requires building a new one. For most purposes the two steps are collapsed: device.queue.submit([encoder.finish()]).

Examples

const encoder = device.createCommandEncoder();
const pass = encoder.beginRenderPass({ colorAttachments: [...] });
pass.end();
device.queue.submit([encoder.finish()]);

Assessment

True or false: calling beginRenderPass() immediately makes the GPU start rendering. Explain the actual execution model and when GPU work begins.

“simply making these calls does not cause the GPU to actually do anything. They're just recording commands for the GPU to do later.”
corpus · your-first-webgpu-app-google-codelab · chunk 2