What I'm trying to do is use OpenGL to do some rendering, and then use CUDA to do some post-processing (computation) of reading only directly on the rendered RGB and depth components without copying the data to the PBO.
To do this, I create an FBO, and I attach two RBOs to it (one for RGBA and one for DEPTH).
Then I call cudaGraphicsGLRegisterImage for each RBO with the GL_RENDERBUFFER parameter. For RBO color, cudaGraphicsGLRegisterImage returns cudaSuccess, but for RBO depth, I get cudaErrorInvalidValue.
I read somewhere on the forums that the CUDA buffer internetworking for the depth component is not currently supported by nVidia, although it is well present in the documentation.
I am using CUDA Toolkit 5.0 and I have a Quadro 2000 card.
Someone succeeded, and how?
Here are some code snippets:
glGenRenderbuffers(1, &rbo_color);
glBindRenderbuffer(GL_RENDERBUFFER, rbo_color);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, WIDTH, HEIGHT);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
if (cudaGraphicsGLRegisterImage(&resource_color, rbo_color, GL_RENDERBUFFER, cudaGraphicsMapFlagsReadOnly) != cudaSuccess)
fprintf(stderr, "Error in registering rbo color with cuda\n");
glGenRenderbuffers(1, &rbo_depth);
glBindRenderbuffer(GL_RENDERBUFFER, rbo_depth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32F, WIDTH, HEIGHT);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
if (cudaGraphicsGLRegisterImage(&resource_depth, rbo_depth, GL_RENDERBUFFER, cudaGraphicsMapFlagsReadOnly) != cudaSuccess)
fprintf(stderr, "Error in registering rbo depth with cuda\n");