# GPUHardwareBufferWrapper

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

*** ** * ** ***


```
@ExperimentalWebGpuApi
public abstract class GPUHardwareBufferWrapper implements AutoCloseable
```

<br />

Known direct subclasses [GPUHardwareBufferExternalTexture](https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferExternalTexture), [GPUHardwareBufferTexture](https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferTexture)

|---|---|
| `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferExternalTexture` |   |
| `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferTexture` |   |

*** ** * ** ***

Base abstract wrapper for imported hardware buffers. Manages the native handle and synchronization fences for accessing the buffer.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#GPUHardwareBufferWrapper(kotlin.Long)(long handle)` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#beginAccess(kotlin.Array)(GPUSyncFence[] fences)` Begins access to the hardware buffer, passing any wait fences to the native layer. |
| `void` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#close()()` |
| `final https://developer.android.com/reference/androidx/webgpu/GPUSyncFence` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#endAccess()()` Ends access to the hardware buffer, returning a signal fence from the native layer. |

| ### Protected methods |
|---|---|
| `final external void` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#nativeBeginAccess(kotlin.Long,kotlin.IntArray)(long handle, int[] fences)` |
| `final external void` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#nativeDestroy(kotlin.Long)(long handle)` |
| `final external int` | `https://developer.android.com/reference/androidx/webgpu/GPUHardwareBufferWrapper#nativeEndAccess(kotlin.Long)(long handle)` |

## Public constructors

### GPUHardwareBufferWrapper

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

```
public GPUHardwareBufferWrapper(long handle)
```

## Public methods

### beginAccess

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

```
public final void beginAccess(GPUSyncFence[] fences)
```

Begins access to the hardware buffer, passing any wait fences to the native layer.

| Parameters |
|---|---|
| `GPUSyncFence[] fences` | Array of GPUSyncFence objects to wait on before accessing the buffer. |

### close

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

```
public void close()
```

### endAccess

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

```
public final GPUSyncFence endAccess()
```

Ends access to the hardware buffer, returning a signal fence from the native layer.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/webgpu/GPUSyncFence` | GPUSyncFence that will be signaled when WebGPU is done with the buffer. |

## Protected methods

### nativeBeginAccess

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

```
protected final external void nativeBeginAccess(long handle, int[] fences)
```

### nativeDestroy

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

```
protected final external void nativeDestroy(long handle)
```

### nativeEndAccess

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

```
protected final external int nativeEndAccess(long handle)
```