cl_int
clGetSupportedImageFormats
(
| cl_context context, |
cl_mem_flags flags, | |
cl_mem_object_type image_type, | |
cl_uint num_entries, | |
cl_image_format *image_formats, | |
cl_uint *num_image_formats) |
context
A valid OpenCL context on which the image object(s) will be created.
flags
A bit-field that is used to specify allocation and usage information about
the image memory object being queried and is described in the table below.
To get a list of supported image
formats that can be read from or written to by a
kernel, flags
must be set to
CL_MEM_READ_WRITE
(get a list
of images that can be read from or written to by a kernel),
CL_MEM_READ_ONLY
(list of images
that can be read from by a kernel) or
CL_MEM_WRITE_ONLY
(list of images
that can be written to by a kernel). To get a list of
supported image formats that can be both read from and
written to by a kernel, flags
must be set
to CL_MEM_KERNEL_READ_AND_WRITE
.
cl_mem_flags | Description |
---|---|
CL_MEM_READ_WRITE
|
This flag specifies that the memory object will be read and written by a kernel. This is the default. |
CL_MEM_WRITE_ONLY
|
This flag specifies that the memory object will be written but not read by a kernel.
Reading from a buffer or image object created with
|
CL_MEM_READ_ONLY
|
This flag specifies that the memory object is a read-only memory object when used inside a kernel.
Writing to a buffer or image object created with
|
CL_MEM_USE_HOST_PTR
|
This flag is valid only if
OpenCL implementations are allowed to cache the buffer contents pointed to by
The result of OpenCL commands that operate on multiple buffer objects created with
the same
Refer to the description
of the alignment rules for
|
CL_MEM_ALLOC_HOST_PTR
|
This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory.
|
CL_MEM_COPY_HOST_PTR
|
This flag is valid only if
|
CL_MEM_HOST_WRITE_ONLY
|
This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write). This can be used to optimize write access from the host (e.g. enable write-combined allocations for memory objects for devices that communicate with the host over a system bus such as PCIe). |
CL_MEM_HOST_READ_ONLY
|
This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read).
|
CL_MEM_HOST_NO_ACCESS
|
This flag specifies that the host will not read or write the memory object.
|
image_type
Describes the image type and must be either
CL_MEM_OBJECT_IMAGE1D
,
CL_MEM_OBJECT_IMAGE1D_BUFFER
,
CL_MEM_OBJECT_IMAGE2D
,
CL_MEM_OBJECT_IMAGE3D
,
CL_MEM_OBJECT_IMAGE1D_ARRAY
or
CL_MEM_OBJECT_IMAGE2D_ARRAY
.
num_entries
Specifies the number of entries that can be returned in the memory location
given by image_formats
.
image_formats
A pointer to a memory location where the list of
supported image formats are returned. Each entry describes a
cl_image_format
structure supported by the OpenCL implementation. If
image_formats
is NULL, it is ignored.
num_image_formats
The actual number of supported image formats for a
specific context
and values specified by
flags
. If num_image_formats
is NULL,
it is ignored.
clGetSupportedImageFormats
can be used to get the list of image
formats supported by an OpenCL implementation when the following information about
an image memory object is specified:
clGetSupportedImageFormats
returns a union of image formats
supported by all devices in the context.
If CL_DEVICE_IMAGE_SUPPORT
specified in table 4.3
(see clGetDeviceInfo)
is CL_TRUE
, the values assigned to
CL_DEVICE_MAX_READ_IMAGE_ARGS
, CL_DEVICE_MAX_WRITE_IMAGE_ARGS
,
CL_DEVICE_IMAGE2D_MAX_WIDTH
, CL_DEVICE_IMAGE2D_MAX_HEIGHT
,
CL_DEVICE_IMAGE3D_MAX_WIDTH
, CL_DEVICE_IMAGE3D_MAX_HEIGHT
,
CL_DEVICE_IMAGE3D_MAX_DEPTH
and CL_DEVICE_MAX_SAMPLERS
by the
implementation must be greater than or equal to the minimum values specified in table 4.3
(see clGetDeviceInfo).
For 1D, 1D image from buffer, 2D, 3D image objects, 1D and 2D image array objects, the mandated minimum list of image formats that must be supported by all devices (that can be read from or written to by a kernel but not both) that support images is described in the table below (Table 5.8a):
num_channels |
channel_order |
channel_data_type |
read/write |
---|---|---|---|
1 |
CL_R |
CL_UNORM_INT8 |
read+write |
1 |
CL_DEPTH |
CL_UNORM_INT16 |
read+write |
2 |
CL_RG |
CL_UNORM_INT8 |
read+write |
4 |
CL_RGBA |
CL_UNORM_INT8 |
read+write |
4 |
CL_BGRA |
CL_UNORM_INT8 |
read+write |
4 |
CL_sRGBA |
CL_UNORM_INT8 |
read+write if the cl_khr_srgb_image_writes extension is supported, else read only |
1 |
CL_DEPTH_STENCIL |
CL_UNORM_INT24 |
read only (applies if the |
For 1D, 1D image from buffer, 2D, 3D image objects, 1D and 2D image array objects, the mandated minimum list of image formats that must be supported by all devices (that can be read from and written to by a kernel) that support images is described in the table below (Table 5.8b):
num_channels |
channel_order |
channel_data_type |
---|---|---|
1 |
CL_R |
CL_UNORM_INT8 |
4 |
CL_RGBA |
CL_UNORM_INT8 |
1 |
CL_DEPTH_STENCIL (applies if the |
CL_UNORM_INT24 |
For the image format given by channel order of
CL_DEPTH_STENCIL
and channel data type of
CL_UNORM_INT24
, the depth is
stored as an unsigned normalized 24-bit value.
For the image format given by channel order of
CL DEPTH_STENCIL
and channel data type of
CL_FLOAT
, each pixel is two 32-bit values.
The depth is stored as a single precision floating
point value followed by the stencil which is stored as a 8-bit integer value.
The stencil value cannot be read or written using the
read_imagef
and
write_imagef
built-in functions in an OpenCL kernel.
Depth image objects with an image channel order =
CL_DEPTH_STENCIL
cannot be used as
arguments to
clEnqueueReadImage,
clEnqueueWriteImage,
clEnqueueCopyImage,
clEnqueueCopyImageToBuffer,
clEnqueueCopyBufferToImage,
clEnqueueMapImage and
clEnqueueFillImage
and will return a CL_INVALID_OPERATION error.
Returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:
context
is not a valid context.
flags
or
image_type
are not valid, or if num_entries
is 0 and image_formats
is not NULL.