GPUBuffer


class GPUBuffer : AutoCloseable


A block of memory accessible by the GPU.

Summary

Public functions

open external Unit

Decrements the reference count of the object and frees resources when the count reaches zero.

external Unit

Destroys the buffer and releases its resources.

open operator Boolean
equals(other: Any?)
external ByteBuffer

Gets a read-only pointer to the mapped range of the buffer.

external Int

Gets the current mapping state of the buffer.

external ByteBuffer
@FastNative
getMappedRange(offset: Long, size: Long)

Gets a pointer to the mapped range of the buffer.

external Long

Gets the size of the buffer in bytes.

external Int

Gets the allowed usages of the buffer.

open Int
suspend Unit
mapAndAwait(mode: Int, offset: Long, size: Long)

Asynchronously maps a range of the buffer for CPU access.

external Unit
@FastNative
mapAsync(
    mode: Int,
    offset: Long,
    size: Long,
    callbackExecutor: Executor,
    callback: GPURequestCallback<Unit>
)

Asynchronously maps a range of the buffer for CPU access.

external Unit

Copies data from a mapped range into a destination pointer.

external Unit

Sets a human-readable label for debugging.

external Unit

Unmaps the buffer, making it accessible to the GPU again.

external Unit

Copies data from a source pointer into a mapped range.

Public properties

Long
Int
Long
Int

Public functions

close

Added in 1.0.0-alpha04
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.

destroy

Added in 1.0.0-alpha04
@FastNative
external fun destroy(): Unit

Destroys the buffer and releases its resources.

equals

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

getConstMappedRange

Added in 1.0.0-alpha04
@FastNative
external fun getConstMappedRange(offset: Long = 0, size: Long = Constants.WHOLE_MAP_SIZE): ByteBuffer

Gets a read-only pointer to the mapped range of the buffer.

Parameters
offset: Long = 0

The offset in bytes from the beginning of the buffer.

size: Long = Constants.WHOLE_MAP_SIZE

The size in bytes of the range to get.

Returns
ByteBuffer

A read-only pointer to the mapped memory.

getMapState

Added in 1.0.0-alpha04
@FastNative
external fun getMapState(): Int

Gets the current mapping state of the buffer.

Returns
Int

The buffer map state.

getMappedRange

Added in 1.0.0-alpha04
@FastNative
external fun getMappedRange(offset: Long = 0, size: Long = Constants.WHOLE_MAP_SIZE): ByteBuffer

Gets a pointer to the mapped range of the buffer.

Parameters
offset: Long = 0

The offset in bytes from the beginning of the buffer.

size: Long = Constants.WHOLE_MAP_SIZE

The size in bytes of the range to get.

Returns
ByteBuffer

A pointer to the mapped memory.

getSize

Added in 1.0.0-alpha04
@FastNative
external fun getSize(): Long

Gets the size of the buffer in bytes.

Returns
Long

The buffer size.

getUsage

Added in 1.0.0-alpha04
@FastNative
external fun getUsage(): Int

Gets the allowed usages of the buffer.

Returns
Int

The buffer usage flags.

hashCode

open fun hashCode(): Int

mapAndAwait

Added in 1.0.0-alpha04
suspend fun mapAndAwait(mode: Int, offset: Long, size: Long): Unit

Asynchronously maps a range of the buffer for CPU access.

Parameters
mode: Int

The mapping mode (read or write).

offset: Long

The offset in bytes from the beginning of the buffer.

size: Long

The size in bytes of the range to map.

mapAsync

Added in 1.0.0-alpha04
@FastNative
external fun mapAsync(
    mode: Int,
    offset: Long,
    size: Long,
    callbackExecutor: Executor,
    callback: GPURequestCallback<Unit>
): Unit

Asynchronously maps a range of the buffer for CPU access.

readMappedRange

Added in 1.0.0-alpha04
@FastNative
external fun readMappedRange(offset: Long, data: ByteBuffer): Unit

Copies data from a mapped range into a destination pointer.

Parameters
offset: Long

The offset in bytes from the beginning of the buffer.

data: ByteBuffer

The destination pointer.

Returns
Unit

The status of the operation.

setLabel

Added in 1.0.0-alpha04
@FastNative
external fun setLabel(label: String): Unit

Sets a human-readable label for debugging.

Parameters
label: String

The label string.

unmap

Added in 1.0.0-alpha04
@FastNative
external fun unmap(): Unit

Unmaps the buffer, making it accessible to the GPU again.

writeMappedRange

Added in 1.0.0-alpha04
@FastNative
external fun writeMappedRange(offset: Long, data: ByteBuffer): Unit

Copies data from a source pointer into a mapped range.

Parameters
offset: Long

The offset in bytes from the beginning of the buffer.

data: ByteBuffer

The source pointer.

Returns
Unit

The status of the operation.

Public properties

handle

Added in 1.0.0-alpha04
val handleLong

mapState

Added in 1.0.0-alpha04
val mapStateInt

size

Added in 1.0.0-alpha04
val sizeLong

usage

Added in 1.0.0-alpha04
val usageInt