I was wondering if it's possible to make OpenGL commands on OS X block on the completion of previous OpenCL commands, without blocking the host at all.
Apple's documentation describes signaling a semaphore after (synchronously) executing an OpenCL kernel on another thread. However, I'm hoping instead to keep all OpenGL and OpenCL calls asynchronous and not having to stall host execution on a semaphore.
Going the other way (making OpenCL wait for OpenGL) is what the cl_khr_gl_event OpenCL extension is for, and it seems to work great (except it's reverse of what I want).
The ARB_cl_event OpenGL extension seems to do what I want, but it doesn't seem to be present on Macs. :-(
I was thinking that maybe I could create a OpenGL sync object, link it to an OpenCL event, then somehow make OpenCL enqueue a task that would trigger the event, thereby triggering the sync object. I was thinking that I could then use glWaitSync to make GL pause. However, this approach won't work because there is no way to create a OpenGL sync event without inserting it into the command stream immediately.
Is there some way that I'm missing to do this on OS X without making the host block?