Obtaining GPU deviceID for each window/NSScreen in multi-display/multi-GPU app? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Obtaining GPU deviceID for each window/NSScreen in multi-display/multi-GPU app? (/thread-10351.html)
Obtaining GPU deviceID for each window/NSScreen in multi-display/multi-GPU app? - dauerbach - Oct 8, 2012 08:18 AM
Wondering if anyone has any experience using clGetGLContextInfoAPPLE in an openCL/openGL application to obtain the device ID for the GPU currently being used to display an application window containing an NSOpenGLView?
In short, I have multiple windows each drawing separately (in a threaded render loop) into an NSOpenGLView. The texture being rendered in computed on the GPU using openCL. I have the openCL/openGL code working together to avoid the openCL result from having to back to the host before being rendered by openGL. However, I can't seem to successfully figure out which GPU a particular window window is being displayed on. Using clGetGLContextInfoAPPLE always return the first physical GPU regardless of which physical display the window is on. As a result, for one of the windows, the openCL result image does have to go back through the host before rendering on the correct display. In addition, one GPU is doing all the openCL kernel processing while the other is doing none of it. Perhaps it has something to do with the openGL context creation, but I've done everything I can think of to make sure the window's openGL context is created after the window is created and positioned on the desired display.
Any thoughts or suggestions greatly appreciated!
RE: Obtaining GPU deviceID for each window/NSScreen in multi-display/multi-GPU app? - OneSadCookie - Oct 8, 2012 11:58 AM
Abe responded with some answers here on the dev forums.
AFAICT, how this *should* work is:
1) Use CGDisplay/NSScreen to position a window on each display
2) create a context for each window, accepting all renderers
3) ensure the window is visible and the context is updated. This will set its virtual screen correctly.
4) call clGetGLContextInfoAPPLE with CL_CGL_DEVICE_FOR_CURRENT_VIRTUAL_SCREEN_APPLE to get a cl_device_id
5) pass that to clCreateCommandQueue
... and of course, ensure that 3-5 are repeated whenever the window moves.
Some other possibly useful info:
* the low byte of the GL renderer ID distinguishes identical GPUs
* CGDisplay can give you an IOFramebuffer for a display, which you can use to correlate a display with this low byte and with the physical port on the rear of the machine.