public abstract class Image extends AbstractOpenCLObject
Buffer
, but with a specific element
format and buffer structure.
Image.ImageDescriptor
, specifying
the extend and dimension of the image, and Image.ImageFormat
, specifying
the type of each pixel.
Context.createImage(com.jme3.opencl.MemoryAccess, com.jme3.opencl.Image.ImageFormat, com.jme3.opencl.Image.ImageDescriptor)
or from OpenGL by
Context.bindImage(com.jme3.texture.Image, com.jme3.texture.Texture.Type, int, com.jme3.opencl.MemoryAccess)
(and alternative versions).
Most methods take long arrays as input: long[] origin
and long[] region
.
Both are arrays of length 3.
origin defines the (x, y, z) offset in pixels in the 1D, 2D or 3D
image, the (x, y) offset and the image index in the 2D image array or the (x)
offset and the image index in the 1D image array. If image is a 2D image
object, origin[2] must be 0. If image is a 1D image or 1D image buffer
object, origin[1] and origin[2] must be 0. If image is a 1D image array
object, origin[2] must be 0. If image is a 1D image array object, origin[1]
describes the image index in the 1D image array. If image is a 2D image array
object, origin[2] describes the image index in the 2D image array.
region defines the (width, height, depth) in pixels of the 1D, 2D or
3D rectangle, the (width, height) in pixels of the 2D rectangle and the
number of images of a 2D image array or the (width) in pixels of the 1D
rectangle and the number of images of a 1D image array. If image is a 2D
image object, region[2] must be 1. If image is a 1D image or 1D image buffer
object, region[1] and region[2] must be 1. If image is a 1D image array
object, region[2] must be 1. The values in region cannot be 0.
Modifier and Type | Class and Description |
---|---|
static class |
Image.ImageChannelOrder
ImageChannelOrder specifies the number of channels and the channel layout i.e. |
static class |
Image.ImageChannelType
ImageChannelType describes the size of the channel data type. |
static class |
Image.ImageDescriptor
The image descriptor structure describes the type and dimensions of the image or image array.
|
static class |
Image.ImageFormat
Describes the image format, consisting of
Image.ImageChannelOrder and Image.ImageChannelType . |
static class |
Image.ImageMapping
Describes a mapped region of the image
|
static class |
Image.ImageType
The possible image types / dimensions.
|
OpenCLObject.ObjectReleaser
releaser
Modifier | Constructor and Description |
---|---|
protected |
Image(OpenCLObject.ObjectReleaser releaser) |
Modifier and Type | Method and Description |
---|---|
abstract Event |
acquireImageForSharingAsync(CommandQueue queue)
Acquires this image object for using.
|
void |
acquireImageForSharingNoEvent(CommandQueue queue)
Acquires this image object for using.
|
abstract void |
copyTo(CommandQueue queue,
Image dest,
long[] srcOrigin,
long[] destOrigin,
long[] region)
Performs a blocking copy operation from one image to another.
|
abstract Event |
copyToAsync(CommandQueue queue,
Image dest,
long[] srcOrigin,
long[] destOrigin,
long[] region)
Performs an async/non-blocking copy operation from one image to another.
|
abstract Event |
copyToBufferAsync(CommandQueue queue,
Buffer dest,
long[] srcOrigin,
long[] srcRegion,
long destOffset)
Copies this image into the specified buffer, no format conversion is done.
|
abstract Event |
fillAsync(CommandQueue queue,
long[] origin,
long[] region,
ColorRGBA color)
Fills the image with the specified color.
|
abstract Event |
fillAsync(CommandQueue queue,
long[] origin,
long[] region,
int[] color)
Fills the image with the specified color given as four integer variables.
|
abstract long |
getArraySize() |
abstract long |
getDepth() |
abstract int |
getElementSize() |
abstract long |
getHeight() |
abstract Image.ImageFormat |
getImageFormat() |
abstract Image.ImageType |
getImageType() |
abstract long |
getRowPitch() |
abstract long |
getSlicePitch() |
abstract long |
getWidth() |
abstract Image.ImageMapping |
map(CommandQueue queue,
long[] origin,
long[] region,
MappingAccess access)
Maps the image into host memory.
|
abstract Image.ImageMapping |
mapAsync(CommandQueue queue,
long[] origin,
long[] region,
MappingAccess access)
Non-blocking version of
map(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess) . |
abstract void |
readImage(CommandQueue queue,
java.nio.ByteBuffer dest,
long[] origin,
long[] region,
long rowPitch,
long slicePitch)
Performs a blocking read of the image into the specified byte buffer.
|
abstract Event |
readImageAsync(CommandQueue queue,
java.nio.ByteBuffer dest,
long[] origin,
long[] region,
long rowPitch,
long slicePitch)
Performs an async/non-blocking read of the image into the specified byte buffer.
|
Image |
register()
Registers this object for automatic releasing on garbage collection.
|
abstract Event |
releaseImageForSharingAsync(CommandQueue queue)
Releases a shared image object.
|
void |
releaseImageForSharingNoEvent(CommandQueue queue)
Releases a shared image object.
|
java.lang.String |
toString() |
abstract void |
unmap(CommandQueue queue,
Image.ImageMapping mapping)
Unmaps the mapped memory
|
abstract void |
writeImage(CommandQueue queue,
java.nio.ByteBuffer src,
long[] origin,
long[] region,
long rowPitch,
long slicePitch)
Performs a blocking write from the specified byte buffer into the image.
|
abstract Event |
writeImageAsync(CommandQueue queue,
java.nio.ByteBuffer src,
long[] origin,
long[] region,
long rowPitch,
long slicePitch)
Performs an async/non-blocking write from the specified byte buffer into the image.
|
finalize, getReleaser, release
protected Image(OpenCLObject.ObjectReleaser releaser)
public Image register()
OpenCLObject
OpenCLObjectManager
, you have to release it manually
by calling OpenCLObject.release()
.
Without registering or releasing, a memory leak might occur.
this
to allow calls like
Buffer buffer = clContext.createBuffer(1024).register();
.register
in interface OpenCLObject
register
in class AbstractOpenCLObject
this
public abstract long getWidth()
public abstract long getHeight()
public abstract long getDepth()
public abstract long getRowPitch()
public abstract long getSlicePitch()
public abstract long getArraySize()
Image.ImageType.IMAGE_1D_ARRAY
,
Image.ImageType.IMAGE_2D_ARRAY
public abstract Image.ImageFormat getImageFormat()
public abstract Image.ImageType getImageType()
public abstract int getElementSize()
public abstract void readImage(CommandQueue queue, java.nio.ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
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 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
public abstract Event readImageAsync(CommandQueue queue, java.nio.ByteBuffer dest, long[] origin, long[] region, long rowPitch, long slicePitch)
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 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
public abstract void writeImage(CommandQueue queue, java.nio.ByteBuffer src, long[] origin, long[] region, long rowPitch, long slicePitch)
queue
- the command queuesrc
- 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 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
public abstract Event writeImageAsync(CommandQueue queue, java.nio.ByteBuffer src, long[] origin, long[] region, long rowPitch, long slicePitch)
queue
- the command queuesrc
- 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 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
public abstract void copyTo(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region)
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 formatpublic abstract Event copyToAsync(CommandQueue queue, Image dest, long[] srcOrigin, long[] destOrigin, long[] region)
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 formatpublic abstract Image.ImageMapping map(CommandQueue queue, long[] origin, long[] region, MappingAccess access)
null
, it is needed for the async
version mapAsync(com.jme3.opencl.CommandQueue, long[], long[], com.jme3.opencl.MappingAccess)
.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 memoryunmap(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image.ImageMapping)
public abstract Image.ImageMapping mapAsync(CommandQueue queue, long[] origin, long[] region, MappingAccess access)
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.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 memoryunmap(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image.ImageMapping)
public abstract void unmap(CommandQueue queue, Image.ImageMapping mapping)
queue
- the command queuemapping
- the mapped memorypublic abstract Event fillAsync(CommandQueue queue, long[] origin, long[] region, ColorRGBA color)
Image.ImageChannelType.FLOAT
or Image.ImageChannelType.HALF_FLOAT
.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 fillpublic abstract Event fillAsync(CommandQueue queue, long[] origin, long[] region, int[] color)
Image.ImageChannelType.FLOAT
or Image.ImageChannelType.HALF_FLOAT
.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 4public abstract Event copyToBufferAsync(CommandQueue queue, Buffer dest, long[] srcOrigin, long[] srcRegion, long destOffset)
Buffer.copyToImageAsync(com.jme3.opencl.CommandQueue, com.jme3.opencl.Image, long, long[], long[])
.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 bufferpublic abstract Event acquireImageForSharingAsync(CommandQueue queue)
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
releaseImageForSharingAsync(com.jme3.opencl.CommandQueue)
so that OpenGL can use the image/texture/renderbuffer again.queue
- the command queuepublic void acquireImageForSharingNoEvent(CommandQueue queue)
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
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
acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
.queue
- the command queuepublic abstract Event releaseImageForSharingAsync(CommandQueue queue)
acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.queue
- the command queuepublic void releaseImageForSharingNoEvent(CommandQueue queue)
acquireImageForSharingAsync(com.jme3.opencl.CommandQueue)
to hand the control back to OpenGL.
The generated event object is directly released, resulting in
performance improvements.queue
- the command queuepublic java.lang.String toString()
toString
in class java.lang.Object