Binding device memory to 3D texture

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.

No, unfortunately we don’t support binding linear memory to 3D textures like we do for 2D textures (this is a hardware limitation).

There is some discussion of adding support for texture arrays to CUDA, which sounds like it would work for your application, but I can’t promise when this will be released.
[url=“http://developer.download.nvidia.com/opengl/specs/GL_EXT_texture_array.txt”]http://developer.download.nvidia.com/openg...xture_array.txt[/url]

You can used flat 2D texture to replace( if not use the hw linear filter function of 3D texture ) and then can bind 2D linear device memory to it in applactions