1. why do you load zero block of memory into GLbuffer if you fill it with other data anyway. just call glBufferData() with NULL pointer and it allocate empty buffer with desired size.
2. creating cl_mem object every frame is IMHO bad idea. move it into init() or something.
Hi Nou, and thanks for your reply !
1. well, I guess because I don't fully understand the memory handling between CPU and GPU yet (I'm pretty new to openCL and fancy openGL ops)...
2. yep, this was the issue: I changed the code so that clCreateFromGLBuffer gets called only once during init, and my lag is gone ! Thanks a lot !
Btw, what is the difference between clCreateFromGLBuffer and and clEnqueueAcquireGLObjects? I thought that clEnqueueAcquireGLObjects would actually retrieve the memory contained in the GL buffer of interest, but now I ain't so sure any longer...
Thanks again !
clEnqueueAcquireGLObjects / clEnqueueReleaseGLObjects has nothing to do with allocating or releasing a buffer, its like getting a lock on that object so that it can be used in the compute mode.
When you are done with CL calculations on buffer, you should call clEnqueueReleaseGLObjects so that it can be used in GL mode.
Alright, I see... This makes sense actually Thank you N0thing !
However, when I call clCreateFromGLBuffer only at startup, my buffer gets updated only once.... (i.e. it retrieves content of only the first frame, afterward nothing... at all... unless I call clCreateFromGLBuffer again)....
Any idea about this ?
EDIT: and if I call clCreateFromGLBuffer at every frame, the data always corresponds to the first frame... I guess I'm missing something else somewhere....
EDIT2: well, looks like I should call both glBufferData AND clCreateFromGLBuffer only once at startup. This gives me appropriate data. sorry for the trouble guys and thanks again for the help