Skip to main content

GPUCommandEncoder

The GPUCommandEncoder interface of the WebGPU API represents an encoder that collects a sequence of GPU commands to be issued to the GPU. Available only in secure contexts.

MDN Reference

Extends

Methods

beginComputePass()

beginComputePass(descriptor?): GPUComputePassEncoder;

The beginComputePass() method of the GPUCommandEncoder interface starts encoding a compute pass, returning a GPUComputePassEncoder that can be used to control computation.

MDN Reference

Parameters

ParameterType
descriptor?GPUComputePassDescriptor

Returns

GPUComputePassEncoder


beginRenderPass()

beginRenderPass(descriptor): GPURenderPassEncoder;

The beginRenderPass() method of the GPUCommandEncoder interface starts encoding a render pass, returning a GPURenderPassEncoder that can be used to control rendering.

MDN Reference

Parameters

ParameterType
descriptorGPURenderPassDescriptor

Returns

GPURenderPassEncoder


clearBuffer()

clearBuffer(
buffer,
offset?,
size?
): void;

The clearBuffer() method of the GPUCommandEncoder interface encodes a command that fills a region of a GPUBuffer with zeroes.

MDN Reference

Parameters

ParameterType
bufferGPUBuffer
offset?number
size?number

Returns

void


copyBufferToBuffer()

Call Signature

copyBufferToBuffer(
source,
destination,
size?
): void;

The copyBufferToBuffer() method of the GPUCommandEncoder interface encodes a command that copies data from one GPUBuffer to another.

MDN Reference

Parameters
ParameterType
sourceGPUBuffer
destinationGPUBuffer
size?number
Returns

void

Call Signature

copyBufferToBuffer(
source,
sourceOffset,
destination,
destinationOffset,
size?
): void;
Parameters
ParameterType
sourceGPUBuffer
sourceOffsetnumber
destinationGPUBuffer
destinationOffsetnumber
size?number
Returns

void


copyBufferToTexture()

Call Signature

copyBufferToTexture(
source,
destination,
copySize
): void;

The copyBufferToTexture() method of the GPUCommandEncoder interface encodes a command that copies data from a GPUBuffer to a GPUTexture.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyBufferInfo
destinationGPUTexelCopyTextureInfo
copySizeGPUExtent3D
Returns

void

Call Signature

copyBufferToTexture(
source,
destination,
copySize
): void;

The copyBufferToTexture() method of the GPUCommandEncoder interface encodes a command that copies data from a GPUBuffer to a GPUTexture.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyBufferInfo
destinationGPUTexelCopyTextureInfo
copySizeIterable<number>
Returns

void


copyTextureToBuffer()

Call Signature

copyTextureToBuffer(
source,
destination,
copySize
): void;

The copyTextureToBuffer() method of the GPUCommandEncoder interface encodes a command that copies data from a GPUTexture to a GPUBuffer.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyTextureInfo
destinationGPUTexelCopyBufferInfo
copySizeGPUExtent3D
Returns

void

Call Signature

copyTextureToBuffer(
source,
destination,
copySize
): void;

The copyTextureToBuffer() method of the GPUCommandEncoder interface encodes a command that copies data from a GPUTexture to a GPUBuffer.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyTextureInfo
destinationGPUTexelCopyBufferInfo
copySizeIterable<number>
Returns

void


copyTextureToTexture()

Call Signature

copyTextureToTexture(
source,
destination,
copySize
): void;

The copyTextureToTexture() method of the GPUCommandEncoder interface encodes a command that copies data from one GPUTexture to another.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyTextureInfo
destinationGPUTexelCopyTextureInfo
copySizeGPUExtent3D
Returns

void

Call Signature

copyTextureToTexture(
source,
destination,
copySize
): void;

The copyTextureToTexture() method of the GPUCommandEncoder interface encodes a command that copies data from one GPUTexture to another.

MDN Reference

Parameters
ParameterType
sourceGPUTexelCopyTextureInfo
destinationGPUTexelCopyTextureInfo
copySizeIterable<number>
Returns

void


finish()

finish(descriptor?): GPUCommandBuffer;

The finish() method of the GPUCommandEncoder interface completes recording of the command sequence encoded on this GPUCommandEncoder, returning a corresponding GPUCommandBuffer.

MDN Reference

Parameters

ParameterType
descriptor?GPUCommandBufferDescriptor

Returns

GPUCommandBuffer


insertDebugMarker()

insertDebugMarker(markerLabel): void;

MDN Reference

Parameters

ParameterType
markerLabelstring

Returns

void

Inherited from

GPUDebugCommandsMixin.insertDebugMarker


popDebugGroup()

popDebugGroup(): void;

MDN Reference

Returns

void

Inherited from

GPUDebugCommandsMixin.popDebugGroup


pushDebugGroup()

pushDebugGroup(groupLabel): void;

MDN Reference

Parameters

ParameterType
groupLabelstring

Returns

void

Inherited from

GPUDebugCommandsMixin.pushDebugGroup


resolveQuerySet()

resolveQuerySet(
querySet,
firstQuery,
queryCount,
destination,
destinationOffset
): void;

The resolveQuerySet() method of the GPUCommandEncoder interface encodes a command that resolves a GPUQuerySet, copying the results into a specified GPUBuffer.

MDN Reference

Parameters

ParameterType
querySetGPUQuerySet
firstQuerynumber
queryCountnumber
destinationGPUBuffer
destinationOffsetnumber

Returns

void

Properties

label

label: string;

MDN Reference

Inherited from

GPUObjectBase.label