# 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
abstract class GPUHardwareBufferWrapper : AutoCloseable
```

<br />

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

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferExternalTexture` |   |
| `https://developer.android.com/reference/kotlin/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/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#GPUHardwareBufferWrapper(kotlin.Long)(handle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#beginAccess(kotlin.Array)(fences: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence>?)` Begins access to the hardware buffer, passing any wait fences to the native layer. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#close()()` |
| `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence?` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#endAccess()()` Ends access to the hardware buffer, returning a signal fence from the native layer. |

| ### Protected functions |
|---|---|
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#nativeBeginAccess(kotlin.Long,kotlin.IntArray)(handle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, fences: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html?)` |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#nativeDestroy(kotlin.Long)(handle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/webgpu/GPUHardwareBufferWrapper#nativeEndAccess(kotlin.Long)(handle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` |

## Public constructors

### GPUHardwareBufferWrapper

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

```
GPUHardwareBufferWrapper(handle: Long)
```

## Public functions

### beginAccess

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

```
fun beginAccess(fences: Array<GPUSyncFence>?): Unit
```

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

| Parameters |
|---|---|
| `fences: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/webgpu/GPUSyncFence>?` | 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)

```
open fun close(): Unit
```

### endAccess

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

```
fun endAccess(): GPUSyncFence?
```

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

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

## Protected functions

### nativeBeginAccess

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

```
protected external fun nativeBeginAccess(handle: Long, fences: IntArray?): Unit
```

### nativeDestroy

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

```
protected external fun nativeDestroy(handle: Long): Unit
```

### nativeEndAccess

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

```
protected external fun nativeEndAccess(handle: Long): Int
```