Class LwjglBuffer

All Implemented Interfaces:
OpenCLObject

public class LwjglBuffer extends Buffer
  • Constructor Details

    • LwjglBuffer

      public LwjglBuffer(org.lwjgl.opencl.CLMem buffer)
  • Method Details

    • getBuffer

      public org.lwjgl.opencl.CLMem getBuffer()
    • getSize

      public long getSize()
      Specified by:
      getSize in class Buffer
      Returns:
      the size of the buffer in bytes.
      See Also:
    • getMemoryAccessFlags

      public MemoryAccess getMemoryAccessFlags()
      Specified by:
      getMemoryAccessFlags in class Buffer
      Returns:
      the memory access flags set on creation.
      See Also:
    • read

      public void read(CommandQueue queue, ByteBuffer dest, long size, long offset)
      Description copied from class: Buffer
      Performs a blocking read of the buffer. The target buffer must have at least size bytes remaining. This method may set the limit to the last byte read.
      Specified by:
      read in class Buffer
      Parameters:
      queue - the command queue
      dest - the target buffer
      size - the size in bytes being read
      offset - the offset in bytes in the buffer to read from
    • readAsync

      public Event readAsync(CommandQueue queue, ByteBuffer dest, long size, long offset)
      Description copied from class: Buffer
      Performs an async/non-blocking read of the buffer. The target buffer must have at least size bytes remaining. This method may set the limit to the last byte read.
      Specified by:
      readAsync in class Buffer
      Parameters:
      queue - the command queue
      dest - the target buffer
      size - the size in bytes being read
      offset - the offset in bytes in the buffer to read from
      Returns:
      the event indicating when the memory has been fully read into the provided buffer
    • write

      public void write(CommandQueue queue, ByteBuffer src, long size, long offset)
      Description copied from class: Buffer
      Performs a blocking write to the buffer. The target buffer must have at least size bytes remaining. This method may set the limit to the last byte that will be written.
      Specified by:
      write in class Buffer
      Parameters:
      queue - the command queue
      src - the source buffer, its data is written to this buffer
      size - the size in bytes to write
      offset - the offset into the target buffer
    • writeAsync

      public Event writeAsync(CommandQueue queue, ByteBuffer src, long size, long offset)
      Description copied from class: Buffer
      Performs an async/non-blocking write to the buffer. The target buffer must have at least size bytes remaining. This method may set the limit to the last byte that will be written.
      Specified by:
      writeAsync in class Buffer
      Parameters:
      queue - the command queue
      src - the source buffer, its data is written to this buffer
      size - the size in bytes to write
      offset - the offset into the target buffer
      Returns:
      an Event to indicate completion
    • copyTo

      public void copyTo(CommandQueue queue, Buffer dest, long size, long srcOffset, long destOffset)
      Description copied from class: Buffer
      Performs a blocking copy operation from this buffer to the specified buffer.
      Specified by:
      copyTo in class Buffer
      Parameters:
      queue - the command queue
      dest - the target buffer
      size - the size in bytes to copy
      srcOffset - offset in bytes into this buffer
      destOffset - offset in bytes into the target 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 class Buffer
      Parameters:
      queue - the command queue
      dest - the target buffer
      size - the size in bytes to copy
      srcOffset - offset in bytes into this buffer
      destOffset - offset in bytes into the target buffer
      Returns:
      the event object indicating when the copy operation is finished
    • map

      public ByteBuffer map(CommandQueue queue, long size, long offset, MappingAccess access)
      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 calling Buffer.unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer).
      Specified by:
      map in class Buffer
      Parameters:
      queue - the command queue
      size - the size in bytes to map
      offset - the offset into this buffer
      access - specifies the possible access to the memory: READ_ONLY, WRITE_ONLY, READ_WRITE
      Returns:
      the byte buffer directly reflecting the buffer contents
    • unmap

      public void unmap(CommandQueue queue, ByteBuffer ptr)
      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.
      Specified by:
      unmap in class Buffer
      Parameters:
      queue - the command queue
      ptr - the buffer that was previously mapped
    • 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 calling Buffer.unmap(com.jme3.opencl.CommandQueue, java.nio.ByteBuffer).
      Specified by:
      mapAsync in class Buffer
      Parameters:
      queue - the command queue
      size - the size in bytes to map
      offset - the offset into this buffer
      access - 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

      public Event fillAsync(CommandQueue queue, ByteBuffer pattern, long size, long offset)
      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 class Buffer
      Parameters:
      queue - the command queue
      pattern - the buffer containing the filling pattern. The remaining bytes specify the pattern length
      size - the size in bytes to fill, must be a multiple of the pattern length
      offset - 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 the Image class.
      Specified by:
      copyToImageAsync in class Buffer
      Parameters:
      queue - the command queue
      dest - the target image
      srcOffset - the offset in bytes into this buffer
      destOrigin - the origin of the copied area
      destRegion - the size of the copied area
      Returns:
      the event object
    • acquireBufferForSharingAsync

      public Event acquireBufferForSharingAsync(CommandQueue queue)
      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 calling Buffer.releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue) so that OpenGL can use the VertexBuffer again.
      Specified by:
      acquireBufferForSharingAsync in class Buffer
      Parameters:
      queue - the command queue
      Returns:
      the event object
    • acquireBufferForSharingNoEvent

      public void acquireBufferForSharingNoEvent(CommandQueue queue)
      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 calling Buffer.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 Buffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue) instead.
      Overrides:
      acquireBufferForSharingNoEvent in class Buffer
      Parameters:
      queue - the command queue
    • releaseBufferForSharingAsync

      public Event releaseBufferForSharingAsync(CommandQueue queue)
      Description copied from class: Buffer
      Releases a shared buffer object. Call this method after the buffer object was acquired by Buffer.acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue) to hand the control back to OpenGL.
      Specified by:
      releaseBufferForSharingAsync in class Buffer
      Parameters:
      queue - the command queue
      Returns:
      the event object
    • releaseBufferForSharingNoEvent

      public void releaseBufferForSharingNoEvent(CommandQueue queue)
      Description copied from class: Buffer
      Releases a shared buffer object. Call this method after the buffer object was acquired by Buffer.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 class Buffer
      Parameters:
      queue - the command queue