Sharing Renderbuffer OpenGL object with OpenCL

My application render the image in a OpenGL FBO.
Then I have attached an OpenGL Renderbuffer to this FBO.

I have created an Image2D OpenCL memory object with clCreateFromGLRenderbuffer
Now my Kernel use an Image2D as input from the Renderbuffer.

My question is the following, is the OpenCL memory object up to date when I call glFlush or do I need
to call an OpenCL function to tell that the Image2D memory object must be updated with the content of the OpenGL Renderbuffer ?

I have seen that I need to acquire and release the memory object which is shared with an OpenGL object,
but I don’t have seen anything to update the memory object from the renderbuffer.

Anyone has any explanations ?

Thanks

I reply to myself for all readers !

The OpenCL memory object shared with an OpenGL Renderbuffer is always up to date. No need to acquire and release the GL object, and no need to call any cl function.

I’d certainly put the clAcquire/Release in, otherwise the GL operations may not have completed writing to the FBO before your kernel starts reading it.

It’s not a case of the memory object needing to be updated from the FBO, because the memory object is the FBO. What might happen is that if you don’t acquire the resource then the CL operation and the GL operation might run in parallel, so your input buffer will change as the kernel is running.

This is unlikely on your current system as you’re using the same resource to do both jobs, so it has to serialise, but in the future it may not, and I would make for a nasty bug to find.

That’s my understanding at least.