5 Replies Latest reply on Jul 7, 2011 2:04 AM by mulat

    OpenCL / OpenGL interop problems

      Writing to depth buffer

      Hi there,

      i am trying to do some writes to a renderbuffer (GL_DEPTH_COMPONENT), as it is a part of a framebuffer object. I encountered a problem: I have a renderbuffer id (name) which actually is the depthbuffer and a single texture name for storing the color values. Since it's one renderbuffer and one texture, both have 1 as a name (I only created one of them each).

      Both get attached to my CL kernel and when trying to write to both, the program not only crashes, it freezes the complete machine (so i have to do a hard reboot).

      Further investigating this, I found out when I create more textures and bind one texture and one depth render buffer to the CL kernel, and both have different names, the code doesn't crash. The color target gets written to fine, I didn't have the time to check the depth render buffer as well (will do that in a few minutes).

      Is it even possible to bind a renderbuffer with GL_DEPTH_COMPONENT to my CL kernel? Or am i doing something completely wrong?

        • OpenCL / OpenGL interop problems

          Is your depth buffer a texture buffer. If it is not, to the best of my knowledge you cannot access it with OpenCL


            • OpenCL / OpenGL interop problems

              Just a followup. I bind an extra colour buffer to the frame buffer and store the depth in here in the red  component so I can access it in OpernCL. I have tried using a 32bit float texture as the depth component but OpenGL will not let me use this as a depth buffer.

              So I effectively have 2 depth buffers, one as a depth component and a texture buffer that I copy gl_frag.z into. This seems a bit of a waste as you do not have to so this in DirectX but I have not managered to access the the depth component in OpenCL any other way.

              Note - this means you can only read not write a depth component in OpenCL (believe this is also a restriction int DirectX compute shaders).

              This makes sense as the implementation of the depth buffer is very hardware dependent.

              It would be nice to be able to read the depth buffer without having to duplicate the buffer but I don't know how