Hi!

I'm beginner to OpenCL world and I need some help to copy data from GPU to CPU. The problem is that this data is a 2D texture made by OpenGL (off-screen rendering with FBO + GLSL). The context init seems good and returns no error; recording the texture to CL via clCreateFromGLTexture2D and acquiring data (clEnqueueAcquireGLObjects) return nothing but CL_SUCCESS too.

Then, there's the moment when I want to copy the texture back from GPU memory to RAM. I tried clEnqueueReadBuffer and clEnqueueReadImage, and I even tried to write something on it with clEnqueueWriteBuffer and clEnqueueWriteImage but each time it fails with the code CL_INVALID_VALUE which doesn't mean the same thing for all this functions. I verified some points but the application shows that th texture is known (clGetGLTextureInfo and clGetGLObjectInfo return the right texture ID and the right type : GL_TEXTURE_2D).

I think I am wrong with the kind of memory the OpenCL handle to the texture is...

Does someone have a sample code or any idea about this?

Thank you!