# GPUCommandEncoder

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/GPUCommandEncoder.kt+class:androidx.webgpu.GPUCommandEncoder) Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

*** ** * ** ***


```
class GPUCommandEncoder : AutoCloseable
```

<br />

*** ** * ** ***

An object used to record GPU commands.

## Summary

| ### Public functions |
|---|---|
| `external https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassEncoder` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#beginComputePass(androidx.webgpu.GPUComputePassDescriptor)(descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassDescriptor?)` Begins recording a compute pass. |
| `external https://developer.android.com/reference/kotlin/androidx/webgpu/GPURenderPassEncoder` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#beginRenderPass(androidx.webgpu.GPURenderPassDescriptor)(descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURenderPassDescriptor)` Begins recording a render pass. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#clearBuffer(androidx.webgpu.GPUBuffer,kotlin.Long,kotlin.Long)(buffer: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Fills a buffer with zeros. |
| `open external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#close()()` Decrements the reference count of the object and frees resources when the count reaches zero. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#copyBufferToBuffer(androidx.webgpu.GPUBuffer,kotlin.Long,androidx.webgpu.GPUBuffer,kotlin.Long,kotlin.Long)( source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer, sourceOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer, destinationOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Copies data from one buffer to another. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#copyBufferToTexture(androidx.webgpu.GPUTexelCopyBufferInfo,androidx.webgpu.GPUTexelCopyTextureInfo,androidx.webgpu.GPUExtent3D)( source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyBufferInfo, destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo, copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D )` Copies data from a buffer to a texture. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#copyTextureToBuffer(androidx.webgpu.GPUTexelCopyTextureInfo,androidx.webgpu.GPUTexelCopyBufferInfo,androidx.webgpu.GPUExtent3D)( source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo, destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyBufferInfo, copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D )` Copies data from a texture to a buffer. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#copyTextureToTexture(androidx.webgpu.GPUTexelCopyTextureInfo,androidx.webgpu.GPUTexelCopyTextureInfo,androidx.webgpu.GPUExtent3D)( source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo, destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo, copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D )` Copies data from one texture to another. |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `external https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandBuffer` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#finish(androidx.webgpu.GPUCommandBufferDescriptor)(descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandBufferDescriptor?)` Finishes recording commands and creates a command buffer. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#hashCode()()` |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#insertDebugMarker(kotlin.String)(markerLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Inserts a debug marker into the command stream. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#popDebugGroup()()` Pops the current debug group. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#pushDebugGroup(kotlin.String)(groupLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Pushes a new debug group. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#resolveQuerySet(androidx.webgpu.GPUQuerySet,kotlin.Int,kotlin.Int,androidx.webgpu.GPUBuffer,kotlin.Long)( querySet: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUQuerySet, firstQuery: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, queryCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer, destinationOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Resolves the results of a query set into a buffer. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#setLabel(kotlin.String)(label: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets a human-readable label for debugging. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#writeTimestamp(androidx.webgpu.GPUQuerySet,kotlin.Int)(querySet: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUQuerySet, queryIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Writes a timestamp value into a query set. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandEncoder#handle()` |

## Public functions

### beginComputePass

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun beginComputePass(descriptor: GPUComputePassDescriptor? = null): GPUComputePassEncoder
```

Begins recording a compute pass.

| Parameters |
|---|---|
| `descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassDescriptor? = null` | The descriptor for the compute pass. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassEncoder` | A compute pass encoder. |

### beginRenderPass

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder
```

Begins recording a render pass.

| Parameters |
|---|---|
| `descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURenderPassDescriptor` | The descriptor for the render pass. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPURenderPassEncoder` | A render pass encoder. |

### clearBuffer

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun clearBuffer(
    buffer: GPUBuffer,
    offset: Long = 0,
    size: Long = Constants.WHOLE_SIZE
): Unit
```

Fills a buffer with zeros.

| Parameters |
|---|---|
| `buffer: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer` | The buffer to clear. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = 0` | The offset in the buffer. |
| `size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html = Constants.WHOLE_SIZE` | The number of bytes to clear. |

### close

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
open external fun close(): Unit
```

Decrements the reference count of the object and frees resources when the count reaches zero.

This is the standard way to manage object lifetimes and should be used in `use` blocks. After calling this, the object is no longer usable.

### copyBufferToBuffer

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun copyBufferToBuffer(
    source: GPUBuffer,
    sourceOffset: Long,
    destination: GPUBuffer,
    destinationOffset: Long,
    size: Long
): Unit
```

Copies data from one buffer to another.

| Parameters |
|---|---|
| `source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer` | The source buffer. |
| `sourceOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset in the source buffer. |
| `destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer` | The destination buffer. |
| `destinationOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset in the destination buffer. |
| `size: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The number of bytes to copy. |

### copyBufferToTexture

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun copyBufferToTexture(
    source: GPUTexelCopyBufferInfo,
    destination: GPUTexelCopyTextureInfo,
    copySize: GPUExtent3D
): Unit
```

Copies data from a buffer to a texture.

| Parameters |
|---|---|
| `source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyBufferInfo` | The source buffer information. |
| `destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo` | The destination texture information. |
| `copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D` | The size of the region to copy. |

### copyTextureToBuffer

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun copyTextureToBuffer(
    source: GPUTexelCopyTextureInfo,
    destination: GPUTexelCopyBufferInfo,
    copySize: GPUExtent3D
): Unit
```

Copies data from a texture to a buffer.

| Parameters |
|---|---|
| `source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo` | The source texture information. |
| `destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyBufferInfo` | The destination buffer information. |
| `copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D` | The size of the region to copy. |

### copyTextureToTexture

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun copyTextureToTexture(
    source: GPUTexelCopyTextureInfo,
    destination: GPUTexelCopyTextureInfo,
    copySize: GPUExtent3D
): Unit
```

Copies data from one texture to another.

| Parameters |
|---|---|
| `source: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo` | The source texture information. |
| `destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUTexelCopyTextureInfo` | The destination texture information. |
| `copySize: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUExtent3D` | The size of the region to copy. |

### equals

```
open operator fun equals(other: Any?): Boolean
```

### finish

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun finish(descriptor: GPUCommandBufferDescriptor? = null): GPUCommandBuffer
```

Finishes recording commands and creates a command buffer.

| Parameters |
|---|---|
| `descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandBufferDescriptor? = null` | The descriptor for the command buffer. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUCommandBuffer` | The created command buffer. |

### hashCode

```
open fun hashCode(): Int
```

### insertDebugMarker

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun insertDebugMarker(markerLabel: String): Unit
```

Inserts a debug marker into the command stream.

| Parameters |
|---|---|
| `markerLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The label for the debug marker. |

### popDebugGroup

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun popDebugGroup(): Unit
```

Pops the current debug group.

### pushDebugGroup

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun pushDebugGroup(groupLabel: String): Unit
```

Pushes a new debug group.

| Parameters |
|---|---|
| `groupLabel: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The label for the debug group. |

### resolveQuerySet

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun resolveQuerySet(
    querySet: GPUQuerySet,
    firstQuery: Int,
    queryCount: Int,
    destination: GPUBuffer,
    destinationOffset: Long
): Unit
```

Resolves the results of a query set into a buffer.

| Parameters |
|---|---|
| `querySet: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUQuerySet` | The query set to resolve. |
| `firstQuery: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the first query to resolve. |
| `queryCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of queries to resolve. |
| `destination: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer` | The destination buffer. |
| `destinationOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset in the destination buffer. |

### setLabel

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun setLabel(label: String): Unit
```

Sets a human-readable label for debugging.

| Parameters |
|---|---|
| `label: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The label string. |

### writeTimestamp

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
@FastNative
external fun writeTimestamp(querySet: GPUQuerySet, queryIndex: Int): Unit
```

Writes a timestamp value into a query set.

| Parameters |
|---|---|
| `querySet: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUQuerySet` | The query set to write to. |
| `queryIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index in the query set. |

## Public properties

### handle

Added in [1.0.0-alpha06](https://developer.android.com/jetpack/androidx/releases/webgpu#1.0.0-alpha06)

```
val handle: Long
```