Class LwjglImage

All Implemented Interfaces:
OpenCLObject

public class LwjglImage extends Image
  • Constructor Details

    • LwjglImage

      public LwjglImage(org.lwjgl.opencl.CLMem image)
  • Method Details

    • getImage

      public org.lwjgl.opencl.CLMem getImage()
    • decodeImageChannelOrder

      public static int decodeImageChannelOrder(Image.ImageChannelOrder order)
    • encodeImageChannelOrder

      public static Image.ImageChannelOrder encodeImageChannelOrder(int order)
    • decodeImageChannelType

      public static int decodeImageChannelType(Image.ImageChannelType type)
    • encodeImageChannelType

      public static Image.ImageChannelType encodeImageChannelType(int type)
    • decodeImageType

      public static int decodeImageType(Image.ImageType type)
    • encodeImageType

      public static Image.ImageType encodeImageType(int type)
    • getWidth

      public long getWidth()
      Specified by:
      getWidth in class Image
      Returns:
      the width of the image
    • getHeight

      public long getHeight()
      Specified by:
      getHeight in class Image
      Returns:
      the height of the image
    • getDepth

      public long getDepth()
      Specified by:
      getDepth in class Image
      Returns:
      the depth of the image
    • getRowPitch

      public long getRowPitch()
      Specified by:
      getRowPitch in class Image
      Returns:
      the row pitch when the image was created from a host buffer
    • getSlicePitch

      public long getSlicePitch()
      Specified by:
      getSlicePitch in class Image
      Returns:
      the slice pitch when the image was created from a host buffer
    • getArraySize

      public long getArraySize()
      Specified by:
      getArraySize in class Image
      Returns:
      the number of elements in the image array
      See Also:
    • getImageFormat

      public Image.ImageFormat getImageFormat()
      Specified by:
      getImageFormat in class Image
      Returns:
      the image format
    • getImageType

      public Image.ImageType getImageType()
      Specified by:
      getImageType in class Image
      Returns:
      the image type
    • getElementSize

      public int getElementSize()
      Specified by:
      getElementSize in class Image
      Returns:
      the number of bytes per pixel
    • readImage

      public void readImage(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
      Description copied from class: Image
      Performs a blocking read of the image into the specified byte buffer.
      Specified by:
      readImage in class Image
      Parameters:
      queue - the command queue
      dest - the target byte buffer
      origin - the image origin location, see class description for the format
      region - the copied region, see class description for the format
      rowPitch - the row pitch of the target buffer, must be set to 0 if the image is 1D. If set to 0 for 2D and 3D image, the row pitch is calculated as bytesPerElement * width
      slicePitch - the slice pitch of the target buffer, must be set to 0 for 1D and 2D images. If set to 0 for 3D images, the slice pitch is calculated as rowPitch * height
    • readImageAsync

      public Event readImageAsync(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
      Description copied from class: Image
      Performs an async/non-blocking read of the image into the specified byte buffer.
      Specified by:
      readImageAsync in class Image
      Parameters:
      queue - the command queue
      dest - the target byte buffer
      origin - the image origin location, see class description for the format
      region - the copied region, see class description for the format
      rowPitch - the row pitch of the target buffer, must be set to 0 if the image is 1D. If set to 0 for 2D and 3D image, the row pitch is calculated as bytesPerElement * width
      slicePitch - the slice pitch of the target buffer, must be set to 0 for 1D and 2D images. If set to 0 for 3D images, the slice pitch is calculated as rowPitch * height
      Returns:
      the event object indicating the status of the operation
    • writeImage

      public void writeImage(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
      Description copied from class: Image
      Performs a blocking write from the specified byte buffer into the image.
      Specified by:
      writeImage in class Image
      Parameters:
      queue - the command queue
      dest - the source buffer
      origin - the image origin location, see class description for the format
      region - the copied region, see class description for the format
      rowPitch - the row pitch of the target buffer, must be set to 0 if the image is 1D. If set to 0 for 2D and 3D image, the row pitch is calculated as bytesPerElement * width
      slicePitch - the slice pitch of the target buffer, must be set to 0 for 1D and 2D images. If set to 0 for 3D images, the slice pitch is calculated as rowPitch * height
    • writeImageAsync

      public Event writeImageAsync(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
      Description copied from class: Image
      Performs an async/non-blocking write from the specified byte buffer into the image.
      Specified by:
      writeImageAsync in class Image
      Parameters:
      queue - the command queue
      dest - the source buffer
      origin - the image origin location, see class description for the format
      region - the copied region, see class description for the format
      rowPitch - the row pitch of the target buffer, must be set to 0 if the image is 1D. If set to 0 for 2D and 3D image, the row pitch is calculated as bytesPerElement * width
      slicePitch - the slice pitch of the target buffer, must be set to 0 for 1D and 2D images. If set to 0 for 3D images, the slice pitch is calculated as rowPitch * height
      Returns:
      the event object indicating the status of the operation
    • copyTo

      public void copyTo(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region)
      Description copied from class: Image
      Performs a blocking copy operation from one image to another. Important: Both images must have the same format!
      Specified by:
      copyTo in class Image
      Parameters:
      queue - the command queue
      dest - the target image
      srcOrigin - the source image origin, see class description for the format
      destOrigin - the target image origin, see class description for the format
      region - the copied region, see class description for the format
    • copyToAsync

      public Event copyToAsync(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region)
      Description copied from class: Image
      Performs an async/non-blocking copy operation from one image to another. Important: Both images must have the same format!
      Specified by:
      copyToAsync in class Image
      Parameters:
      queue - the command queue
      dest - the target image
      srcOrigin - the source image origin, see class description for the format
      destOrigin - the target image origin, see class description for the format
      region - the copied region, see class description for the format
      Returns:
      the event object indicating the status of the operation
    • map

      public Image.ImageMapping map(CommandQueue queue, long[] origin, long[] region, MappingAccess access)
      Description copied from class: Image
      Maps the image into host memory. The returned structure contains the mapped byte buffer and row and slice pitch. The event object is set to null, it is needed for the async version Image.mapAsync(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess).
      Specified by:
      map in class Image
      Parameters:
      queue - the command queue
      origin - the image origin, see class description for the format
      region - the mapped region, see class description for the format
      access - the allowed memory access to the mapped memory
      Returns:
      a structure describing the mapped memory
      See Also:
    • mapAsync

      public Image.ImageMapping mapAsync(CommandQueue queue, long[] origin, long[] region, MappingAccess access)
      Description copied from class: Image
      Non-blocking version of Image.map(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess). The returned structure contains the mapped byte buffer and row and slice pitch. The event object is used to detect when the mapped memory is available.
      Specified by:
      mapAsync in class Image
      Parameters:
      queue - the command queue
      origin - the image origin, see class description for the format
      region - the mapped region, see class description for the format
      access - the allowed memory access to the mapped memory
      Returns:
      a structure describing the mapped memory
      See Also:
    • unmap

      public void unmap(CommandQueue queue, Image.ImageMapping mapping)
      Description copied from class: Image
      Unmaps the mapped memory
      Specified by:
      unmap in class Image
      Parameters:
      queue - the command queue
      mapping - the mapped memory
    • fillAsync

      public Event fillAsync(CommandQueue queue, long[] origin, long[] region, ColorRGBA color)
      Description copied from class: Image
      Fills the image with the specified color. Does only work if the image channel is Image.ImageChannelType.FLOAT or Image.ImageChannelType.HALF_FLOAT.
      Specified by:
      fillAsync in class Image
      Parameters:
      queue - the command queue
      origin - the image origin, see class description for the format
      region - the size of the region, see class description for the format
      color - the color to fill
      Returns:
      an event object to detect for the completion
    • fillAsync

      public Event fillAsync(CommandQueue queue, long[] origin, long[] region, int[] color)
      Description copied from class: Image
      Fills the image with the specified color given as four integer variables. Does not work if the image channel is Image.ImageChannelType.FLOAT or Image.ImageChannelType.HALF_FLOAT.
      Specified by:
      fillAsync in class Image
      Parameters:
      queue - the command queue
      origin - the image origin, see class description for the format
      region - the size of the region, see class description for the format
      color - the color to fill, must be an array of length 4
      Returns:
      an event object to detect for the completion
    • copyToBufferAsync

      public Event copyToBufferAsync(CommandQueue queue, Buffer dest, long[] srcOrigin, long[] srcRegion, long destOffset)
      Description copied from class: Image
      Copies this image into the specified buffer, no format conversion is done. This is the dual function to Buffer.copyToImageAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image, long, long[], long[]).
      Specified by:
      copyToBufferAsync in class Image
      Parameters:
      queue - the command queue
      dest - the target buffer
      srcOrigin - the image origin, see class description for the format
      srcRegion - the copied region, see class description for the format
      destOffset - an offset into the target buffer
      Returns:
      the event object to detect the completion of the operation
    • acquireImageForSharingAsync

      public Event acquireImageForSharingAsync(CommandQueue queue)
      Description copied from class: Image
      Acquires this image object for using. Only call this method if this image represents a shared object from OpenGL, created with e.g. Context.bindImage(com.jme3.texture.Image, com.jme3.texture.Texture.Type, int, com.jme3.opencl.MemoryAccess) or variations. This method must be called before the image is used. After the work is done, the image must be released by calling Image.releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) so that OpenGL can use the image/texture/renderbuffer again.
      Specified by:
      acquireImageForSharingAsync in class Image
      Parameters:
      queue - the command queue
      Returns:
      the event object
    • acquireImageForSharingNoEvent

      public void acquireImageForSharingNoEvent(CommandQueue queue)
      Description copied from class: Image
      Acquires this image object for using. Only call this method if this image represents a shared object from OpenGL, created with e.g. Context.bindImage(com.jme3.texture.Image, com.jme3.texture.Texture.Type, int, com.jme3.opencl.MemoryAccess) or variations. This method must be called before the image is used. After the work is done, the image must be released by calling Image.releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) so that OpenGL can use the image/texture/renderbuffer 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 Image.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue).
      Overrides:
      acquireImageForSharingNoEvent in class Image
      Parameters:
      queue - the command queue
    • releaseImageForSharingAsync

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

      public void releaseImageForSharingNoEvent(CommandQueue queue)
      Description copied from class: Image
      Releases a shared image object. Call this method after the image object was acquired by Image.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) to hand the control back to OpenGL. The generated event object is directly released, resulting in performance improvements.
      Overrides:
      releaseImageForSharingNoEvent in class Image
      Parameters:
      queue - the command queue