Tag: texture

CUDA外部纹理声明

我想声明我的纹理一次,并在我的所有内核和文件中使用它。 因此,我在标题中将其声明为extern并在所有其他文件中包含标题(遵循SO 如何使用extern在源文件之间共享变量? ) 我有一个包含我的纹理的标题cudaHeader.cuh文件: extern texture texImage; 在我的file1.cu ,我分配了我的CUDA数组并将其绑定到纹理: cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc( ); cudaStatus=cudaMallocArray( &cu_array_image, &channelDesc, width, height ); if (cudaStatus != cudaSuccess) { fprintf(stderr, “cudaMallocArray failed! cu_array_image couldn’t be created.\n”); return cudaStatus; } cudaStatus=cudaMemcpyToArray( cu_array_image, 0, 0, image, size_image, cudaMemcpyHostToDevice); if (cudaStatus != cudaSuccess) { fprintf(stderr, “cudaMemcpyToArray failed! Copy from the host […]