public abstract class Buffer extends AbstractOpenCLObject
Context
.
Event
object
and have the prefix -Async in their name.Modifier and Type | Class and Description |
---|---|
static class |
Buffer.AsyncMapping
Result of an async mapping operation, contains the event and the target byte buffer.
|
OpenCLObject.ObjectReleaser
releaser
Modifier | Constructor and Description |
---|---|
protected |
Buffer(OpenCLObject.ObjectReleaser releaser) |
Modifier and Type | Method and Description |
---|---|
abstract Event |
acquireBufferForSharingAsync(CommandQueue queue)
Aquires this buffer object for using.
|
void |
acquireBufferForSharingNoEvent(CommandQueue queue)
Aquires this buffer object for using.
|
void |
copyTo(CommandQueue queue,
Buffer dest)
Alternative version of
copyTo(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long) ,
sets size to this.getSize() . |
void |
copyTo(CommandQueue queue,
Buffer dest,
long size)
Alternative version of
copyTo(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long, long, long) ,
sets srcOffset and destOffset to zero. |
abstract void |
copyTo(CommandQueue queue,
Buffer dest,
long size,
long srcOffset,
long destOffset)
Performs a blocking copy operation from this buffer to the specified buffer.
|
Event |
copyToAsync(CommandQueue queue,
Buffer dest)
Alternative version of
copyToAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long) ,
sets size to this.getSize() . |
Event |
copyToAsync(CommandQueue queue,
Buffer dest,
long size)
Alternative version of
copyToAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long, long, long) ,
sets srcOffset and destOffset to zero. |
abstract Event |
copyToAsync(CommandQueue queue,
Buffer dest,
long size,
long srcOffset,
long destOffset)
Performs an async/non-blocking copy operation from this buffer to the specified buffer.
|
abstract Event |
copyToImageAsync(CommandQueue queue,
Image dest,
long srcOffset,
long[] destOrigin,
long[] destRegion)
Copies this buffer to the specified image.
|
abstract Event |
fillAsync(CommandQueue queue,
java.nio.ByteBuffer pattern,
long size,
long offset)
Enqueues a fill operation.
|
abstract MemoryAccess |
getMemoryAccessFlags() |
abstract long |
getSize() |
abstract java.nio.ByteBuffer |
map(CommandQueue queue,
long size,
long offset,
MappingAccess access)
Maps this buffer directly into host memory.
|
java.nio.ByteBuffer |
map(CommandQueue queue,
long size,
MappingAccess access)
Alternative version of
map(com.jme3.opencl.CommandQueue, long, long, com.jme3.opencl.MappingAccess) ,
sets offset to zero. |
java.nio.ByteBuffer |
map(CommandQueue queue,
MappingAccess access)
Alternative version of
map(com.jme3.opencl.CommandQueue, long, com.jme3.opencl.MappingAccess) ,
sets size to getSize() . |
abstract Buffer.AsyncMapping |
mapAsync(CommandQueue queue,
long size,
long offset,
MappingAccess access)
Maps this buffer asynchronously into host memory.
|
Buffer.AsyncMapping |
mapAsync(CommandQueue queue,
long size,
MappingAccess access)
Alternative version of
mapAsync(com.jme3.opencl.CommandQueue, long, long, com.jme3.opencl.MappingAccess) ,
sets offset to zero. |
Buffer.AsyncMapping |
mapAsync(CommandQueue queue,
MappingAccess access)
Alternative version of
mapAsync(com.jme3.opencl.CommandQueue, long, com.jme3.opencl.MappingAccess) ,
sets size to getSize() . |
void |
read(CommandQueue queue,
java.nio.ByteBuffer dest)
Alternative version of
read(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long) ,
sets size to getSize() . |
void |
read(CommandQueue queue,
java.nio.ByteBuffer dest,
long size)
Alternative version of
read(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long) ,
sets offset to zero. |
abstract void |
read(CommandQueue queue,
java.nio.ByteBuffer dest,
long size,
long offset)
Performs a blocking read of the buffer.
|
Event |
readAsync(CommandQueue queue,
java.nio.ByteBuffer dest)
Alternative version of
readAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long) ,
sets size to getSize() |
Event |
readAsync(CommandQueue queue,
java.nio.ByteBuffer dest,
long size)
Alternative version of
readAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long) ,
sets offset to zero. |
abstract Event |
readAsync(CommandQueue queue,
java.nio.ByteBuffer dest,
long size,
long offset)
Performs an async/non-blocking read of the buffer.
|
Buffer |
register()
Registers this object for automatic releasing on garbage collection.
|
abstract Event |
releaseBufferForSharingAsync(CommandQueue queue)
Releases a shared buffer object.
|
void |
releaseBufferForSharingNoEvent(CommandQueue queue)
Releases a shared buffer object.
|
java.lang.String |
toString() |
abstract void |
unmap(CommandQueue queue,
java.nio.ByteBuffer ptr)
Unmaps a previously mapped memory.
|
void |
write(CommandQueue queue,
java.nio.ByteBuffer src)
Alternative version of
write(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long) ,
sets size to getSize() . |
void |
write(CommandQueue queue,
java.nio.ByteBuffer src,
long size)
Alternative version of
write(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long) ,
sets offset to zero. |
abstract void |
write(CommandQueue queue,
java.nio.ByteBuffer src,
long size,
long offset)
Performs a blocking write to the buffer.
|
Event |
writeAsync(CommandQueue queue,
java.nio.ByteBuffer src)
Alternative version of
writeAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long) ,
sets size to getSize() . |
Event |
writeAsync(CommandQueue queue,
java.nio.ByteBuffer src,
long size)
Alternative version of
writeAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long) ,
sets offset to zero. |
abstract Event |
writeAsync(CommandQueue queue,
java.nio.ByteBuffer src,
long size,
long offset)
Performs an async/non-blocking write to the buffer.
|
finalize, getReleaser, release
protected Buffer(OpenCLObject.ObjectReleaser releaser)
public Buffer register()
OpenCLObject
OpenCLObjectManager
, you have to release it manually
by calling OpenCLObject.release()
.
Without registering or releasing, a memory leak might occur.
this
to allow calls like
Buffer buffer = clContext.createBuffer(1024).register();
.register
in interface OpenCLObject
register
in class AbstractOpenCLObject
this
public abstract long getSize()
Context.createBuffer(long)
public abstract MemoryAccess getMemoryAccessFlags()
Context.createBuffer(long, com.jme3.opencl.MemoryAccess)
public abstract void read(CommandQueue queue, java.nio.ByteBuffer dest, long size, long offset)
size
bytes remaining.
This method may set the limit to the last byte read.queue
- the command queuedest
- the target buffersize
- the size in bytes being readoffset
- the offset in bytes in the buffer to read frompublic void read(CommandQueue queue, java.nio.ByteBuffer dest, long size)
read(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long)
,
sets offset
to zero.queue
- the command queuedest
- the target buffersize
- the number of bytes to readpublic void read(CommandQueue queue, java.nio.ByteBuffer dest)
read(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long)
,
sets size
to getSize()
.queue
- the command queuedest
- the target bufferpublic abstract Event readAsync(CommandQueue queue, java.nio.ByteBuffer dest, long size, long offset)
size
bytes remaining.
This method may set the limit to the last byte read.queue
- the command queuedest
- the target buffersize
- the size in bytes being readoffset
- the offset in bytes in the buffer to read frompublic Event readAsync(CommandQueue queue, java.nio.ByteBuffer dest, long size)
readAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long)
,
sets offset
to zero.queue
- the command queuedest
- the target buffersize
- the number of bytes to readpublic Event readAsync(CommandQueue queue, java.nio.ByteBuffer dest)
readAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long)
,
sets size
to getSize()
queue
- the command queuedest
- the target bufferpublic abstract void write(CommandQueue queue, java.nio.ByteBuffer src, long size, long offset)
size
bytes remaining.
This method may set the limit to the last byte that will be written.queue
- the command queuesrc
- the source buffer, its data is written to this buffersize
- the size in bytes to writeoffset
- the offset into the target bufferpublic void write(CommandQueue queue, java.nio.ByteBuffer src, long size)
write(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long)
,
sets offset
to zero.queue
- the command queuesrc
- the source buffer, its data is written to this buffersize
- the number of bytes to writepublic void write(CommandQueue queue, java.nio.ByteBuffer src)
write(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long)
,
sets size
to getSize()
.queue
- the command queuesrc
- the source buffer, its data is written to this bufferpublic abstract Event writeAsync(CommandQueue queue, java.nio.ByteBuffer src, long size, long offset)
size
bytes remaining.
This method may set the limit to the last byte that will be written.queue
- the command queuesrc
- the source buffer, its data is written to this buffersize
- the size in bytes to writeoffset
- the offset into the target bufferpublic Event writeAsync(CommandQueue queue, java.nio.ByteBuffer src, long size)
writeAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long, long)
,
sets offset
to zero.queue
- the command queuesrc
- the source buffer, its data is written to this buffersize
- the number of bytes to writepublic Event writeAsync(CommandQueue queue, java.nio.ByteBuffer src)
writeAsync(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer, long)
,
sets size
to getSize()
.queue
- the command queuesrc
- the source buffer, its data is written to this bufferpublic abstract void copyTo(CommandQueue queue, Buffer dest, long size, long srcOffset, long destOffset)
queue
- the command queuedest
- the target buffersize
- the size in bytes to copysrcOffset
- offset in bytes into this bufferdestOffset
- offset in bytes into the target bufferpublic void copyTo(CommandQueue queue, Buffer dest, long size)
copyTo(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long, long, long)
,
sets srcOffset
and destOffset
to zero.queue
- the command queuedest
- the target buffersize
- the number of bytes to copypublic void copyTo(CommandQueue queue, Buffer dest)
copyTo(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long)
,
sets size
to this.getSize()
.queue
- the command queuedest
- the target bufferpublic abstract Event copyToAsync(CommandQueue queue, Buffer dest, long size, long srcOffset, long destOffset)
queue
- the command queuedest
- the target buffersize
- the size in bytes to copysrcOffset
- offset in bytes into this bufferdestOffset
- offset in bytes into the target bufferpublic Event copyToAsync(CommandQueue queue, Buffer dest, long size)
copyToAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long, long, long)
,
sets srcOffset
and destOffset
to zero.queue
- the command queuedest
- the target buffersize
- the number of bytes to copypublic Event copyToAsync(CommandQueue queue, Buffer dest)
copyToAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Buffer, long)
,
sets size
to this.getSize()
.queue
- the command queuedest
- the target bufferpublic abstract java.nio.ByteBuffer map(CommandQueue queue, long size, long offset, MappingAccess access)
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queuesize
- the size in bytes to mapoffset
- the offset into this bufferaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic java.nio.ByteBuffer map(CommandQueue queue, long size, MappingAccess access)
map(com.jme3.opencl.CommandQueue, long, long, com.jme3.opencl.MappingAccess)
,
sets offset
to zero.
Important: The mapped memory MUST be released by calling
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queuesize
- the number of bytes to mapaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic java.nio.ByteBuffer map(CommandQueue queue, MappingAccess access)
map(com.jme3.opencl.CommandQueue, long, com.jme3.opencl.MappingAccess)
,
sets size
to getSize()
.
Important: The mapped memory MUST be released by calling
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queueaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic abstract void unmap(CommandQueue queue, java.nio.ByteBuffer ptr)
queue
- the command queueptr
- the buffer that was previously mappedpublic abstract Buffer.AsyncMapping mapAsync(CommandQueue queue, long size, long offset, MappingAccess access)
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queuesize
- the size in bytes to mapoffset
- the offset into this bufferaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic Buffer.AsyncMapping mapAsync(CommandQueue queue, long size, MappingAccess access)
mapAsync(com.jme3.opencl.CommandQueue, long, long, com.jme3.opencl.MappingAccess)
,
sets offset
to zero.
Important: The mapped memory MUST be released by calling
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queuesize
- the size in bytes to mapaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic Buffer.AsyncMapping mapAsync(CommandQueue queue, MappingAccess access)
mapAsync(com.jme3.opencl.CommandQueue, long, com.jme3.opencl.MappingAccess)
,
sets size
to getSize()
.
Important: The mapped memory MUST be released by calling
unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.queue
- the command queueaccess
- specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITEpublic abstract Event fillAsync(CommandQueue queue, java.nio.ByteBuffer pattern, long size, long offset)
queue
- the command queuepattern
- the buffer containing the filling pattern.
The remaining bytes specify the pattern lengthsize
- the size in bytes to fill, must be a multiple of the pattern lengthoffset
- the offset in bytes into the buffer, must be a multiple of the pattern lengthpublic abstract Event copyToImageAsync(CommandQueue queue, Image dest, long srcOffset, long[] destOrigin, long[] destRegion)
Image
class.queue
- the command queuedest
- the target imagesrcOffset
- the offset in bytes into this bufferdestOrigin
- the origin of the copied areadestRegion
- the size of the copied areapublic abstract Event acquireBufferForSharingAsync(CommandQueue queue)
Context.bindVertexBuffer(com.jme3.scene.VertexBuffer, com.jme3.opencl.MemoryAccess)
.
This method must be called before the buffer is used. After the work is
done, the buffer must be released by calling
releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue)
so that OpenGL can use the VertexBuffer again.queue
- the command queuepublic void acquireBufferForSharingNoEvent(CommandQueue queue)
Context.bindVertexBuffer(com.jme3.scene.VertexBuffer, com.jme3.opencl.MemoryAccess)
.
This method must be called before the buffer is used. After the work is
done, the buffer must be released by calling
releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue)
so that OpenGL can use the VertexBuffer again.
The generated event object is directly released.
This brings a performance improvement when the resource is e.g. directly
used by a kernel afterwards on the same queue (this implicitly waits for
this action). If you need the event, use
acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
instead.queue
- the command queuepublic abstract Event releaseBufferForSharingAsync(CommandQueue queue)
acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.queue
- the command queuepublic void releaseBufferForSharingNoEvent(CommandQueue queue)
acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.
The generated event object is directly released, resulting in
performance improvements.queue
- the command queuepublic java.lang.String toString()
toString
in class java.lang.Object