Hi, I was wondering if it possible/acceptable to copy new data to the underlying array of a texture reference, without having to bind the array again and still having a valid texture? Of course, the new data would be the same data-type and size as the original array. It seems to make sense, but I haven’t seen any examples of this. Below is sample code from the programming guide, with two extra lines demonstrating what I want to do:
int main()
{
// Allocate CUDA array in device memory
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
cudaArray* cuArray;
cudaMallocArray(&cuArray, &channelDesc, width, height);
// Copy to device memory some data located at address h_data
// in host memory
cudaMemcpyToArray(cuArray, 0, 0, h_data, size, cudaMemcpyHostToDevice);
// Set texture parameters
texRef.addressMode[0] = cudaAddressModeWrap;
texRef.addressMode[1] = cudaAddressModeWrap;
texRef.filterMode = cudaFilterModeLinear;
texRef.normalized = true;
// Bind the array to the texture
cudaBindTextureToArray(texRef, cuArray, channelDesc);
// Allocate result of transformation in device memory
float* output;
cudaMalloc((void**)&output, width * height * sizeof(float));
// Invoke kernel
dim3 dimBlock(16, 16);
dim3 dimGrid((width + dimBlock.x – 1) / dimBlock.x, (height + dimBlock.y – 1) / dimBlock.y);
transformKernel<<<dimGrid, dimBlock>>>(output, width, height, angle);
// NEW! Copy different data to the underlying array of the texture reference
cudaMemcpyToArray(cuArray, 0, 0, h_data_NEW, size, cudaMemcpyHostToDevice);
// NEW! Re-run kernel with new data (note: the kernel calls tex2D)
transformKernel<<<dimGrid, dimBlock>>>(output, width, height, angle);
// Free device memory
cudaFreeArray(cuArray);
cudaFree(output);
}