GPUComputePassEncoder: end() 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.
Theend() method of theGPUComputePassEncoder interface completes recording of the current compute pass command sequence.
In this article
Syntax
js
end()Parameters
None.
Return value
None (Undefined).
Validation
The following criteria must be met when callingend(), otherwise aGPUValidationError is generated and theGPUComputePassEncoder becomes invalid:
- The
GPUComputePassEncoderis open (i.e., not already ended via anend()call). - any
pushDebugGroup()calls made on this encoder have a correspondingpopDebugGroup()call beforeend()is called.
Examples
In ourbasic compute demo, several commands are recorded via aGPUCommandEncoder. Most of these commands originate from theGPUComputePassEncoder created viaGPUCommandEncoder.beginComputePass().
js
const BUFFER_SIZE = 1000;// …// Create GPUCommandEncoder to encode commands to issue to the GPUconst commandEncoder = device.createCommandEncoder();// Initiate render passconst passEncoder = commandEncoder.beginComputePass();// Issue commandspassEncoder.setPipeline(computePipeline);passEncoder.setBindGroup(0, bindGroup);passEncoder.dispatchWorkgroups(Math.ceil(BUFFER_SIZE / 64));// End the render passpassEncoder.end();// Copy output buffer to staging buffercommandEncoder.copyBufferToBuffer( output, 0, // Source offset stagingBuffer, 0, // Destination offset BUFFER_SIZE,);// End frame by passing array of command buffers to command queue for executiondevice.queue.submit([commandEncoder.finish()]);// …Specifications
| Specification |
|---|
| WebGPU> # dom-gpucomputepassencoder-end> |
Browser compatibility
See also
- TheWebGPU API