GPUBuffer
public final class GPUBuffer implements AutoCloseable
A chunk of memory allocated on the GPU, used for vertex data, uniforms, storage, etc.
Summary
Public methods |
|
|---|---|
external void |
close() |
final external void |
Immediately destroys the buffer resource. |
boolean |
|
final external @NonNull ByteBuffer |
@FastNativeReturns an immutable pointer to the mapped memory range for reading. |
final long |
|
final external int |
Gets the current mapping state of the buffer. |
final external @NonNull ByteBuffer |
@FastNativeReturns a mutable pointer to the mapped memory range for writing. |
final external long |
Gets the size of the buffer in bytes. |
final external int |
Gets the usage flags the buffer was created with. |
int |
hashCode() |
final void |
mapAndAwait(int mode, long offset, long size)Requests to map a range of the buffer into CPU-accessible memory asynchronously. |
final external void |
@FastNativeRequests to map a range of the buffer into CPU-accessible memory asynchronously. |
final int |
mapState() |
final external void |
@FastNativeReads data from a mapped buffer into CPU memory. |
final external void |
@FastNativeSets a debug label for the buffer. |
final long |
size() |
final external void |
Unmaps the buffer, making it inaccessible by the CPU and potentially usable by the GPU again. |
final int |
usage() |
final external void |
@FastNativeWrites data from CPU memory into a mapped buffer. |
Public methods
destroy
@FastNative
public final external void destroy()
Immediately destroys the buffer resource.
getConstMappedRange
@FastNative
public final external @NonNull ByteBuffer getConstMappedRange(long offset, long size)
Returns an immutable pointer to the mapped memory range for reading.
| Parameters | |
|---|---|
long offset |
The offset in bytes of the mapped range to retrieve. |
long size |
The size in bytes of the mapped range to retrieve. Can be whole_map_size. |
| Returns | |
|---|---|
@NonNull ByteBuffer |
An immutable pointer to the mapped buffer memory. |
getMapState
@FastNative
public final external int getMapState()
Gets the current mapping state of the buffer.
| Returns | |
|---|---|
int |
The buffer's map state. |
getMappedRange
@FastNative
public final external @NonNull ByteBuffer getMappedRange(long offset, long size)
Returns a mutable pointer to the mapped memory range for writing.
| Parameters | |
|---|---|
long offset |
The offset in bytes of the mapped range to retrieve. |
long size |
The size in bytes of the mapped range to retrieve. Can be whole_map_size. |
| Returns | |
|---|---|
@NonNull ByteBuffer |
A mutable pointer to the mapped buffer memory. |
getSize
@FastNative
public final external long getSize()
Gets the size of the buffer in bytes.
| Returns | |
|---|---|
long |
The size of the buffer. |
getUsage
@FastNative
public final external int getUsage()
Gets the usage flags the buffer was created with.
| Returns | |
|---|---|
int |
The buffer's usage flags. |
mapAndAwait
public final void mapAndAwait(int mode, long offset, long size)
Requests to map a range of the buffer into CPU-accessible memory asynchronously.
| Parameters | |
|---|---|
int mode |
The desired access mode for the mapping. |
long offset |
The offset in bytes where the mapping should start. |
long size |
The size in bytes of the range to map. Can be whole_map_size. |
mapAsync
@FastNative
public final external void mapAsync(
int mode,
long offset,
long size,
@NonNull Executor callbackExecutor,
@NonNull BufferMapCallback callback
)
Requests to map a range of the buffer into CPU-accessible memory asynchronously.
readMappedRange
@FastNative
public final external void readMappedRange(long offset, @NonNull ByteBuffer data)
Reads data from a mapped buffer into CPU memory.
| Parameters | |
|---|---|
long offset |
The offset in the mapped buffer to read from. |
@NonNull ByteBuffer data |
A pointer to the destination CPU memory. |
| Returns | |
|---|---|
void |
Status code of the operation. |
setLabel
@FastNative
public final external void setLabel(@NonNull String label)
Sets a debug label for the buffer.
unmap
@FastNative
public final external void unmap()
Unmaps the buffer, making it inaccessible by the CPU and potentially usable by the GPU again.
writeMappedRange
@FastNative
public final external void writeMappedRange(long offset, @NonNull ByteBuffer data)
Writes data from CPU memory into a mapped buffer.
| Parameters | |
|---|---|
long offset |
The offset in the mapped buffer to write to. |
@NonNull ByteBuffer data |
A pointer to the source CPU memory. |
| Returns | |
|---|---|
void |
Status code of the operation. |