码迷,mamicode.com
首页 > 其他好文 > 详细

CUDA C Programming Guide 在线教程学习笔记 Part 6

时间:2017-11-12 01:01:41      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:模式   ***   mapr   ogr   art   算法   texture   uid   ext   

? 纹理内存读取函数

  1 /****************************************************************/
  2  
  3 // Texture Object API
  4  
  5 /****************************************************************/
  6 
  7 template<class T>                               
  8 T tex1Dfetch(cudaTextureObject_t texObj, int x);
  9     // 一维纹理,整数下标。只用于非正规化坐标,挤压模式或边界模式,不能滤波
 10 
 11 template<class T>
 12 T tex1D(cudaTextureObject_t texObj, float x);
 13     // 一维纹理,浮点数下标
 14 
 15 template<class T>
 16 T tex1DLod(cudaTextureObject_t texObj, float x, float level);
 17     // 一维纹理,基于 level-of-detail(层次细节)算法
 18 
 19 template<class T>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
 20 T tex1DGrad(cudaTextureObject_t texObj, float x, float dx, float dy);
 21     // 一维纹理,基于 gradients(梯度)算法
 22 
 23 template<class T>
 24 T tex2D(cudaTextureObject_t texObj, float x, float y);
 25     // 二维纹理
 26 
 27 template<class T>
 28 tex2DLod(cudaTextureObject_t texObj, float x, float y, float level);
 29     // 二维纹理,基于 level-of-detail(层次细节)算法
 30 
 31 template<class T>
 32 T tex2DGrad(cudaTextureObject_t texObj, float x, float y,float2 dx, float2 dy);
 33     // 二维纹理,基于 gradients(梯度)算法
 34 
 35 template<class T>
 36 T tex3D(cudaTextureObject_t texObj, float x, float y, float z);
 37     // 三维纹理
 38 
 39 template<class T>
 40 T tex3DLod(cudaTextureObject_t texObj, float x, float y, float z, float level);
 41     // 三维纹理,基于 level-of-detail(层次细节)算法
 42 
 43 template<class T>
 44 T tex3DGrad(cudaTextureObject_t texObj, float x, float y, float z,float4 dx, float4 dy);
 45     // 三维纹理,基于 gradients(梯度)算法 
 46 
 47 template<class T>
 48 T tex1DLayered(cudaTextureObject_t texObj, float x, int layer);
 49     // 一维分层纹理
 50 
 51 template<class T>
 52 T tex1DLayeredLod(cudaTextureObject_t texObj, float x, int layer, float level);
 53     // 一维分层纹理,基于 level-of-detail(层次细节)算法
 54 
 55 template<class T>
 56 T tex1DLayeredGrad(cudaTextureObject_t texObj, float x, int layer, float dx, float dy);
 57     // 一维分层纹理,基于 gradients(梯度)算法
 58 
 59 template<class T>
 60 T tex2DLayered(cudaTextureObject_t texObj, float x, float y, int layer);
 61     // 二维分层纹理
 62 
 63 template<class T>
 64 T tex2DLayeredLod(cudaTextureObject_t texObj, float x, float y, int layer, float level);
 65     // 二维分层纹理,基于 level-of-detail(层次细节)算法
 66 
 67 template<class T>
 68 T tex2DLayeredGrad(cudaTextureObject_t texObj, float x, float y, int layer, float2 dx, float2 dy);
 69     // 二维分层纹理,基于 gradients(梯度)算法
 70 
 71 template<class T>
 72 T texCubemap(cudaTextureObject_t texObj, float x, float y, float z);
 73     // 立方体贴图纹理
 74 
 75 template<class T>
 76 T texCubemapLod(cudaTextureObject_t texObj, float x, float, y, float z, float level);
 77     // 立方体贴图纹理,基于 level-of-detail(层次细节)算法
 78 
 79 template<class T>
 80 T texCubemapLayered(cudaTextureObject_t texObj, float x, float y, float z, int layer);
 81     // 立方体分层贴图纹理
 82 
 83 template<class T>
 84 T texCubemapLayeredLod(cudaTextureObject_t texObj, float x, float y, float z, int layer, float level);
 85     // 立方分层体贴图纹理,基于 level-of-detail(层次细节)算法 
 86 
 87 template<class T>
 88 T tex2Dgather(cudaTextureObject_t texObj, float x, float y, int comp = 0);
 89     //
 90 
 91 /****************************************************************/
 92 
 93 // Texture Object API
 94 
 95 /****************************************************************/
 96 
 97 template<class DataType>
 98 Type tex1Dfetch(texture<DataType, cudaTextureType1D, cudaReadModeElementType> texRef, int x);
 99 
100 float tex1Dfetch(texture<unsigned char, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
101 float tex1Dfetch(texture<signed char, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x); 
102 float tex1Dfetch(texture<unsigned short, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
103 float tex1Dfetch(texture<signed short, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
104     // 一维纹理,整数下标。只用于非正规化坐标,挤压模式或边界模式,不能滤波
105 
106 // 2元组,4元组也可以使用这种方法,例如:
107 float4 tex1Dfetch(texture<uchar2, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
108 float4 tex1Dfetch(texture<uchar4, cudaTextureType1D, cudaReadModeNormalizedFloat> texRef, int x);
109 
110 // 其他函数名类似 Texture Object API
111 template<class DataType, enum cudaTextureReadMode readMode>
112 Type tex1D(texture<DataType, cudaTextureType1D, readMode> texRef, float x); 
113 
114 template<class DataType, enum cudaTextureReadMode readMode>
115 Type tex1DLod(texture<DataType, cudaTextureType1D, readMode> texRef, float x, float level);
116 
117 template<class DataType, enum cudaTextureReadMode readMode>
118 Type tex1DGrad(texture<DataType, cudaTextureType1D, readMode> texRef, float x, float dx, float dy);
119 
120 template<class DataType, enum cudaTextureReadMode readMode>
121 Type tex2D(texture<DataType, cudaTextureType2D, readMode> texRef,float x, float y);
122 
123 template<class DataType, enum cudaTextureReadMode readMode>
124 Type tex2DLod(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, float level);
125 
126 template<class DataType, enum cudaTextureReadMode readMode>
127 Type tex2DGrad(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, float2 dx, float2 dy);
128 
129 template<class DataType, enum cudaTextureReadMode readMode>
130 Type tex3D(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z);
131 
132 template<class DataType, enum cudaTextureReadMode readMode>
133 Type tex3DLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float level);
134 
135 template<class DataType, enum cudaTextureReadMode readMode>
136 Type tex3DGrad(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float4 dx, float4 dy);
137 
138 template<class DataType, enum cudaTextureReadMode readMode>
139 Type tex1DLayered(texture<DataType, cudaTextureType1DLayered, readMode> texRef, float x, int layer);
140 
141 template<class DataType, enum cudaTextureReadMode readMode>
142 Type tex1DLayeredLod(texture<DataType, cudaTextureType1D, readMode> texRef, float x, int layer, float level);
143 
144 template<class DataType, enum cudaTextureReadMode readMode>
145 Type tex1DLayeredGrad(texture<DataType, cudaTextureType1D, readMode> texRef, float x, int layer, float dx, float dy);
146 
147 template<class DataType, enum cudaTextureReadMode readMode>
148 Type tex2DLayered(texture<DataType, cudaTextureType2DLayered, readMode> texRef, float x, float y, int layer);
149 
150 template<class DataType, enum cudaTextureReadMode readMode>
151 Type tex2DLayeredLod(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int layer, float level);
152 
153 template<class DataType, enum cudaTextureReadMode readMode>
154 Type tex2DLayeredGrad(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int layer, float2 dx, float2 dy);
155 
156 template<class DataType, enum cudaTextureReadMode readMode>
157 Type texCubemap(texture<DataType, cudaTextureTypeCubemap, readMode> texRef, float x, float y, float z);
158 
159 template<class DataType, enum cudaTextureReadMode readMode>
160 Type texCubemapLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, float level);
161 
162 template<class DataType, enum cudaTextureReadMode readMode>
163 Type texCubemapLayered(texture<DataType, cudaTextureTypeCubemapLayered, readMode> texRef, float x, float y, float z, int layer);
164 
165 template<class DataType, enum cudaTextureReadMode readMode>
166 Type texCubemapLayeredLod(texture<DataType, cudaTextureType3D, readMode> texRef, float x, float y, float z, int layer, float level);
167 
168 template<class DataType, enum cudaTextureReadMode readMode>
169 Type tex2Dgather(texture<DataType, cudaTextureType2D, readMode> texRef, float x, float y, int comp = 0);

 

? 表面内存读写函数

  1 /****************************************************************/
  2 
  3 // Surface Object API
  4 
  5 /****************************************************************/
  6 
  7 template<class T>
  8 T surf1Dread(cudaSurfaceObject_t surfObj, int x, boundaryMode = cudaBoundaryModeTrap);
  9     // 一维表面读取
 10 
 11 template<class T>
 12 void surf1Dwrite(T data, cudaSurfaceObject_t surfObj, int x, boundaryMode = cudaBoundaryModeTrap);
 13     // 一维表面写入
 14 
 15 template<class T>
 16 T surf2Dread(cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 17     // 二维表面读取
 18 template<class T>
 19 void surf2Dread(T* data, cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 20     // 二维表面读取
 21 
 22 template<class T>
 23 void surf2Dwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, boundaryMode = cudaBoundaryModeTrap);
 24     // 二维表面写入
 25 
 26 template<class T>
 27 T surf3Dread(cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 28     // 三维表面读取
 29 
 30 template<class T>
 31 void surf3Dread(T* data, cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 32     // 三维表面读取
 33 
 34 template<class T>
 35 void surf3Dwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
 36     // 三维表面写入
 37 
 38 template<class T>
 39 T surf1DLayeredread(cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 40     // 一维分层表面读取
 41 
 42 template<class T>
 43 void surf1DLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 44     // 一维分层表面读取
 45 
 46 template<class Type>
 47 void surf1DLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
 48     // 一维分层表面写入
 49 
 50 template<class T>
 51 T surf2DLayeredread(cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 52     // 二维分层表面读取
 53 
 54 template<class T>
 55 void surf2DLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 56     // 二维分层表面读取
 57 template<class T>
 58 void surf2DLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
 59     // 二维分层表面写入
 60 
 61 template<class T>
 62 T surfCubemapread(cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 63     // 立方体贴图表面读取
 64 
 65 template<class T>
 66 void surfCubemapread(T data, cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 67     // 立方体贴图表面读取
 68 
 69 template<class T>
 70 void surfCubemapwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
 71     // 立方体贴图表面写入
 72 
 73 template<class T>
 74 T surfCubemapLayeredread(cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 75     // 立方体分层贴图表面读取
 76 
 77 template<class T>
 78 void surfCubemapLayeredread(T data, cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 79     // 立方体分层贴图表面读取
 80 
 81 template<class T>
 82 void surfCubemapLayeredwrite(T data, cudaSurfaceObject_t surfObj, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
 83     // 立方体分层贴图表面写入
 84 
 85 /****************************************************************/
 86 
 87 // Surface Refernence API
 88 
 89 /****************************************************************/
 90 
 91 // 函数名类似 Texture Object API
 92 template<class Type>
 93 Type surf1Dread(surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
 94 
 95 template<class Type>
 96 void surf1Dread(Type data, surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
 97 
 98 template<class Type>
 99 void surf1Dwrite(Type data, surface<void, cudaSurfaceType1D> surfRef, int x, boundaryMode = cudaBoundaryModeTrap);
100 
101 template<class Type>
102 Type surf2Dread(surface<void, cudaSurfaceType2D> surfRef, int x, int y, boundaryMode = cudaBoundaryModeTrap);
103 
104 template<class Type>
105 void surf2Dread(Type* data, surface<void, cudaSurfaceType2D> surfRef, int x, int y, boundaryMode = cudaBoundaryModeTrap);
106 
107 template<class Type>
108 void surf3Dwrite(Type data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
109 
110 template<class Type>
111 Type surf3Dread(surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
112 
113 template<class Type>
114 void surf3Dread(Type* data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
115 
116 template<class Type>
117 void surf3Dwrite(Type data, surface<void, cudaSurfaceType3D> surfRef, int x, int y, int z, boundaryMode = cudaBoundaryModeTrap);
118 
119 template<class Type>
120 Type surf1DLayeredread(surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
121 
122 template<class Type>
123 void surf1DLayeredread(Type data, surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
124 
125 template<class Type>
126 void surf1DLayeredwrite(Type data, surface<void, cudaSurfaceType1DLayered> surfRef, int x, int layer, boundaryMode = cudaBoundaryModeTrap);
127 
128 template<class Type>
129 Type surf2DLayeredread(surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
130 
131 template<class Type>
132 void surf2DLayeredread(Type data, surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
133 
134 template<class Type>
135 void surf2DLayeredwrite(Type data, surface<void, cudaSurfaceType2DLayered> surfRef, int x, int y, int layer, boundaryMode = cudaBoundaryModeTrap);
136 
137 template<class Type>
138 Type surfCubemapread(surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
139 
140 template<class Type>
141 void surfCubemapread(Type data, surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
142 
143 template<class Type>
144 void surfCubemapwrite(Type data, surface<void, cudaSurfaceTypeCubemap> surfRef, int x, int y, int face, boundaryMode = cudaBoundaryModeTrap);
145 
146 template<class Type>
147 Type surfCubemapLayeredread(surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
148 
149 template<class Type>
150 void surfCubemapLayeredread(Type data, surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);
151 
152 template<class Type>
153 void surfCubemapLayeredwrite(Type data, surface<void, cudaSurfaceTypeCubemapLayered> surfRef, int x, int y, int layerFace, boundaryMode = cudaBoundaryModeTrap);

 

CUDA C Programming Guide 在线教程学习笔记 Part 6

标签:模式   ***   mapr   ogr   art   算法   texture   uid   ext   

原文地址:http://www.cnblogs.com/cuancuancuanhao/p/7819902.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!