Render to texture with CUDA?

Hi folks,

I’m wondering whether techniques like render to texture are available in CUDA?

My program is some stereo matching algorithm, and I need intermediate results stored in texture (or 2D cuda array) to make full use of the efficiency of cached texture memory reads. Since in the kernels you can not write to an 2D array, so this seems like a dead-end?

It’s possible to break the program into OpenGL part and CUDA part, so that the render to texture part is done in OpenGL. But to my understanding when you map the frame buffer object from OpenGL to CUDA then you are using the fbo just like a linear memory created with cudaMalloc, and cached texture memory reads are not utilized.

My understandings may be well flawed, so please correct me if I’m wrong. And any advice on how to store intermediate results to the texture memory or 2D cuda array is appreciated!


You can’t write to textures directly in CUDA, there is no render to texture. But GPU to GPU copying to texture is really fast, I doubt it will ever be your bottleneck.

Of course if you can coalesce memory accesses, you don’t need textures at all.

Using OpenGL interoperability is an option, but doing everything in CUDA is usually quite somewhat faster if it’s possible.

Thank you wumpus for the prompt response! I guess I should just go ahead with writing to a linear memory and then using cudaMemcpy to a 2D array for further use :))

When you talk about coalescing memory accesses, is that the shared memory? Any other form of memory coalescing that I should be careful about?



Memory coalescing applies to global memory, not shared. Please read the programming guide section on coalescing and come back with any specific questions you might have.