Hi, I’m trying to make use of CUDA’s 3D textures.
In my code I have a large memory region consisting of 10 images and residing in device memory. I want to bind those Images to one slice of a 3D texture each, so I can easily access them with tex3D(x,y,imageNum).
My question is, whether there is a way to bind these images to a 3D texture without using a cudaArray (like it is possible with bindTexture() and bindTexure2D(), which both only expect a device pointer and dimensions).
Using a cudaArray to store the image data and then bind it to a texture with bindTextureToArray(), seems to be quite an effort (need to call cudaMalloc3DArray(), set up cudaMemcpy3DParms, call cudaMemcpy3D(), …).
Any suggestions?
Edit: I searched some more through the CUDA reference and using a cudaArray seems to be inevitable. However, do I really have to copy my device data into that cudaArray or can I just sort of wrap the device pointer with a cudaArray type. copying seems like wasted since the data already is on the device and I do not want to duplicate it.
Edit: I finally used a cudaArray and copied my device data into it. However, copying and binding consumes about 1-2 ms computation time for a 512x512x10 float array.