C Specification
The cl_image_ image descriptor structure describes the image type
and dimensions of an image or image array when creating an image using
clCreateImage or clCreateImageWithProperties, and is defined as:
// Provided by CL_VERSION_1_2
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;
union {
cl_mem buffer;
cl_mem mem_object;
};
} cl_image_desc;
Members
-
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_, orOBJECT_ IMAGE2D_ ARRAY CL_MEM_.OBJECT_ IMAGE3D -
image_width is the width of the image in pixels. For a 1D image, 1D image array, 2D image, or 2D image array, the image width must be greater than or equal to one and less than or equal to the value returned for
CL_DEVICE_for all devices in the context. For a 3D image, the image width must be greater than or equal to one and less than or equal to the value returned forIMAGE2D_ MAX_ WIDTH CL_DEVICE_for all devices in the context. For a 1D image buffer, the image width must be greater than or equal to one and less than or equal to the value returned forIMAGE3D_ MAX_ WIDTH CL_DEVICE_for all devices in the context.IMAGE_ MAX_ BUFFER_ SIZE -
image_height is the height of the image in pixels. It is only used if the image is a 2D image, 2D image array, or 3D image. For a 2D image or 2D image array, the image height must greater than or equal to one and less than or equal to the value returned for
CL_DEVICE_for all devices in the context. For a 3D image, the image height must be greater than or equal to one and less than or equal to the value returned forIMAGE2D_ MAX_ HEIGHT CL_DEVICE_for all devices in the context.IMAGE3D_ MAX_ HEIGHT -
image_depth is the depth of the image in pixels. It is only used if the image is a 3D image. For a 3D image, the image depth must be greater than or equal to one and less than or equal to the value returned for
CL_DEVICE_for all devices in the context.IMAGE3D_ MAX_ DEPTH -
image_array_size [1] is the number of images in the image array. It is only used if the image is a 1D image array or 2D image array. For a 1D image array or 2D image array, the image array size must be greater than or equal to one and less than or equal to the value returned for
CL_DEVICE_for all devices in the context.IMAGE_ MAX_ ARRAY_ SIZE -
image_row_pitch is the scan-line pitch in bytes. The image_row_pitch must be zero if host_ptr is
NULL, the image is not an image created from an external memory handle, and the image is not a 2D image created from a buffer.
If image_row_pitch is zero and host_ptr is notNULL, then the image row pitch is calculated as image_width times the size of an image element in bytes.
If image_row_pitch is zero and the image is created from an external memory handle, then the image row pitch is implementation-defined.
If image_row_pitch is non-zero, then it must be greater than or equal to the image_width times the size of an image element in bytes, and must be a multiple of the size of an image element in bytes.
For an image created from a buffer, the image_row_pitch must also:-
be a multiple of the
CL_IMAGE_value for the image_format, image_type, and flags used to create the image, if theREQUIREMENTS_ ROW_ PITCH_ ALIGNMENT_ EXT cl_ext_extension is supported, orimage_ requirements_ info -
be a multiple of the maximum of the
CL_DEVICE_value for all devices in the context that support images, otherwise.IMAGE_ PITCH_ ALIGNMENT
-
-
image_slice_pitch is the size in bytes of each 2D slice in a 3D image, or the size in bytes of each image in a 1D or 2D image array. The image_slice_pitch must be zero if host_ptr is
NULLand the image is not an image created from an external memory handle, If image_slice_pitch is zero and host_ptr is notNULLthen the image slice pitch is calculated as the image row pitch × image_height for a 2D image array or a 3D image, and as the image row pitch for a 1D image array. If image_slice_pitch is zero and the image is created from an external memory handle, then the image slice pitch is implementation-defined. The image slice pitch must be ≥ the image row pitch × image_height for a 2D image array or a 3D image, must be ≥ the image row pitch for a 1D image array, and must be a multiple of the image row pitch. For an image created from a buffer, the image slice pitch must be a multiple of theCL_IMAGE_value for the image_format, image_type and flags used to create the image, if theREQUIREMENTS_ SLICE_ PITCH_ ALIGNMENT_ EXT cl_ext_extension is supported.image_ from_ buffer -
num_mip_levels must be
0, indicating that the image has a single mipmap level, unless thecl_khr_extension is supported. When themipmap_ image cl_khr_extension is supported, num_mip_levels may additionally specify the total number of mipmap levels in the image, including the base level [2].mipmap_ image -
num_samples must be
0. -
mem_object may refer to a valid buffer or image memory object.
mem_objectcan be a buffer memory object ifimage_typeisCL_MEM_orOBJECT_ IMAGE1D_ BUFFER CL_MEM_, or any otherOBJECT_ IMAGE2D image_typeif thecl_ext_extension is supported. [3]image_ from_ buffer mem_objectcan be an image object ifimage_typeisCL_MEM_[4]. Otherwise it must beOBJECT_ IMAGE2D NULL. The image pixels are taken from the memory objects data store. When the contents of the specified memory objects data store are modified, those changes are reflected in the contents of the image object and vice-versa at corresponding synchronization points.
Description
For a 1D image buffer created from a buffer object, the image_width ×
size of element in bytes must be ≤ size of the buffer object.
The image data in the buffer object is stored as a single scanline which is
a linear sequence of adjacent elements.
For a 1D image created from a buffer object, the image_width × size of
element in bytes must be ≤ size of the buffer object. The image data in the
buffer object is stored as a single scanline which is a linear sequence of
adjacent elements.
For a 1D image array created from a buffer object, the image_slice_pitch ×
image_array_size must be ≤ size of the buffer object specified by mem_object.
The image data in the buffer object is stored as a linear sequence of adjacent 1D
slices. Each slice is a single scanline padded to image_slice_pitch bytes.
Each scanline is a linear sequence of image elements.
For a 2D image created from a buffer object, the image_row_pitch ×
image_height must be ≤ size of the buffer object specified by
mem_object.
The image data in the buffer object is stored as a linear sequence of
adjacent scanlines.
Each scanline is a linear sequence of image elements padded to
image_row_pitch bytes.
For a 2D image array created from a buffer object, the image_slice_pitch ×
image_array_size must be ≤ size of the buffer object specified by mem_object.
The image data in the buffer object is stored as a linear sequence of adjacent 2D
slices. Each slice is a linear sequence of adjacent scanlines padded to
image_slice_pitch bytes. Each scanline is a linear sequence of image elements padded
to image_row_pitch bytes.
For a 3D image created from a buffer object, the image_slice_pitch ×
image_depth must be ≤ size of the buffer object specified by mem_object.
The image data in the buffer object is stored as a linear sequence of adjacent 2D
slices padded to image_slice_pitch bytes. Each slice is a linear sequence of adjacent
scanlines. Each scanline is a linear sequence of image elements padded to
image_row_pitch bytes.
For an image object created from another image object, the values specified
in the image descriptor except for mem_object must match the image
descriptor information associated with mem_object.
Image elements are stored according to their image format as described in Image Format Descriptor.
If the buffer object specified by mem_object was created with
CL_MEM_, the host_ptr specified to clCreateBuffer or
clCreateBufferWithProperties must
-
Be aligned to the
CL_IMAGE_value for the returned for parameters compatible with those used to create the image, if theREQUIREMENTS_ BASE_ ADDRESS_ ALIGNMENT_ EXT cl_ext_extension is supported, orimage_ requirements_ info -
Be aligned to the maximum of the
CL_DEVICE_value for all devices in the context associated with the buffer specified byIMAGE_ BASE_ ADDRESS_ ALIGNMENT mem_objectthat support images, otherwise.
Creating a 2D image object from another 2D image object creates a new
2D image object that shares the image data store with mem_object but views
the pixels in the image with a different image channel order.
Restrictions are:
-
All of the values specified in image_desc must match the image descriptor information associated with
mem_object, except formem_object. -
The image channel data type specified in image_format must match the image channel data type associated with
mem_object. -
The image channel order specified in image_format must be compatible with the image channel order associated with
mem_object, as described in the Compatible Image Channel Orders table.
| The image channel order compatibility constraint allows creation of a sRGB view of the image from a linear RGB view or vice-versa, i.e. the pixels stored in the image can be accessed as linear RGB or sRGB values. |
| Image Channel Order in image_format: | Image Channel Order associated with mem_object: |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Concurrent reading from, writing to and copying between both a buffer object and buffer or image object associated with the buffer object is undefined. Only reading from both a buffer object and buffer or 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. |
Document Notes
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.