# WebGpuUtils

Added in 1.0.0-alpha06

*** ** * ** ***


```
public final class WebGpuUtils
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` | `https://developer.android.com/reference/androidx/webgpu/helper/WebGpuUtils#createWebGpu(android.view.Surface,androidx.webgpu.GPUInstanceDescriptor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPUDeviceDescriptor)( https://developer.android.com/reference/android/view/Surface.html surface, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUInstanceDescriptor instanceDescriptor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions requestAdapterOptions, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUDeviceDescriptor deviceDescriptor )` Creates a `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` environment using a newly created default single-threaded dispatcher. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` | `https://developer.android.com/reference/androidx/webgpu/helper/WebGpuUtils#createWebGpu(kotlinx.coroutines.CoroutineDispatcher,android.view.Surface,androidx.webgpu.GPUInstanceDescriptor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPUDeviceDescriptor)( @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html dispatcher, https://developer.android.com/reference/android/view/Surface.html surface, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUInstanceDescriptor instanceDescriptor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions requestAdapterOptions, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUDeviceDescriptor deviceDescriptor )` Creates a `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` environment using the provided `https://developer.android.com/reference/androidx/webgpu/helper/package-summary#createWebGpu(kotlinx.coroutines.CoroutineDispatcher,android.view.Surface,androidx.webgpu.GPUInstanceDescriptor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPUDeviceDescriptor)`. |
| `static final void` | `https://developer.android.com/reference/androidx/webgpu/helper/WebGpuUtils#initLibrary()()` Initializes the native library. |

## Public methods

### createWebGpu

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/helper/WebGpu.kt+function:createWebGpu)

```
public static final @NonNull WebGpu createWebGpu(
    Surface surface,
    @NonNull GPUInstanceDescriptor instanceDescriptor,
    @NonNull GPURequestAdapterOptions requestAdapterOptions,
    @NonNull GPUDeviceDescriptor deviceDescriptor
)
```

Creates a `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` environment using a newly created default single-threaded dispatcher.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/view/Surface.html surface` | An optional Android `https://developer.android.com/reference/android/view/Surface.html` to bind to WebGPU. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUInstanceDescriptor instanceDescriptor` | Options for configuring the native WebGPU instance. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions requestAdapterOptions` | Options for selecting the GPU adapter (e.g., backend type). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUDeviceDescriptor deviceDescriptor` | Options for requesting the GPU device. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` | A configured `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` instance. |

### createWebGpu

Artifact: [androidx.webgpu:webgpu](https://developer.android.com/jetpack/androidx/releases/webgpu) [View Source](https://cs.android.com/search?q=file:androidx/webgpu/helper/WebGpu.kt+function:createWebGpu)

```
public static final @NonNull WebGpu createWebGpu(
    @NonNull CoroutineDispatcher dispatcher,
    Surface surface,
    @NonNull GPUInstanceDescriptor instanceDescriptor,
    @NonNull GPURequestAdapterOptions requestAdapterOptions,
    @NonNull GPUDeviceDescriptor deviceDescriptor
)
```

Creates a `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` environment using the provided `https://developer.android.com/reference/androidx/webgpu/helper/package-summary#createWebGpu(kotlinx.coroutines.CoroutineDispatcher,android.view.Surface,androidx.webgpu.GPUInstanceDescriptor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPUDeviceDescriptor)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html dispatcher` | A custom `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to use for executing WebGPU JNI operations. Must be single-threaded. |
| `https://developer.android.com/reference/android/view/Surface.html surface` | An optional Android `https://developer.android.com/reference/android/view/Surface.html` to bind to WebGPU. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUInstanceDescriptor instanceDescriptor` | Options for configuring the native WebGPU instance. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions requestAdapterOptions` | Options for selecting the GPU adapter (e.g., backend type). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUDeviceDescriptor deviceDescriptor` | Options for requesting the GPU device. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` | A configured `https://developer.android.com/reference/androidx/webgpu/helper/WebGpu` instance. |

### initLibrary

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

```
public static final void initLibrary()
```

Initializes the native library. This method should be called before making and WebGPU calls.