# GPUInstance

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

*** ** * ** ***


```
class GPUInstance : AutoCloseable
```

<br />

*** ** * ** ***

A top-level object representing a WebGPU instance.

## Summary

| ### Public functions |
|---|---|
| `open external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#close()()` Decrements the reference count of the object and frees resources when the count reaches zero. |
| `external https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSurface` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#createSurface(androidx.webgpu.GPUSurfaceDescriptor)(descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSurfaceDescriptor)` Creates a new surface. |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `external https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSupportedWGSLLanguageFeatures` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#getWGSLLanguageFeatures()()` Retrieves the list of WGSL language features supported by the instance. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#hasWGSLLanguageFeature(kotlin.Int)(feature: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Checks if a specific WGSL language feature is supported. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#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/GPUInstance#processEvents()()` Processes pending asynchronous events and invokes their callbacks. |
| `suspend https://developer.android.com/reference/kotlin/androidx/webgpu/GPUAdapter` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#requestAdapter(androidx.webgpu.GPURequestAdapterOptions)(options: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURequestAdapterOptions?)` Asynchronously requests a graphics adapter. |
| `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/GPUInstance#requestAdapter(java.util.concurrent.Executor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPURequestCallback)( callbackExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, options: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURequestAdapterOptions?, callback: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURequestCallback<https://developer.android.com/reference/kotlin/androidx/webgpu/GPUAdapter> )` Asynchronously requests a graphics adapter. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUInstance#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.

### createSurface

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

```
@FastNative
external fun createSurface(descriptor: GPUSurfaceDescriptor = GPUSurfaceDescriptor()): GPUSurface
```

Creates a new surface.

| Parameters |
|---|---|
| `descriptor: https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSurfaceDescriptor = GPUSurfaceDescriptor()` | The descriptor for the surface. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSurface` | The created surface. |

### equals

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

### getWGSLLanguageFeatures

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

```
@FastNative
external fun getWGSLLanguageFeatures(): GPUSupportedWGSLLanguageFeatures
```

Retrieves the list of WGSL language features supported by the instance.

### hasWGSLLanguageFeature

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

```
@FastNative
external fun hasWGSLLanguageFeature(feature: Int): Boolean
```

Checks if a specific WGSL language feature is supported.

| Parameters |
|---|---|
| `feature: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The feature to check for. Value is one of the following: - `1` - `2` - `3` - `4` - `5` - `6` - `7` - `8` - `9` - `10` - `11` - `12` - `13` - `14` <br /> |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | {@code true} if the feature is supported, {@code false} otherwise. |

### hashCode

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

### processEvents

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

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

Processes pending asynchronous events and invokes their callbacks.

### requestAdapter

```
suspend fun requestAdapter(options: GPURequestAdapterOptions? = null): GPUAdapter
```

Asynchronously requests a graphics adapter.

| Parameters |
|---|---|
| `options: https://developer.android.com/reference/kotlin/androidx/webgpu/GPURequestAdapterOptions? = null` | The options for the adapter request. |

### requestAdapter

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

```
@FastNative
external fun requestAdapter(
    callbackExecutor: Executor,
    options: GPURequestAdapterOptions? = null,
    callback: GPURequestCallback<GPUAdapter>
): Unit
```

Asynchronously requests a graphics adapter.

## Public properties

### handle

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

```
val handle: Long
```