GPUBuffer
public final class GPUBuffer implements AutoCloseable
A block of memory accessible by the GPU.
Summary
Public methods |
|
|---|---|
external void |
close()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 |
|
final external @NonNull ByteBuffer |
@FastNativeGets 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 |
@FastNativeGets 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 |
hashCode() |
final void |
mapAndAwait(int mode, long offset, long size)Asynchronously maps a range of the buffer for CPU access. |
final external void |
@FastNativeAsynchronously maps a range of the buffer for CPU access. |
final int |
mapState() |
final external void |
@FastNativeCopies data from a mapped range into a destination pointer. |
final external void |
@FastNativeSets a human-readable label for debugging. |
final long |
size() |
final external void |
Unmaps the buffer, making it accessible to the GPU again. |
final int |
usage() |
final external void |
@FastNativeCopies data from a source pointer into a mapped range. |
Public methods
close
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
@FastNative
public final external void destroy()
Destroys the buffer and releases its resources.
getConstMappedRange
@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. |
getMapState
@FastNative
public final external int getMapState()
Gets the current mapping state of the buffer.
| Returns | |
|---|---|
int |
The buffer map state. |
getMappedRange
@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
@FastNative
public final external long getSize()
Gets the size of the buffer in bytes.
| Returns | |
|---|---|
long |
The buffer size. |
getUsage
@FastNative
public final external int getUsage()
Gets the allowed usages of the buffer.
| Returns | |
|---|---|
int |
The buffer usage flags. |
mapAndAwait
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
@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.
readMappedRange
@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
@FastNative
public final external void setLabel(@NonNull String label)
Sets a human-readable label for debugging.
unmap
@FastNative
public final external void unmap()
Unmaps the buffer, making it accessible to the GPU again.
writeMappedRange
@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. |