Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
Introduction
createBufferUsageMapModeWGPUBufferWGPUShaderModuleWGPUBindGroupLayoutWGPUBindGroupWGPUComputePipelineWGPUQuerySetWGPUComputePassEncoderWGPUCommandBufferWGPUCommandEncoderWGPUQueueWGPULimitsBufferDescriptorShaderModuleDescriptorComputePipelineDescriptorBufferBindingBindGroupEntryBindGroupDescriptorQuerySetDescriptorWGPUDeviceWGPUSupportedFeaturesWGPUAdapterWGPU
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. wgpu-native
  3. wgpu-native
  4. WGPUCommandEncoder

wgpu-native.WGPUCommandEncoder

export interface WGPUCommandEncoder {
  /**
   * Opaque native handle to this command encoder.
   */
  readonly handle: CommandEncoderHandle;

  /**
   * Begin a compute pass.
   *
   * Compute passes are used to dispatch compute shaders.
   *
   * @returns A compute pass encoder for recording dispatch commands
   */
  beginComputePass(): WGPUComputePassEncoder;

  /**
   * Copy data from one buffer to another.
   *
   * Source and destination must have COPY_SRC and COPY_DST usage flags respectively.
   *
   * @param source - Source buffer
   * @param sourceOffset - Byte offset in source
   * @param destination - Destination buffer
   * @param destinationOffset - Byte offset in destination
   * @param size - Number of bytes to copy
   */
  copyBufferToBuffer(
    source: WGPUBuffer,
    sourceOffset: number,
    destination: WGPUBuffer,
    destinationOffset: number,
    size: number
  ): void;

  /**
   * Resolve query set results into a buffer.
   *
   * Copies query results (timestamps, counts, etc.) from a query set to a buffer.
   *
   * @param querySet - Query set to read from
   * @param firstQuery - Index of first query to resolve
   * @param queryCount - Number of queries to resolve
   * @param destination - Destination buffer (must have QUERY_RESOLVE usage)
   * @param destinationOffset - Byte offset in destination
   */
  resolveQuerySet(
    querySet: WGPUQuerySet,
    firstQuery: number,
    queryCount: number,
    destination: WGPUBuffer,
    destinationOffset: number
  ): void;

  /**
   * Finish command recording and create a command buffer.
   *
   * After calling finish(), no more commands can be added to this encoder.
   *
   * @returns A command buffer ready for submission
   */
  finish(): WGPUCommandBuffer;
}
readonlyhandle(CommandEncoderHandle)
– Opaque native handle to this command encoder.
beginComputePass(() => WGPUComputePassEncoder)
– Begin a compute pass. Compute passes are used to dispatch compute shaders.
copyBufferToBuffer((source: WGPUBuffer, sourceOffset: number, destination: WGPUBuffer, destinationOffset: number, size: number) => void)
– Copy data from one buffer to another. Source and destination must have COPY_SRC and COPY_DST usage flags respectively.
resolveQuerySet((querySet: WGPUQuerySet, firstQuery: number, queryCount: number, destination: WGPUBuffer, destinationOffset: number) => void)
– Resolve query set results into a buffer. Copies query results (timestamps, counts, etc.) from a query set to a buffer.
finish(() => WGPUCommandBuffer)
– Finish command recording and create a command buffer. After calling finish(), no more commands can be added to this encoder.

Command encoder.

Records GPU commands (compute passes, buffer copies, etc.) for later submission. A new encoder must be created for each command buffer.

Previous
WGPUCommandBuffer
Next
WGPUComputePassEncoder