GPUBuffer


public final class GPUBuffer implements AutoCloseable


A block of memory accessible by the GPU.

Summary

Public methods

external void

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

final external void

Destroys the buffer and releases its resources.

boolean
equals(Object other)
final external @NonNull ByteBuffer
@FastNative
getConstMappedRange(long offset, long size)

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

final long
final external int

Gets the current mapping state of the buffer.

final external @NonNull ByteBuffer
@FastNative
getMappedRange(long offset, long size)

Gets a pointer to the mapped range of the buffer.

final external long

Gets the size of the buffer in bytes.

final external int

Gets the allowed usages of the buffer.

int
final void
mapAndAwait(int mode, long offset, long size)

Asynchronously maps a range of the buffer for CPU access.

final external void
@FastNative
mapAsync(
    int mode,
    long offset,
    long size,
    @NonNull Executor callbackExecutor,
    @NonNull GPURequestCallback<Unit> callback
)

Asynchronously maps a range of the buffer for CPU access.

final int
final external void

Copies data from a mapped range into a destination pointer.

final external void

Sets a human-readable label for debugging.

final long
final external void

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

final int
final external void

Copies data from a source pointer into a mapped range.

Public methods

close

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

destroy

Added in 1.0.0-alpha04
@FastNative
public final external void destroy()

Destroys the buffer and releases its resources.

equals

public boolean equals(Object other)

getConstMappedRange

Added in 1.0.0-alpha04
@FastNative
public final external @NonNull ByteBuffer getConstMappedRange(long offset, long size)

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

Parameters
long offset

The offset in bytes from the beginning of the buffer.

long size

The size in bytes of the range to get.

Returns
@NonNull ByteBuffer

A read-only pointer to the mapped memory.

getHandle

Added in 1.0.0-alpha04
public final long getHandle()

getMapState

Added in 1.0.0-alpha04
@FastNative
public final external int getMapState()

Gets the current mapping state of the buffer.

Returns
int

The buffer map state.

getMappedRange

Added in 1.0.0-alpha04
@FastNative
public final external @NonNull ByteBuffer getMappedRange(long offset, long size)

Gets a pointer to the mapped range of the buffer.

Parameters
long offset

The offset in bytes from the beginning of the buffer.

long size

The size in bytes of the range to get.

Returns
@NonNull ByteBuffer

A pointer to the mapped memory.

getSize

Added in 1.0.0-alpha04
@FastNative
public final external long getSize()

Gets the size of the buffer in bytes.

Returns
long

The buffer size.

getUsage

Added in 1.0.0-alpha04
@FastNative
public final external int getUsage()

Gets the allowed usages of the buffer.

Returns
int

The buffer usage flags.

hashCode

public int hashCode()

mapAndAwait

Added in 1.0.0-alpha04
public final void mapAndAwait(int mode, long offset, long size)

Asynchronously maps a range of the buffer for CPU access.

Parameters
int mode

The mapping mode (read or write).

long offset

The offset in bytes from the beginning of the buffer.

long size

The size in bytes of the range to map.

mapAsync

Added in 1.0.0-alpha04
@FastNative
public final external void mapAsync(
    int mode,
    long offset,
    long size,
    @NonNull Executor callbackExecutor,
    @NonNull GPURequestCallback<Unit> callback
)

Asynchronously maps a range of the buffer for CPU access.

mapState

Added in 1.0.0-alpha04
public final int mapState()

readMappedRange

Added in 1.0.0-alpha04
@FastNative
public final external void readMappedRange(long offset, @NonNull ByteBuffer data)

Copies data from a mapped range into a destination pointer.

Parameters
long offset

The offset in bytes from the beginning of the buffer.

@NonNull ByteBuffer data

The destination pointer.

Returns
void

The status of the operation.

setLabel

Added in 1.0.0-alpha04
@FastNative
public final external void setLabel(@NonNull String label)

Sets a human-readable label for debugging.

Parameters
@NonNull String label

The label string.

size

Added in 1.0.0-alpha04
public final long size()

unmap

Added in 1.0.0-alpha04
@FastNative
public final external void unmap()

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

usage

Added in 1.0.0-alpha04
public final int usage()

writeMappedRange

Added in 1.0.0-alpha04
@FastNative
public final external void writeMappedRange(long offset, @NonNull ByteBuffer data)

Copies data from a source pointer into a mapped range.

Parameters
long offset

The offset in bytes from the beginning of the buffer.

@NonNull ByteBuffer data

The source pointer.

Returns
void

The status of the operation.