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

*** ** * ** ***


```
public final class GPUComputePassEncoder implements AutoCloseable
```

<br />

*** ** * ** ***

An object used to record commands for a compute pass.

## Summary

| ### Public methods |
|---|---|
| `external void` | `https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#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/GPUComputePassEncoder#dispatchWorkgroups(kotlin.Int,kotlin.Int,kotlin.Int)( int workgroupCountX, int workgroupCountY, int workgroupCountZ )` Dispatches a compute shader. |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#dispatchWorkgroupsIndirect(androidx.webgpu.GPUBuffer,kotlin.Long)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer indirectBuffer, long indirectOffset )` Dispatches a compute shader with parameters from a buffer. |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#end()()` Ends the compute pass. |
| `boolean` | `https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final long` | `https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#getHandle()()` |
| `int` | `https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#hashCode()()` |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#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/GPUComputePassEncoder#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/GPUComputePassEncoder#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/GPUComputePassEncoder#setBindGroup(kotlin.Int,androidx.webgpu.GPUBindGroup,kotlin.IntArray)( int groupIndex, https://developer.android.com/reference/androidx/webgpu/GPUBindGroup group, @https://developer.android.com/reference/androidx/annotation/NonNull int[] dynamicOffsets )` Sets a bind group for the pipeline. |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#setImmediates(kotlin.Int,java.nio.ByteBuffer)(int offset, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/nio/ByteBuffer.html data)` |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUComputePassEncoder#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/GPUComputePassEncoder#setPipeline(androidx.webgpu.GPUComputePipeline)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUComputePipeline pipeline)` Sets the current compute pipeline. |

## Public methods

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

### dispatchWorkgroups

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

```
@FastNative
public final external void dispatchWorkgroups(
    int workgroupCountX,
    int workgroupCountY,
    int workgroupCountZ
)
```

Dispatches a compute shader.

| Parameters |
|---|---|
| `int workgroupCountX` | The number of workgroups in the X dimension. |
| `int workgroupCountY` | The number of workgroups in the Y dimension. |
| `int workgroupCountZ` | 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
public final external void dispatchWorkgroupsIndirect(
    @NonNull GPUBuffer indirectBuffer,
    long indirectOffset
)
```

Dispatches a compute shader with parameters from a buffer.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUBuffer indirectBuffer` | The buffer containing the dispatch parameters. |
| `long indirectOffset` | 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
public final external void end()
```

Ends the compute pass.

### equals

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

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

### setBindGroup

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

```
@FastNative
public final external void setBindGroup(
    int groupIndex,
    GPUBindGroup group,
    @NonNull int[] dynamicOffsets
)
```

Sets a bind group for the pipeline.

| Parameters |
|---|---|
| `int groupIndex` | The index of the bind group. |
| `https://developer.android.com/reference/androidx/webgpu/GPUBindGroup group` | The bind group to set. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull int[] dynamicOffsets` | 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
public final external void setImmediates(int offset, @NonNull ByteBuffer data)
```

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

### setPipeline

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

```
@FastNative
public final external void setPipeline(@NonNull GPUComputePipeline pipeline)
```

Sets the current compute pipeline.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUComputePipeline pipeline` | The compute pipeline to set. |