The image descriptor structure describes the type and dimensions of the image or image array and is defined as:
typedef struct _cl_image_desc { cl_mem_object_type image_type; size_t image_width; size_t image_height; size_t image_depth; size_t image_array_size; size_t image_row_pitch; size_t image_slice_pitch; cl_uint num_mip_levels; cl_uint num_samples; cl_mem buffer; } cl_image_desc;
- image_type
-
Describes the image type and must be either
CL_MEM_OBJECT_IMAGE1D
,CL_MEM_OBJECT_IMAGE1D_BUFFER
,CL_MEM_OBJECT_IMAGE1D_ARRAY
,CL_MEM_OBJECT_IMAGE2D
,CL_MEM_OBJECT_IMAGE2D_ARRAY
, orCL_MEM_OBJECT_IMAGE3D
. - image_width
-
The width of the image in pixels. For a 2D image and image array, the image width must be a value >= 1 and ≤
CL_DEVICE_IMAGE2D_MAX_WIDTH
. For a 3D image, the image width must be a value ≥ 1 and ≤CL_DEVICE_IMAGE3D_MAX_WIDTH
. For a 1D image buffer, the image width must be a value ≥ 1 and ≤CL_DEVICE_IMAGE_MAX_BUFFER_SIZE
. For a 1D image and 1D image array, the image width must be a value ≥ 1 and ≤CL_DEVICE_IMAGE2D_MAX_WIDTH
. - image_height
-
The height of the image in pixels. This is only used if the image is a 2D or 3D image, or a 2D image array. For a 2D image or image array, the image height must be a value ≥ 1 and ≤
CL_DEVICE_IMAGE2D_MAX_HEIGHT
. For a 3D image, the image height must be a value ≥ 1 and ≤CL_DEVICE_IMAGE3D_MAX_HEIGHT
. - image_depth
-
The depth of the image in pixels. This is only used if the image is a 3D image and must be a value ≥ 1 and ≤
CL_DEVICE_IMAGE3D_MAX_DEPTH
. - image_array_size
-
The number of images in the image array. This is only used if the image is a 1D or 2D image array. The values for
image_array_size
, if specified, must be a value ≥ 1 and ≤CL_DEVICE_IMAGE_MAX_ARRAY_SIZE
.Note that reading and writing 2D image arrays from a kernel with
image_array_size
= 1 may be lower performance than 2D images. - image_row_pitch
-
The scan-line pitch in bytes. This must be 0 if
host_ptr
is NULL and can be either 0 or ≥image_width
* size of element in bytes ifhost_ptr
is not NULL. Ifhost_ptr
is not NULL andimage_row_pitch
= 0,image_row_pitch
is calculated asimage_width
* size of element in bytes. Ifimage_row_pitch
is not 0, it must be a multiple of the image element size in bytes. For a 2D image created from a buffer, the pitch specified (or computed if pitch specified is 0) must be a multiple of the maximum of theCL_DEVICE_IMAGE_PITCH_ALIGNMENT
value for all devices in the context associated withimage_desc→mem_object
and that support images. - image_slice_pitch
-
The size in bytes of each 2D slice in the 3D image or the size in bytes of each image in a 1D or 2D image array. This must be 0 if
host_ptr
is NULL. Ifhost_ptr
is not NULL,image_slice_pitch
can be either 0 or ≥image_row_pitch
*image_height
for a 2D image array or 3D image and can be either 0 or ≥image_row_pitch
for a 1D image array. Ifhost_ptr
is not NULL andimage_slice_pitch
= 0,image_slice_pitch
is calculated asimage_row_pitch
*image_height
for a 2D image array or 3D image andimage_row_pitch
for a 1D image array. Ifimage_slice_pitch
is not 0, it must be a multiple of theimage_row_pitch
. - num_mip_levelnum_samples
-
Must be 0.
- mem_object
-
Refers to a valid buffer or image memory object.
mem_object
can be a buffer memory object if image_type isCL_MEM_OBJECT_IMAGE1D_BUFFER
orCL_MEM_OBJECT_IMAGE2D
(To create a 2D image from a buffer object that share the data store between the image and buffer object) .mem_object
can be a image object ifimage_type
isCL_MEM_OBJECT_IMAGE2D
(To create an image object from another image object that share the data store between these image objects). Otherwise it must be NULL. The image pixels are taken from the memory object’s data store. When the contents of the specified memory object’s data store are modified, those changes are reflected in the contents of the image object and vice-versa at corresponding sychronization points. For a 1D image buffer object, theimage_width
* size of element in bytes must be ≤ size of buffer object data store. For a 2D image created from a buffer, theimage_row_pitch * image_height
must be ≤ size of buffer object data store. For an image object created from another image object, the values specified in the image descriptor except formem_object
must match the image descriptor information associated withmem_object
.
Concurrent reading from, writing to and copying between both a buffer object and 1D image buffer or 2D image object associated with the buffer object is undefined. Only reading from both a buffer object and 1D image buffer or 2D image object associated with the buffer object is defined.
Writing to an image created from a buffer and then reading from this buffer in a kernel even if appropriate synchronization operations (such as a barrier) are performed between the writes and reads is undefined. Similarly, writing to the buffer and reading from the image created from this buffer with appropriate synchronization between the writes and reads is undefined.