read back opengl rendering results with CUDA

I’m trying to use CUDA to read back the framebuffer to CPU memory. I know the mapping/unmapping may be slow, I’m just curious how slow it is with CUDA 2.0. My program is based on the imageDenoising example in CUDA SDK.

I cannot get the readback work. Now I’m wondering if it is possible or making sense to do so.

In imageDenoising, a PBO is mapped to CUDA every frame and then used as a texture to be displayed onto framebuffer. This is different from what I need, mapping framebuffer to CUDA every frame, then sending back to CPU memory.

The comment in imageDenoising says "
//While a PBO is registered to CUDA, it can’t be used
//as the destination for OpenGL drawing calls.
//But in our particular case OpenGL is only used
//to display the content of the PBO, specified by CUDA kernels,
//so we need to register/unregister it only once."

Does it mean I cannot read back the framebuffer with CUDA?

I attached the code, press ‘s’ to read back the framebuffer and save as a raw file. A matlab script to view the raw file is also included.


Yao (115 KB)