Package com.jme3.opencl.lwjgl
Class LwjglImage
java.lang.Object
com.jme3.opencl.AbstractOpenCLObject
com.jme3.opencl.Image
com.jme3.opencl.lwjgl.LwjglImage
- All Implemented Interfaces:
OpenCLObject
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.opencl.Image
Image.ImageChannelOrder, Image.ImageChannelType, Image.ImageDescriptor, Image.ImageFormat, Image.ImageMapping, Image.ImageType
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 image object for using.void
Acquires this image object for using.void
copyTo
(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region) Performs a blocking copy operation from one image to another.copyToAsync
(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region) Performs an async/non-blocking copy operation from one image to another.copyToBufferAsync
(CommandQueue queue, Buffer dest, long[] srcOrigin, long[] srcRegion, long destOffset) Copies this image into the specified buffer, no format conversion is done.static int
static int
static int
static Image.ImageChannelOrder
encodeImageChannelOrder
(int order) static Image.ImageChannelType
encodeImageChannelType
(int type) static Image.ImageType
encodeImageType
(int type) fillAsync
(CommandQueue queue, long[] origin, long[] region, int[] color) Fills the image with the specified color given as four integer variables.fillAsync
(CommandQueue queue, long[] origin, long[] region, ColorRGBA color) Fills the image with the specified color.long
long
getDepth()
int
long
org.lwjgl.opencl.CLMem
getImage()
long
long
long
getWidth()
map
(CommandQueue queue, long[] origin, long[] region, MappingAccess access) Maps the image into host memory.mapAsync
(CommandQueue queue, long[] origin, long[] region, MappingAccess access) Non-blocking version ofImage.map(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess)
.void
readImage
(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch) Performs a blocking read of the image into the specified byte buffer.readImageAsync
(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch) Performs an async/non-blocking read of the image into the specified byte buffer.Releases a shared image object.void
Releases a shared image object.void
unmap
(CommandQueue queue, Image.ImageMapping mapping) Unmaps the mapped memoryvoid
writeImage
(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch) Performs a blocking write from the specified byte buffer into the image.writeImageAsync
(CommandQueue queue, ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch) Performs an async/non-blocking write from the specified byte buffer into the image.Methods inherited from class com.jme3.opencl.AbstractOpenCLObject
finalize, getReleaser, release
-
Constructor Details
-
LwjglImage
public LwjglImage(org.lwjgl.opencl.CLMem image)
-
-
Method Details
-
getImage
public org.lwjgl.opencl.CLMem getImage() -
decodeImageChannelOrder
-
encodeImageChannelOrder
-
decodeImageChannelType
-
encodeImageChannelType
-
decodeImageType
-
encodeImageType
-
getWidth
public long getWidth() -
getHeight
public long getHeight() -
getDepth
public long getDepth() -
getRowPitch
public long getRowPitch()- Specified by:
getRowPitch
in classImage
- Returns:
- the row pitch when the image was created from a host buffer
-
getSlicePitch
public long getSlicePitch()- Specified by:
getSlicePitch
in classImage
- Returns:
- the slice pitch when the image was created from a host buffer
-
getArraySize
public long getArraySize()- Specified by:
getArraySize
in classImage
- Returns:
- the number of elements in the image array
- See Also:
-
getImageFormat
- Specified by:
getImageFormat
in classImage
- Returns:
- the image format
-
getImageType
- Specified by:
getImageType
in classImage
- Returns:
- the image type
-
getElementSize
public int getElementSize()- Specified by:
getElementSize
in classImage
- 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 classImage
- Parameters:
queue
- the command queuedest
- the target byte bufferorigin
- the image origin location, see class description for the formatregion
- the copied region, see class description for the formatrowPitch
- 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 asbytesPerElement * 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 asrowPitch * 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 classImage
- Parameters:
queue
- the command queuedest
- the target byte bufferorigin
- the image origin location, see class description for the formatregion
- the copied region, see class description for the formatrowPitch
- 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 asbytesPerElement * 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 asrowPitch * 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 classImage
- Parameters:
queue
- the command queuedest
- the source bufferorigin
- the image origin location, see class description for the formatregion
- the copied region, see class description for the formatrowPitch
- 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 asbytesPerElement * 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 asrowPitch * 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 classImage
- Parameters:
queue
- the command queuedest
- the source bufferorigin
- the image origin location, see class description for the formatregion
- the copied region, see class description for the formatrowPitch
- 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 asbytesPerElement * 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 asrowPitch * 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 classImage
- Parameters:
queue
- the command queuedest
- the target imagesrcOrigin
- the source image origin, see class description for the formatdestOrigin
- the target image origin, see class description for the formatregion
- 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 classImage
- Parameters:
queue
- the command queuedest
- the target imagesrcOrigin
- the source image origin, see class description for the formatdestOrigin
- the target image origin, see class description for the formatregion
- 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 tonull
, it is needed for the async versionImage.mapAsync(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess)
.- Specified by:
map
in classImage
- Parameters:
queue
- the command queueorigin
- the image origin, see class description for the formatregion
- the mapped region, see class description for the formataccess
- 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 ofImage.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 classImage
- Parameters:
queue
- the command queueorigin
- the image origin, see class description for the formatregion
- the mapped region, see class description for the formataccess
- the allowed memory access to the mapped memory- Returns:
- a structure describing the mapped memory
- See Also:
-
unmap
Description copied from class:Image
Unmaps the mapped memory -
fillAsync
Description copied from class:Image
Fills the image with the specified color. Does only work if the image channel isImage.ImageChannelType.FLOAT
orImage.ImageChannelType.HALF_FLOAT
. -
fillAsync
Description copied from class:Image
Fills the image with the specified color given as four integer variables. Does not work if the image channel isImage.ImageChannelType.FLOAT
orImage.ImageChannelType.HALF_FLOAT
.- Specified by:
fillAsync
in classImage
- Parameters:
queue
- the command queueorigin
- the image origin, see class description for the formatregion
- the size of the region, see class description for the formatcolor
- 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 toBuffer.copyToImageAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image, long, long[], long[])
.- Specified by:
copyToBufferAsync
in classImage
- Parameters:
queue
- the command queuedest
- the target buffersrcOrigin
- the image origin, see class description for the formatsrcRegion
- the copied region, see class description for the formatdestOffset
- an offset into the target buffer- Returns:
- the event object to detect the completion of the operation
-
acquireImageForSharingAsync
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 callingImage.releaseImageForSharingAsync(com.jme3.opencl.CommandQueue)
so that OpenGL can use the image/texture/renderbuffer again.- Specified by:
acquireImageForSharingAsync
in classImage
- Parameters:
queue
- the command queue- Returns:
- the event object
-
acquireImageForSharingNoEvent
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 callingImage.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, useImage.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
.- Overrides:
acquireImageForSharingNoEvent
in classImage
- Parameters:
queue
- the command queue
-
releaseImageForSharingAsync
Description copied from class:Image
Releases a shared image object. Call this method after the image object was acquired byImage.acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.- Specified by:
releaseImageForSharingAsync
in classImage
- Parameters:
queue
- the command queue- Returns:
- the event object
-
releaseImageForSharingNoEvent
Description copied from class:Image
Releases a shared image object. Call this method after the image object was acquired byImage.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 classImage
- Parameters:
queue
- the command queue
-