PDA

View Full Version : Multiple GPU use and wglShareLists under Windows



Chris3D
09-15-2011, 08:54 AM
Hi guys, I'm new in this forum, however not new to GL. I hope you can help me with this:

Problem: When rendering using a specific GPU, I'm not able to display the result to the screen if the GPU is not the default device context.
SystemInfo: Windows 7, VS2010, Cpp, MFC, Hardware: 2x Nvidia Quadro FX1800(No SLI!) each with 2 Monitors attached
Context: My application has four windows, one on each monitor, when I dont assign any tasks to a specific GPU, Windows will assign everything to the first GPU(default device), resulting in slow framerates. Because the GPU is at about 100% usage. So I used the gl extension: WGL_NV_gpu_affinity, which works fine.. BUT: with this extension one is only able to render offscreen, so I took a pixel buffer to render into(Example #3 in the manual of the extension) and then assign that buffer as a texture that I simply draw into the rendering context of the window, the buffer is known there because I use wglShareLists for the device context of the pixel buffer and the device context of my window. This works if I assign the rendering task to the primary device, for all rendering tasks done on the second GPU, I only see white textures. The reason for that I assume is that, when the window (a MFC CDialog) is created the device context defaults to the first GPU, but the pixelBuffer for which I create the affine device context is on the second GPU, so wglShareLists wont work. I see two possible solutions:
more specific question:
1st: (which I would prefer) How do I force the CDialog to use a specific device context and prevent it from just always using the default(1st GPU)?
2nd: If thats not possible, since I have my rendered scene in a pixel buffer, it must be possible to transfer it from one GPU to the other. I could access the buffer directly and save it in the user memory, then make the other rendering context active and draw it.. but that detour would be extremely slow I presume. So how do I transfer between two GPUs fast?

Any thoughts about how to solve this?
Thanks for reading.
(I can provide code if requested)

skynet
09-15-2011, 10:46 PM
You can use WGL_NV_copy_image to transport image data between contexts on separate (NVidia-)GPUs.

eile
09-16-2011, 02:12 AM
You can use WGL_NV_gpu_affinity to draw to a window directly. Under Windows 7 this was broken, but should work in latest drivers. You have to be careful which dc (window vs. affinity) you use for which operation. Check the Equalizer source code (wgl/window.cpp) for details.