Cuda Render Buffer Interop for Depth Component

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");
+5
source share
1 answer

I had no successful binding of the depth buffer itself. One of them is to make the value of the depth pixel in the color buffer and bind the color buffer in the same way as you. You will need to write your own shader in order to accomplish this.

+3
source

All Articles