If I am writing a visualizer with glsl, how can I guarantee it will take advantage of more gpu's? Right out of the box it only works on one, what sort of steps / design of the software will allow the pixel shader to be run in parallel on more than one card?
2 Answers
Zero steps required in GLSL. The SLI/crossfire driver takes care of dividing the workload across the GPUs for you. Same for nVidia surround and AMD Eyefinity: as far as the shader is concerned, it's just a bigger render target.
See these slides by nVidia: SLI in OpenGL, especially the slides "Things Interfering with SLI".
You want to make sure that your rendering loop is correctly set up (i.e. SwapBuffers is called), and that you are at least double buffered for AFR mode SLI.

- 4,855
- 5
- 34
- 51
-
Ok so right now I am just creating a glrect and running the shader on it. It uses 100% of one gpu, ignoring the other completely. My drivers/setup are able to work fine with games. There is clearly something else at play here. I am not very experienced with shaders to begin with, thanks though for input. – jett Oct 25 '12 at 15:58
-
1@jett: "*It uses 100% of one gpu, ignoring the other completely.*" How do you know that? – Nicol Bolas Oct 25 '12 at 17:16
-
@NicolBolas Using MSI Afterburner and/or cpuid hwmonitor. – jett Oct 25 '12 at 17:21
-
Hmm, are you letting OpenGL know when the frame is ended with e.g. SwapBuffers()? Also are you running in windowed mode or fullscreen? – sleep Oct 25 '12 at 21:52
-
@JarrodSmith Yes using swapbuffers and windowed mode. – jett Oct 26 '12 at 12:36
From the comments in Jarrod's answer it looks like the 'problem' you are running into is AFR mode (alternate frame rendering) vs SFR mode (split frame rendering), which is a driver mode setup issue.
In AFR mode, the driver sends each entire frame to a single GPU and sends alternate frames to the other GPU. This is great for games and animations where you're most interested in maximizing frame rate and don't care so much about frame latency. Using the GPUs this way gives you pretty much a 2x fps speedup for SLI with little effort. But if you're only drawing a single frame (as seems to be the case from your comment), it will just use the one GPU.
In SFR mode, the driver will split each frame and render part of each frame on each GPU. The problem with this mode is that both GPUs need to do all the setup for every frame, so you won't get 2x speedup. In fact pretty much the only thing that will be sped up is fragment shaders (since each GPU will run half the fragments), so if only 50% of your (single GPU) render time is fragment shaders, you'll only get (at best) a 33% speedup. You might get less as the split may be imbalanced (so one GPU ends up with most of the fragments).
As SFR is generally slower, AFR tends to be the default. You can control AFR vs SFR via the control panel.

- 119,907
- 13
- 134
- 226
-
Okay thanks. As I stated in the following response I am just running a fragment shader on a glrect. This is dynamic not static rendering as well. About 90% of overall calculation is this one shader. I haven't figured out how to enable the correct settings (been testing various configs for a bit now), but you would recommend AFR I take it (for this configuration) ? – jett Oct 25 '12 at 20:41