The end() method of the GPUComputePassEncoder interface completes recording of the current compute pass command sequence. 
 
The following criteria must be met when calling end(), otherwise a GPUValidationError is generated and the GPUComputePassEncoder becomes invalid:
 
 
In our basic compute demo, several commands are recorded via a GPUCommandEncoder. Most of these commands originate from the GPUComputePassEncoder created via GPUCommandEncoder.beginComputePass().
 
const BUFFER_SIZE = 1000;
const commandEncoder = device.createCommandEncoder();
const passEncoder = commandEncoder.beginComputePass();
passEncoder.setPipeline(computePipeline);
passEncoder.setBindGroup(0, bindGroup);
passEncoder.dispatchWorkgroups(Math.ceil(BUFFER_SIZE / 64));
passEncoder.end();
commandEncoder.copyBufferToBuffer(
  output,
  0, 
  stagingBuffer,
  0, 
  BUFFER_SIZE,
);
device.queue.submit([commandEncoder.finish()]);