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.AsyncMappingNested classes/interfaces inherited from interface com.jme3.opencl.OpenCLObject
OpenCLObject.ObjectReleaser -
Field Summary
Fields inherited from class com.jme3.opencl.AbstractOpenCLObject
releaser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAcquires this buffer object for using.voidAcquires this buffer object for using.voidcopyTo(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.CLMemlonggetSize()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.voidread(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.voidReleases a shared buffer object.voidunmap(CommandQueue queue, ByteBuffer ptr) Unmaps a previously mapped memory.voidwrite(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, writeAsyncMethods 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:
getMemoryAccessFlagsin classBuffer- Returns:
- the memory access flags set on creation.
- See Also:
-
read
Description copied from class:BufferPerforms a blocking read of the buffer. The target buffer must have at leastsizebytes remaining. This method may set the limit to the last byte read. -
readAsync
Description copied from class:BufferPerforms an async/non-blocking read of the buffer. The target buffer must have at leastsizebytes remaining. This method may set the limit to the last byte read. -
write
Description copied from class:BufferPerforms a blocking write to the buffer. The target buffer must have at leastsizebytes remaining. This method may set the limit to the last byte that will be written. -
writeAsync
Description copied from class:BufferPerforms an async/non-blocking write to the buffer. The target buffer must have at leastsizebytes remaining. This method may set the limit to the last byte that will be written.- Specified by:
writeAsyncin 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:BufferPerforms 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:BufferPerforms an async/non-blocking copy operation from this buffer to the specified buffer.- Specified by:
copyToAsyncin 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:BufferMaps 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:BufferUnmaps 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:BufferMaps 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:
mapAsyncin 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:BufferEnqueues a fill operation. This method can be used to initialize or clear a buffer with a certain value.- Specified by:
fillAsyncin 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:BufferCopies 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 theImageclass.- Specified by:
copyToImageAsyncin 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:BufferAcquires 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:
acquireBufferForSharingAsyncin classBuffer- Parameters:
queue- the command queue- Returns:
- the event object
-
acquireBufferForSharingNoEvent
Description copied from class:BufferAcquires 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:
acquireBufferForSharingNoEventin classBuffer- Parameters:
queue- the command queue
-
releaseBufferForSharingAsync
Description copied from class:BufferReleases 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:
releaseBufferForSharingAsyncin classBuffer- Parameters:
queue- the command queue- Returns:
- the event object
-
releaseBufferForSharingNoEvent
Description copied from class:BufferReleases 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:
releaseBufferForSharingNoEventin classBuffer- Parameters:
queue- the command queue
-