OK, supposing I want to pass a pointer as 2D texture on GPU.
I do the following:
texture<float, 2, cudaReadModeElementType> pu;
cudaArray *ca_u;
cudaChannelFormatDesc chanDesc_mot = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
CUDA_SAFE_CALL(cudaMallocArray(&ca_u, &chanDesc_mot, size));
CUDA_SAFE_CALL(cudaMemcpyToArray(ca_u, 0, 0, u, size, cudaMemcpyHostToDevice));
CUDA_SAFE_CALL(cudaBindTextureToArray(pu, ca_u, chanDesc_mot));
How in hell, CUDA will know the width and the height of the texture when I’ll try to access it later with text2D(pu, x, y)?