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. WGPUComputePassEncoder

wgpu-native.WGPUComputePassEncoder

export interface WGPUComputePassEncoder {
  /**
   * Opaque native handle to this compute pass encoder.
   */
  readonly handle: ComputePassEncoderHandle;

  /**
   * Set the compute pipeline to use for subsequent dispatches.
   *
   * @param pipeline - The compute pipeline to use
   */
  setPipeline(pipeline: WGPUComputePipeline): void;

  /**
   * Bind a bind group to a specified index.
   *
   * @param index - Bind group index
   * @param bindGroup - The bind group to bind (null to unbind)
   */
  setBindGroup(index: number, bindGroup: WGPUBindGroup | null): void;

  /**
   * Dispatch compute work in 3D grid.
   *
   * Each dimension defaults to 1 if not specified.
   *
   * @param x - Number of workgroups in X dimension
   * @param y - Number of workgroups in Y dimension (default: 1)
   * @param z - Number of workgroups in Z dimension (default: 1)
   */
  dispatchWorkgroups(x: number, y?: number, z?: number): void;

  /**
   * Write a timestamp to a query set.
   *
   * Useful for performance profiling of GPU work.
   *
   * @param querySet - Query set to write to
   * @param queryIndex - Index within the query set
   */
  writeTimestamp(querySet: WGPUQuerySet, queryIndex: number): void;

  /**
   * End the compute pass.
   *
   * No more commands can be recorded to this pass after calling end().
   */
  end(): void;
}
readonlyhandle(ComputePassEncoderHandle)
– Opaque native handle to this compute pass encoder.
setPipeline((pipeline: WGPUComputePipeline) => void)
– Set the compute pipeline to use for subsequent dispatches.
setBindGroup((index: number, bindGroup: WGPUBindGroup | null) => void)
– Bind a bind group to a specified index.
dispatchWorkgroups((x: number, y?: number, z?: number) => void)
– Dispatch compute work in 3D grid. Each dimension defaults to 1 if not specified.
writeTimestamp((querySet: WGPUQuerySet, queryIndex: number) => void)
– Write a timestamp to a query set. Useful for performance profiling of GPU work.
end(() => void)
– End the compute pass. No more commands can be recorded to this pass after calling end().

Compute pass encoder.

Encodes compute dispatch commands within a command encoder. Commands are recorded but not executed until the command buffer is submitted.

Previous
WGPUCommandEncoder
Next
WGPUComputePipeline