# GPUComputePassEncoder

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

*** ** * ** ***


```
class GPUComputePassEncoder : AutoCloseable
```

<br />

*** ** * ** ***

An object used to record commands for a compute pass.

## Summary

| ### Public functions |
|---|---|
| `open external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassEncoder#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/GPUComputePassEncoder#dispatchWorkgroups(kotlin.Int,kotlin.Int,kotlin.Int)( workgroupCountX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, workgroupCountY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, workgroupCountZ: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Dispatches a compute shader. |
| `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/GPUComputePassEncoder#dispatchWorkgroupsIndirect(androidx.webgpu.GPUBuffer,kotlin.Long)( indirectBuffer: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer, indirectOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Dispatches a compute shader with parameters from 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/GPUComputePassEncoder#end()()` Ends the compute pass. |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassEncoder#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePassEncoder#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/GPUComputePassEncoder#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/GPUComputePassEncoder#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/GPUComputePassEncoder#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/GPUComputePassEncoder#setBindGroup(kotlin.Int,androidx.webgpu.GPUBindGroup,kotlin.IntArray)( groupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, group: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBindGroup?, dynamicOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html )` Sets a bind group for the pipeline. |
| `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/GPUComputePassEncoder#setImmediates(kotlin.Int,java.nio.ByteBuffer)(offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, data: https://developer.android.com/reference/java/nio/ByteBuffer.html)` |
| `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/GPUComputePassEncoder#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/GPUComputePassEncoder#setPipeline(androidx.webgpu.GPUComputePipeline)(pipeline: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePipeline)` Sets the current compute pipeline. |

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

## Public functions

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

### dispatchWorkgroups

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

```
@FastNative
external fun dispatchWorkgroups(
    workgroupCountX: Int,
    workgroupCountY: Int = 1,
    workgroupCountZ: Int = 1
): Unit
```

Dispatches a compute shader.

| Parameters |
|---|---|
| `workgroupCountX: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of workgroups in the X dimension. |
| `workgroupCountY: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 1` | The number of workgroups in the Y dimension. |
| `workgroupCountZ: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 1` | The number of workgroups in the Z dimension. |

### dispatchWorkgroupsIndirect

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

```
@FastNative
external fun dispatchWorkgroupsIndirect(
    indirectBuffer: GPUBuffer,
    indirectOffset: Long
): Unit
```

Dispatches a compute shader with parameters from a buffer.

| Parameters |
|---|---|
| `indirectBuffer: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBuffer` | The buffer containing the dispatch parameters. |
| `indirectOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset in the indirect buffer. |

### end

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

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

Ends the compute pass.

### equals

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

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

### setBindGroup

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

```
@FastNative
external fun setBindGroup(
    groupIndex: Int,
    group: GPUBindGroup? = null,
    dynamicOffsets: IntArray = intArrayOf()
): Unit
```

Sets a bind group for the pipeline.

| Parameters |
|---|---|
| `groupIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the bind group. |
| `group: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUBindGroup? = null` | The bind group to set. |
| `dynamicOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html = intArrayOf()` | An array of dynamic offsets. |

### setImmediates

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

```
@FastNative
external fun setImmediates(offset: Int, data: ByteBuffer): Unit
```

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

### setPipeline

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

```
@FastNative
external fun setPipeline(pipeline: GPUComputePipeline): Unit
```

Sets the current compute pipeline.

| Parameters |
|---|---|
| `pipeline: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUComputePipeline` | The compute pipeline to 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
```