PDA

View Full Version : Read GL depth buffer from OpenCL?



Dark Photon
04-14-2011, 02:48 PM
I want to do some post-processing on a OpenGL depth buffer with OpenCL.

However, AFAICT, OpenCL can't do this. Is this true? If so, what's the simplest way to shim this so OpenCL will work?

BACKGROUND:

clCreateFromGLTexture2D (http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLTexture2D.html) only honors cl_image_format (http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/cl_image_format.html) formats, which are essentially only RGBA (color) formats. Any attempt to use a depth texture results in CL_INVALID_GL_OBJECT, even if you pass a GL_DEPTH_COMPONENT32F texture (component type GL_FLOAT, which is supported). So a depth texture is apparently out.

And clCreateFromGLRenderbuffer (http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateFromGLRenderbuffer.html) says it "too" only handles RGBA-based (color) internal formats. Here's a guy that tried that last year and met with failure: link (http://www.khronos.org/message_boards/viewtopic.php?p=7289#p7289)

What's a poor developer to do?

david.garcia
04-14-2011, 03:43 PM
That's a good question. I'm not an expert on CL/GL interop, but as far as I understand you are out of luck. Sorry.

Dark Photon
04-14-2011, 04:33 PM
Ok, thanks. I was hoping to get out of writing a redundant FLOAT color channel, doubling my write bandwidth, just to use OpenCL for this.