Package com.jme3.opencl.lwjgl
Class LwjglBuffer
java.lang.Object
com.jme3.opencl.AbstractOpenCLObject
com.jme3.opencl.Buffer
com.jme3.opencl.lwjgl.LwjglBuffer
- All Implemented Interfaces:
OpenCLObject
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.opencl.Buffer
Buffer.AsyncMapping
Nested classes/interfaces inherited from interface com.jme3.opencl.OpenCLObject
OpenCLObject.ObjectReleaser
-
Field Summary
Fields inherited from class com.jme3.opencl.AbstractOpenCLObject
releaser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAcquires this buffer object for using.void
Acquires this buffer object for using.void
copyTo
(CommandQueue queue, Buffer dest, long size, long srcOffset, long destOffset) Performs a blocking copy operation from this buffer to the specified buffer.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.copyToImageAsync
(CommandQueue queue, Image dest, long srcOffset, long[] destOrigin, long[] destRegion) Copies this buffer to the specified image.fillAsync
(CommandQueue queue, ByteBuffer pattern, long size, long offset) Enqueues a fill operation.org.lwjgl.opencl.CLMem
long
getSize()
map
(CommandQueue queue, long size, long offset, MappingAccess access) Maps this buffer directly into host memory.mapAsync
(CommandQueue queue, long size, long offset, MappingAccess access) Maps this buffer asynchronously into host memory.void
read
(CommandQueue queue, ByteBuffer dest, long size, long offset) Performs a blocking read of the buffer.readAsync
(CommandQueue queue, ByteBuffer dest, long size, long offset) Performs an async/non-blocking read of the buffer.Releases a shared buffer object.void
Releases a shared buffer object.void
unmap
(CommandQueue queue, ByteBuffer ptr) Unmaps a previously mapped memory.void
write
(CommandQueue queue, ByteBuffer src, long size, long offset) Performs a blocking write to the buffer.writeAsync
(CommandQueue queue, ByteBuffer src, long size, long offset) Performs an async/non-blocking write to the buffer.Methods inherited from class com.jme3.opencl.Buffer
copyTo, copyTo, copyToAsync, copyToAsync, map, map, mapAsync, mapAsync, read, read, readAsync, readAsync, register, toString, write, write, writeAsync, writeAsync
Methods inherited from class com.jme3.opencl.AbstractOpenCLObject
finalize, getReleaser, release
-
Constructor Details
-
LwjglBuffer
public LwjglBuffer(org.lwjgl.opencl.CLMem buffer)
-
-
Method Details
-
getBuffer
public org.lwjgl.opencl.CLMem getBuffer() -
getSize
public long getSize() -
getMemoryAccessFlags
- Specified by:
getMemoryAccessFlags
in classBuffer
- Returns:
- the memory access flags set on creation.
- See Also:
-
read
Description copied from class:Buffer
Performs a blocking read of the buffer. The target buffer must have at leastsize
bytes remaining. This method may set the limit to the last byte read. -
readAsync
Description copied from class:Buffer
Performs an async/non-blocking read of the buffer. The target buffer must have at leastsize
bytes remaining. This method may set the limit to the last byte read. -
write
Description copied from class:Buffer
Performs a blocking write to the buffer. The target buffer must have at leastsize
bytes remaining. This method may set the limit to the last byte that will be written. -
writeAsync
Description copied from class:Buffer
Performs an async/non-blocking write to the buffer. The target buffer must have at leastsize
bytes remaining. This method may set the limit to the last byte that will be written.- Specified by:
writeAsync
in classBuffer
- Parameters:
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 buffer- Returns:
- an Event to indicate completion
-
copyTo
Description copied from class:Buffer
Performs a blocking copy operation from this buffer to the specified buffer. -
copyToAsync
public Event copyToAsync(CommandQueue queue, Buffer dest, long size, long srcOffset, long destOffset) Description copied from class:Buffer
Performs an async/non-blocking copy operation from this buffer to the specified buffer.- Specified by:
copyToAsync
in classBuffer
- Parameters:
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 buffer- Returns:
- the event object indicating when the copy operation is finished
-
map
Description copied from class:Buffer
Maps this buffer directly into host memory. This might be the fastest method to access the contents of the buffer since the OpenCL implementation directly provides the memory.
Important: The mapped memory MUST be released by callingBuffer.unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
. -
unmap
Description copied from class:Buffer
Unmaps a previously mapped memory. This releases the native resources and for WRITE_ONLY or READ_WRITE access, the memory content is sent back to the GPU. -
mapAsync
public Buffer.AsyncMapping mapAsync(CommandQueue queue, long size, long offset, MappingAccess access) Description copied from class:Buffer
Maps this buffer asynchronously into host memory. This might be the fastest method to access the contents of the buffer since the OpenCL implementation directly provides the memory.
Important: The mapped memory MUST be released by callingBuffer.unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer)
.- Specified by:
mapAsync
in classBuffer
- Parameters:
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_WRITE- Returns:
- the byte buffer directly reflecting the buffer contents and the event indicating when the buffer contents are available
-
fillAsync
Description copied from class:Buffer
Enqueues a fill operation. This method can be used to initialize or clear a buffer with a certain value.- Specified by:
fillAsync
in classBuffer
- Parameters:
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 length- Returns:
- an event indicating when this operation is finished
-
copyToImageAsync
public Event copyToImageAsync(CommandQueue queue, Image dest, long srcOffset, long[] destOrigin, long[] destRegion) Description copied from class:Buffer
Copies this buffer to the specified image. Note that no format conversion is done.
For detailed description of the origin and region parameter, see the documentation of theImage
class.- Specified by:
copyToImageAsync
in classBuffer
- Parameters:
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 area- Returns:
- the event object
-
acquireBufferForSharingAsync
Description copied from class:Buffer
Acquires this buffer object for using. Only call this method if this buffer represents a shared object from OpenGL, created with e.g.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 callingBuffer.releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue)
so that OpenGL can use the VertexBuffer again.- Specified by:
acquireBufferForSharingAsync
in classBuffer
- Parameters:
queue
- the command queue- Returns:
- the event object
-
acquireBufferForSharingNoEvent
Description copied from class:Buffer
Acquires this buffer object for using. Only call this method if this buffer represents a shared object from OpenGL, created with e.g.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 callingBuffer.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, useBuffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
instead.- Overrides:
acquireBufferForSharingNoEvent
in classBuffer
- Parameters:
queue
- the command queue
-
releaseBufferForSharingAsync
Description copied from class:Buffer
Releases a shared buffer object. Call this method after the buffer object was acquired byBuffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.- Specified by:
releaseBufferForSharingAsync
in classBuffer
- Parameters:
queue
- the command queue- Returns:
- the event object
-
releaseBufferForSharingNoEvent
Description copied from class:Buffer
Releases a shared buffer object. Call this method after the buffer object was acquired byBuffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL. The generated event object is directly released, resulting in performance improvements.- Overrides:
releaseBufferForSharingNoEvent
in classBuffer
- Parameters:
queue
- the command queue
-