C Specification

To get information specific to an image object created with clCreateImage, 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 https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_API.html#clGetImageInfo
cl_image_info Return type Info. returned in param_value

CL_​IMAGE_​FORMAT

cl_image_format

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

CL_​IMAGE_​ELEMENT_​SIZE

size_t

Return size of each element of the image memory object given by image in bytes. An element is made up of n channels. The value of n is given in cl_image_format descriptor.

CL_​IMAGE_​ROW_​PITCH

size_t

Return calculated row pitch in bytes of a row of elements of the image object given by image.

CL_​IMAGE_​SLICE_​PITCH

size_t

Return calculated 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. 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 (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.