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

*** ** * ** ***


```
public final class GPUInstance implements AutoCloseable
```

<br />

*** ** * ** ***

A top-level object representing a WebGPU instance.

## Summary

| ### Public methods |
|---|---|
| `external void` | `https://developer.android.com/reference/androidx/webgpu/GPUInstance#close()()` Decrements the reference count of the object and frees resources when the count reaches zero. |
| `final external @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUSurface` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUInstance#createSurface(androidx.webgpu.GPUSurfaceDescriptor)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUSurfaceDescriptor descriptor)` Creates a new surface. |
| `boolean` | `https://developer.android.com/reference/androidx/webgpu/GPUInstance#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final long` | `https://developer.android.com/reference/androidx/webgpu/GPUInstance#getHandle()()` |
| `final external @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUSupportedWGSLLanguageFeatures` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUInstance#getWGSLLanguageFeatures()()` Retrieves the list of WGSL language features supported by the instance. |
| `final external boolean` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUInstance#hasWGSLLanguageFeature(kotlin.Int)(int feature)` Checks if a specific WGSL language feature is supported. |
| `int` | `https://developer.android.com/reference/androidx/webgpu/GPUInstance#hashCode()()` |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUInstance#processEvents()()` Processes pending asynchronous events and invokes their callbacks. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUAdapter` | `https://developer.android.com/reference/androidx/webgpu/GPUInstance#requestAdapter(androidx.webgpu.GPURequestAdapterOptions)(https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions options)` Asynchronously requests a graphics adapter. |
| `final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/webgpu/GPUInstance#requestAdapter(java.util.concurrent.Executor,androidx.webgpu.GPURequestAdapterOptions,androidx.webgpu.GPURequestCallback)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions options, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPURequestCallback<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/webgpu/GPUAdapter> callback )` Asynchronously requests a graphics adapter. |

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

### createSurface

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

```
@FastNative
public final external @NonNull GPUSurface createSurface(@NonNull GPUSurfaceDescriptor descriptor)
```

Creates a new surface.

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

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

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

### getWGSLLanguageFeatures

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

```
@FastNative
public final external @NonNull GPUSupportedWGSLLanguageFeatures getWGSLLanguageFeatures()
```

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
public final external boolean hasWGSLLanguageFeature(int feature)
```

Checks if a specific WGSL language feature is supported.

| Parameters |
|---|---|
| `int feature` | 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 |
|---|---|
| `boolean` | {@code true} if the feature is supported, {@code false} otherwise. |

### hashCode

```
public int hashCode()
```

### processEvents

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

```
@FastNative
public final external void processEvents()
```

Processes pending asynchronous events and invokes their callbacks.

### requestAdapter

```
public final @NonNull GPUAdapter requestAdapter(GPURequestAdapterOptions options)
```

Asynchronously requests a graphics adapter.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/webgpu/GPURequestAdapterOptions options` | 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
public final external void requestAdapter(
    @NonNull Executor callbackExecutor,
    GPURequestAdapterOptions options,
    @NonNull GPURequestCallback<@NonNull GPUAdapter> callback
)
```

Asynchronously requests a graphics adapter.