博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sampler 用法 OpenCL
阅读量:2442 次
发布时间:2019-05-10

本文共 3257 字,大约阅读时间需要 10 分钟。

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

<normalized coords>

Specifies whether the xy and z coordinates 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 mode can 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.0f0.0f0.0f0.0f) if image channel order is CL_A, CL_INTENSITY, CL_RA, CL_ARGB, CL_BGRA or CL_RGBA and is (0.0f0.0f0.0f1.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  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.

Notes

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 .

Example

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/

你可能感兴趣的文章
express 模板引擎_了解Express模板引擎
查看>>
如何在CentOS 8上安装Node.js
查看>>
如何在Ubuntu 20.04上安装Git
查看>>
javascript深度图_在JavaScript中深度克隆对象(及其工作方式)
查看>>
centos ssh密钥_如何在CentOS 8上设置SSH密钥
查看>>
debian 10 安装_如何在Debian 10上安装Webmin
查看>>
使用CentOS 8进行初始服务器设置
查看>>
ecmascript v3_节点v12中的新ECMAScript模块简介
查看>>
盖茨比乔布斯_通过盖茨比使用Airtable
查看>>
mern技术栈好处?_如何开始使用MERN堆栈
查看>>
路由器接路由器_路由器之战:到达路由器vsReact路由器
查看>>
rxjs 搜索_如何使用RxJS构建搜索栏
查看>>
如何在Debian 10上安装MariaDB
查看>>
go函数的可变长参数_如何在Go中使用可变参数函数
查看>>
debian 服务器_使用Debian 10进行初始服务器设置
查看>>
joi 参数验证_使用Joi进行节点API架构验证
查看>>
react-notifications-component,一个强大的React Notifications库
查看>>
如何在Debian 10上设置SSH密钥
查看>>
如何在Debian 10上安装Node.js
查看>>
angular4前后端分离_如何在Angular 4+中使用Apollo客户端GraphQL
查看>>