> Documentation index: https://developer.android.com/reference/llms.txt

# WebGPU

Artifact: [androidx.webkit:webkit](https://developer.android.com/jetpack/androidx/releases/webkit.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/webkit/WebGPU.java+class:androidx.webkit.WebGPU) Added in [1.19.0-alpha03](https://developer.android.com/jetpack/androidx/releases/webkit.md.txt#1.19.0-alpha03)

*** ** * ** ***


```
class WebGPU
```

<br />

*** ** * ** ***

Provides access to the [Dawn](https://dawn.googlesource.com/dawn) implementation of [WebGPU](https://www.w3.org/TR/webgpu/) packaged in Android System WebView.

Most apps should use the `androidx.webgpu` library instead of calling this class directly.

## Summary

| ### Constants |
|---|---|
| `const Long` | `ERROR_APP_TOO_OLD = -1` Returned by `getWGPUProcGetProcAddress` when WebView no longer supports the requested Dawn major version. |
| `const Long` | `ERROR_WEBVIEW_TOO_OLD = 0` Returned by `getWGPUProcGetProcAddress` when WebView does not expose WebGPU or its Dawn version is older than requested. |

| ### Public functions |
|---|---|
| `java-static Long` | `@AnyThread getWGPUProcGetProcAddress( majorVersion: @IntRange(from = 0, to = 16777215) Int, minorVersion: @IntRange(from = 0, to = 1099511627775) Long )` Returns the native `WGPUProcGetProcAddress` function pointer (see [webgpu.h](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)) from WebView when it supports the requested Dawn version. |

## Constants

### ERROR_APP_TOO_OLD

Added in [1.19.0-alpha03](https://developer.android.com/jetpack/androidx/releases/webkit.md.txt#1.19.0-alpha03)

```
const val ERROR_APP_TOO_OLD = -1: Long
```

Returned by `getWGPUProcGetProcAddress` when WebView no longer supports the requested Dawn major version.

### ERROR_WEBVIEW_TOO_OLD

Added in [1.19.0-alpha03](https://developer.android.com/jetpack/androidx/releases/webkit.md.txt#1.19.0-alpha03)

```
const val ERROR_WEBVIEW_TOO_OLD = 0: Long
```

Returned by `getWGPUProcGetProcAddress` when WebView does not expose WebGPU or its Dawn version is older than requested.

## Public functions

### getWGPUProcGetProcAddress

Added in [1.19.0-alpha03](https://developer.android.com/jetpack/androidx/releases/webkit.md.txt#1.19.0-alpha03)

```
@AnyThread
java-static fun getWGPUProcGetProcAddress(
    majorVersion: @IntRange(from = 0, to = 16777215) Int,
    minorVersion: @IntRange(from = 0, to = 1099511627775) Long
): Long
```

Returns the native `WGPUProcGetProcAddress` function pointer (see [webgpu.h](https://github.com/webgpu-native/webgpu-headers/blob/main/webgpu.h)) from WebView when it supports the requested Dawn version.

Native C/C++ code casts a positive return value to `WGPUProcGetProcAddress` to look up WebGPU functions. The returned pointer is valid for the lifetime of the process. Values `<= 0` are error codes and must not be cast to a pointer.

Dawn uses a 24-bit unsigned major version (fits in `int`) and a 40-bit unsigned minor version (needs `long`).

| Parameters |
|---|---|
| `majorVersion: @IntRange(from = 0, to = 16777215) Int` | exact Dawn major version required (`0` to `2^24 - 1`). |
| `minorVersion: @IntRange(from = 0, to = 1099511627775) Long` | minimum Dawn minor version required (`0` to `2^40 - 1`). |

| Returns |
|---|---|
| `Long` | a positive function pointer address if compatible, `ERROR_WEBVIEW_TOO_OLD`, or `ERROR_APP_TOO_OLD`. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if `majorVersion` or `minorVersion` is out of range. |