我已经设置了cudaArray
, 并将其绑定到纹理:
texture<float, 2, cudaReadModeElementType> tex;
cudaChannelFormatDesc channelDesc =
cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
cudaArray *cuArray;
checkCudaErrors(cudaMallocArray(&cuArray,
&channelDesc,
width,
height));
checkCudaErrors(cudaMemcpyToArray(cuArray,
0,
0,
hData,
size,
cudaMemcpyHostToDevice));
现在我想知道,如果 and 中的内容在cuArray
计算tex
过程中一直保持不变,我可以传递tex
和/或传递cuArray
给另一个函数,这样我就不必每次都进行绑定了吗?
像这样的东西:
DoJobUsingTex(float* output, float* input, int size, texture tex)
{
\\ do something here
}