Samplers

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. ...

Get OpenCL Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.