【CUDA学习笔记】3.纹理引用API
来源:互联网 发布:淘宝食品店铺运营技巧 编辑:程序博客网 时间:2024/06/12 01:53
纹理引用API
纹理引用是编译时确定的(相对于纹理对象的运行时确定),私以为大概就对应着面向过程的编程方式(C)以及面向对象的编程方式(C++)。
CUDA programing guide里给的例子:
texture<DataType, Type, ReadMode> texRef;
很好懂,DataType就是指定纹理中的数据元素的类型;
Type是纹理引用的类型,包括一维纹理cudaTextureType1D,二维纹理cudaTextureType2D,和三维纹理cudaTextureType3D,另外还有一维层次纹理cudaTextureType1DLayered和二维层次纹理cudaTextureType2DLayered,。Type的类型是可选的,默认情况下是cudaTextureType1D。
readMode和纹理对象中的是一样的,默认是cudaReadModeElementType。
纹理引用只能声明为全局静态变量,不能作为函数参数传递。
纹理引用的其他特征是可以通过主机运行时改变的。CUDA参考手册中说明了运行时的API拥有一个高级的接口(C++风格的)和一个低级的接口(C风格的)。其中texture类型就是在高级API中定义的数据结构,它由低级API中的textureReference结构继承而来。
可以在CUDA API中找到其定义:
struct __device_builtin__ textureReference
{
/**
* Indicates whether texture reads are normalized or not
*/
int normalized;
/**
* Texture filter mode
*/
enum cudaTextureFilterMode filterMode;
/**
* Texture address mode for up to 3 dimensions
*/
enum cudaTextureAddressMode addressMode[3];
/**
* Channel descriptor for the texture reference
*/
struct cudaChannelFormatDesc channelDesc;
/**
* Perform sRGB->linear conversion during texture read
*/
int sRGB;
/**
* Limit to the anisotropy ratio
*/
unsigned int maxAnisotropy;
/**
* Mipmap filter mode
*/
enum cudaTextureFilterMode mipmapFilterMode;
/**
* Offset applied to the supplied mipmap level
*/
float mipmapLevelBias;
/**
* Lower end of the mipmap level range to clamp access to
*/
float minMipmapLevelClamp;
/**
* Upper end of the mipmap level range to clamp access to
*/
float maxMipmapLevelClamp;
int __cudaReserved[15];
};
这与纹理对象中使用的struct cudaTeextureDesc结构类似,都是定义纹理的一些特征。
纹理引用将纹理以绑定的形式与cuda数组或线性空间绑定在一起。
绑定到数组:cudaBindTextureToArray(&texRef, de_arr,&channel_format);
绑定到现行空间:cudaBindTexture2D(&offset, texRef, devPtr, channelDesc,width, height, pitch);
- 【CUDA学习笔记】3.纹理引用API
- 【cuda学习笔记】2.纹理对象API的使用,实现sobel边缘检测
- 【CUDA学习笔记】纹理操作细节
- 【CUDA学习笔记】1.纹理内存
- CUDA学习之纹理内存
- CUDA driver API学习
- CUDA 学习(十四)、纹理内存
- D3D学习笔记:纹理
- OpenGL学习笔记:纹理
- 学习笔记:多重纹理
- 学习笔记:多重纹理
- CUDA基础学习笔记
- CUDA学习笔记
- cuda学习笔记
- CUDA学习笔记
- CUDA学习笔记
- CUDA学习笔记(1)
- CUDA学习笔记
- Android屏幕适配及DisplayMetrics解析
- RESET MASTER 和RESET SLAVE区别
- Type interface dxm.com.mapper.UserMapperI is already known to the MapperRegistry.
- Xcode 8.0无法注释的问题
- CODEVS 1380没有上司的舞会
- 【CUDA学习笔记】3.纹理引用API
- Redis-(Command.java)命令类
- Coursera Machine Learning 第五周 quiz Programming Exercise 4: Neural Networks Learning
- There are no resources that can be added or removed from the server...解决办法
- python学习笔记 进程和线程
- codevs1384黑色星期五【USACO】
- 实战c++中的vector系列--正确释放vector的内存(clear(), swap(), shrink_to_fit())
- linux下获得本地真实IP地址,非127.0.0.1
- CentOS 7 安装Mariadb 及详解