One of the parameters passed to read_image
and write_image
built-ins is the image sampler object. Sampler variables in a program are declared to be of type sampler_t
and enable the read and write routines to sample an input pixel value. The samplers are created inside a kernel by using the OR operator for the normalized coordinates, the addressing modes, and the filtering modes. Example is as follows:
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
Normalized coordinates can be set to either of the following two:
CLK_NORMALIZED_COORDS_TRUE
: The pixel coordinate values are in the range of 0 to 1.0.CLK_NORMALIZED_COORDS_FALSE
: The pixel coordinate values will be having an extent of image dimensions. That is 0 for Height - 1 and 0 for WIDTH - 1. The following diagram shows a 3D-coordinate system when it is normalized or non-normalized:
The addressing mode can be one of: CLK_ADDRESS_MIRRORED_REPEAT
, CLK_ADDRESS_REPEAT
, CLK_ADDRESS_CLAMP_TO_EDGE...