C Specification

To get information specific to an image object created with clCreateImage, clCreateImageWithProperties, clCreateImage2D, or clCreateImage3D call the function

cl_int clGetImageInfo(
    cl_mem image,
    cl_image_info param_name,
    size_t param_value_size,
    void* param_value,
    size_t* param_value_size_ret);

Parameters

  • image specifies the image object being queried.

  • param_name specifies the information to query. The list of supported param_name types and the information returned in param_value by clGetImageInfo is described in the Image Object Queries table.

  • param_value is a pointer to memory where the appropriate result being queried is returned. If param_value is NULL, it is ignored.

  • param_value_size is used to specify the size in bytes of memory pointed to by param_value. This size must be ≥ size of return type as described in the Image Object Queries table.

  • param_value_size_ret returns the actual size in bytes of data being queried by param_name. If param_value_size_ret is NULL, it is ignored.

Description

Table 1. List of supported param_names by clGetImageInfo
Image Info Return type Description

CL_IMAGE_FORMAT

cl_image_format

Return the image format descriptor specified when image is created with clCreateImage, clCreateImageWithProperties, clCreateImage2D or clCreateImage3D.

CL_IMAGE_ELEMENT_SIZE

size_t

Return size of each element of the image memory object given by image in bytes.

CL_IMAGE_ROW_PITCH

size_t

Returns the row pitch in bytes of a row of elements of the image object given by image.
If image was created with a non-zero value for image_row_pitch, then the value provided for image_row_pitch by the application is returned, otherwise the returned value is calculated as CL_IMAGE_WIDTH × CL_IMAGE_ELEMENT_SIZE.

CL_IMAGE_SLICE_PITCH

size_t

Returns the slice pitch in bytes of a 2D slice for the 3D image object or size of each image in a 1D or 2D image array given by image.
If image was created with a non-zero value for image_slice_pitch then the value provided for image_slice_pitch by the application is returned, otherwise the returned value is calculated as:
- CL_IMAGE_ROW_PITCH for 1D image arrays.
- CL_IMAGE_HEIGHT × CL_IMAGE_ROW_PITCH for 3D images and 2D image arrays.
For a 1D image, 1D image buffer and 2D image object return 0.

CL_IMAGE_WIDTH

size_t

Return width of the image in pixels.

CL_IMAGE_HEIGHT

size_t

Return height of the image in pixels. For a 1D image, 1D image buffer and 1D image array object, height = 0.

CL_IMAGE_DEPTH

size_t

Return depth of the image in pixels. For a 1D image, 1D image buffer, 2D image or 1D and 2D image array object, depth = 0.

CL_IMAGE_ARRAY_SIZE

missing before version 1.2.

size_t

Return number of images in the image array. If image is not an image array, 0 is returned.

CL_IMAGE_BUFFER

missing before version 1.2 and deprecated by version 2.0.

cl_mem

Return buffer object associated with image.

CL_IMAGE_NUM_MIP_LEVELS

missing before version 1.2.

cl_uint

Return num_mip_levels associated with image.

CL_IMAGE_NUM_SAMPLES

missing before version 1.2.

cl_uint

Return num_samples associated with image.

clGetImageInfo returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns one of the following errors:

  • CL_INVALID_VALUE if param_name is not valid, or if size in bytes specified by param_value_size is < size of return type as described in the Image Object Queries table and param_value is not NULL.

  • CL_INVALID_MEM_OBJECT if image is a not a valid image object.

  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

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.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0