# 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)

*** ** * ** ***


```
public final class GPUCommandEncoder implements AutoCloseable
```

<br />

*** ** * ** ***

An object used to record GPU commands.

## Summary

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

## Public methods

### beginComputePass

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

```
@FastNative
public final external @NonNull GPUComputePassEncoder beginComputePass(GPUComputePassDescriptor descriptor)
```

Begins recording a compute pass.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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
public final external @NonNull GPURenderPassEncoder beginRenderPass(@NonNull GPURenderPassDescriptor descriptor)
```

Begins recording a render pass.

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

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/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
public final external void clearBuffer(@NonNull GPUBuffer buffer, long offset, long size)
```

Fills a buffer with zeros.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer buffer` | The buffer to clear. |
| `long offset` | The offset in the buffer. |
| `long 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)

```
public external void close()
```

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
public final external void copyBufferToBuffer(
    @NonNull GPUBuffer source,
    long sourceOffset,
    @NonNull GPUBuffer destination,
    long destinationOffset,
    long size
)
```

Copies data from one buffer to another.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer source` | The source buffer. |
| `long sourceOffset` | The offset in the source buffer. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer destination` | The destination buffer. |
| `long destinationOffset` | The offset in the destination buffer. |
| `long size` | 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
public final external void copyBufferToTexture(
    @NonNull GPUTexelCopyBufferInfo source,
    @NonNull GPUTexelCopyTextureInfo destination,
    @NonNull GPUExtent3D copySize
)
```

Copies data from a buffer to a texture.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTexelCopyBufferInfo source` | The source buffer information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTexelCopyTextureInfo destination` | The destination texture information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUExtent3D copySize` | 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
public final external void copyTextureToBuffer(
    @NonNull GPUTexelCopyTextureInfo source,
    @NonNull GPUTexelCopyBufferInfo destination,
    @NonNull GPUExtent3D copySize
)
```

Copies data from a texture to a buffer.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTexelCopyTextureInfo source` | The source texture information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUTexelCopyBufferInfo destination` | The destination buffer information. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUExtent3D copySize` | 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
public final external void copyTextureToTexture(
    @NonNull GPUTexelCopyTextureInfo source,
    @NonNull GPUTexelCopyTextureInfo destination,
    @NonNull GPUExtent3D copySize
)
```

Copies data from one texture to another.

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

### equals

```
public boolean equals(Object other)
```

### finish

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

```
@FastNative
public final external @NonNull GPUCommandBuffer finish(GPUCommandBufferDescriptor descriptor)
```

Finishes recording commands and creates a command buffer.

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

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

### getHandle

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

```
public final long getHandle()
```

### hashCode

```
public int hashCode()
```

### insertDebugMarker

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

```
@FastNative
public final external void insertDebugMarker(@NonNull String markerLabel)
```

Inserts a debug marker into the command stream.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html markerLabel` | 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
public final external void popDebugGroup()
```

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
public final external void pushDebugGroup(@NonNull String groupLabel)
```

Pushes a new debug group.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html groupLabel` | 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
public final external void resolveQuerySet(
    @NonNull GPUQuerySet querySet,
    int firstQuery,
    int queryCount,
    @NonNull GPUBuffer destination,
    long destinationOffset
)
```

Resolves the results of a query set into a buffer.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUQuerySet querySet` | The query set to resolve. |
| `int firstQuery` | The index of the first query to resolve. |
| `int queryCount` | The number of queries to resolve. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer destination` | The destination buffer. |
| `long destinationOffset` | 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
public final external void setLabel(@NonNull String label)
```

Sets a human-readable label for debugging.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html label` | The label string. |

### writeTimestamp

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

```
@FastNative
public final external void writeTimestamp(@NonNull GPUQuerySet querySet, int queryIndex)
```

Writes a timestamp value into a query set.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUQuerySet querySet` | The query set to write to. |
| `int queryIndex` | The index in the query set. |