本文共 3257 字,大约阅读时间需要 10 分钟。
A type used to control how elements of a 2D or 3D image object are read by read_image{f|i|ui}
.
const sampler_t <sampler name> = <value> |
The image read functions take a sampler argument. The sampler can be passed as an argument to the kernel using , or it can be a constant variable of type sampler_t declared in the program source.
Sampler variables in a program are declared to be of type sampler_t. The sampler_t type is a 32-bit unsigned int constant and is interpreted as a bit-field that specifies the following properties:
Addressing Mode
Filter Mode
Normalized Coordinates
These properties control how elements of a 2D or 3D image object are read by .
Samplers can also be declared as global constants in the program source using the syntax shown at the top of this page.
The sampler fields are described in the table below:
Sampler State | Description |
---|---|
| Specifies whether the
CLK_NORMALIZED_COORDS_TRUE or CLK_NORMALIZED_COORDS_FALSE.
In OpenCL 1.0, the samplers specified with an image in multiple |
| Specifies the image addressing-mode i.e. how out-of-range image coordinates are handled. This must be a literal value and can be one of the following predefined enums: CLK_ADDRESS_REPEAT - out-of-range image coordinates are wrapped to the valid range. This CLK_ADDRESS_CLAMP_TO_EDGE - out-of-range image coordinates are clamped to the extent. CLK_ADDRESS_CLAMP32 - out-of-range image coordinates will return a border color. The border color is ( CLK_ADDRESS_NONE - for this address mode the programmer guarantees that the image coordinates used to sample elements of the image refer to a location inside the image; otherwise the results are undefined. |
| Specifies the filtering mode to use. This must be a literal value and can be one of the following predefined enums: CLK_FILTER_NEAREST or CLK_FILTER_LINEAR. Refer to section on Image Addressing and Filtering in the for a description of these filtering modes. |
Samplers cannot be declared as arrays, pointers, or be used as the type for local variables inside a function or as the return value of a function defined in a program. Samplers cannot be passed as arguments to functions called by a function. A sampler argument to a function cannot be modified.
The maximum number of samplers that can be declared in a kernel can be queried using the CL_DEVICE_MAX_SAMPLERS
token in the table of OpenCL Device Queries for .
const sampler_t samplerA = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_REPEAT | CLK_FILTER_NEAREST; |
samplerA specifies a sampler that uses normalized coordinates, the repeat addressing mode and a nearest filter.
转载地址:http://htiqb.baihongyu.com/