GPUCommandEncoder: finish() method
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The finish()
method of the
GPUCommandEncoder
interface completes recording of the command sequence encoded on this GPUCommandEncoder
, returning a corresponding GPUCommandBuffer
.
Syntax
js
finish()
finish(descriptor)
Parameters
descriptor
Optional-
An object that can contain the following properties:
label
Optional-
A string providing a label for the returned
GPUCommandBuffer
that can be used to identify it, for example inGPUError
messages or console warnings.
Return value
A GPUCommandBuffer
object instance.
Validation
The following criteria must be met when calling finish()
, otherwise a GPUValidationError
is generated and the GPUCommandEncoder
becomes invalid:
- There are no active debug groups (i.e. started via
pushDebugGroup()
). - The
GPUCommandEncoder
is in an open state — this means that:- There are no child
GPUComputePassEncoder
orGPURenderPassEncoder
s active that have not beenend()
ed. - The
GPUCommandEncoder
has not already hadfinish()
called on it (in which case it cannot be used to encode any more commands).
- There are no child
Examples
js
// ...
const commandBuffer = commandEncoder.finish();
device.queue.submit([commandBuffer]);
// ...
Specifications
Specification |
---|
WebGPU # dom-gpucommandencoder-finish |
Browser compatibility
BCD tables only load in the browser
See also
- The WebGPU API