sampler 用法 OpenCL
2016-06-14 23:18
330 查看
sampler_t
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> |
Description
The image read functions take a sampler argument. The sampler can be passed as an argument to the kernel using clSetKernelArg,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 read_image{f|i|ui}.
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 |
---|---|
<normalized coords> | Specifies whether the x, yand zcoordinates are passed in as normalized or unnormalized values. This must be one of the following predefined enums: CLK_NORMALIZED_COORDS_TRUE or CLK_NORMALIZED_COORDS_FALSE. In OpenCL 1.0, the samplers specified with an image in multiple read_image{f|i|ui}calls declared in a kernel must use the same value for <normalized coords>. |
<address mode> | 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 address modecan only be used with normalized coordinates. If normalized coordinates are not used, this addressing mode may generate image coordinates that are undefined. 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 ( 0.0f, 0.0f, 0.0f, 0.0f) if image channel order is CL_A, CL_INTENSITY, CL_RA, CL_ARGB, CL_BGRA or CL_RGBA and is ( 0.0f, 0.0f, 0.0f, 1.0f) if image channel order is CL_R, CL_RG, CL_RGB or CL_LUMINANCE. 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. |
<filter mode> | 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 OpenCL specification for a description of these filtering modes. |
A sampler argument to a __kernel function cannot be modified.
Notes
The maximum number of samplers that can be declared in a kernel can be queried using the CL_DEVICE_MAX_SAMPLERStoken in the table of OpenCL Device Queries for clGetDeviceInfo.
Example
const sampler_t samplerA = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_REPEAT | CLK_FILTER_NEAREST; |
相关文章推荐
- shell脚本应用(一)
- Docker CentOS7 LNMP环境yum方式安装
- PHP 开发学习[4] —— 学习参考网站
- HA的简介与配置
- tomcat配置虚拟主机
- linux下SVN忽略文件/文件夹的方法
- 企业如何准备企业网站建设资料
- 访问列表框select中option选项
- linux之条件判断
- Linux - 管道
- Linux Heartbeat 安装与配置总结
- openwrt编译环境搭建
- 做了一个网站
- 做了一个网站
- 做了一个网站
- shell脚本学习
- 虚拟机安装CentOS以及SecureCRT设置【完美无错版】
- GDB调试手册
- Linux中的task,process, thread 简介
- Java Ide配置tomcat和maven