cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

mulat
Journeyman III

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?

0 Likes
5 Replies
tonyo_au
Journeyman III

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

Tony

0 Likes

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

0 Likes

Hi,

thanks for your replies. I am using a renderbuffer for the depth target and I am trying to write to it using OpenCL (trying something like oldschool effects with OpenCL and then using the result for "standard" rendering). Does someone one if this is possible with DirectCompute?, writing to the zbuffer to use the results with a second "render pass"?

regards,

mulat

0 Likes

My directx is getting a bit dated but you seem to be able to read the depth buffer with directcompute so there is a reasonable chance you can write it.

I do not believe there is any way with OpenCL because it does not support any depth buffer format in its image structures.

 

Checkout the code in Intel's sample program

http://visual-computing.intel-research.net/art/publications/sdsm/

 

It does not write to the depth buffer with directcompute but it does read it

0 Likes

Hi,

thanks a lot for the link, and your comments 🙂

mulat

0 Likes