PDA

View Full Version : Rendering with 2 contexts killing the fps



outis
12-30-2008, 02:38 PM
Hi,

I want to use openGL to render on 2 different windows. To achieve this, I made 2 context, and swap between each of them thanks to the wlgMakeCurrent function. This happens to take my fps from capped at Vsync to around 35.

The first window is 800*600, the second is 600*200. Full scene is computed on the big window, the second only renders one triangle.

Based on this, it seems to me that I am doing something wrong, rather than having openGL take that much more ressources to perform on 2 separate windows.

Code runs on windows xp 32 bits btw.

Any inputs are welcomed

dletozeun
12-30-2008, 03:27 PM
I don't see really a problem here, do you need to display the 2nd window? If not you can create a fbo instead and use only one window, thus one RC.

outis
12-30-2008, 03:47 PM
Yes I need both the windows to be displayed and rendering.

This I have done, my problem is how performing this reduces dramatically the fps, even when the second context runs on a small window, with a very simple scene. Matter of fact, just running the second window and only clearing its background already has a huge impact on the performances.

hDC = GetDC(WinWnd);
PixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, PixelFormat, &pfd);
hRC = wglCreateContext(hDC);

This is the code used to create a context. Each window has its own handle, hDC and hRC.

knackered
12-30-2008, 07:16 PM
well if you've got vsync on then the first contexts swapbuffers will wait for the monitor vsync before returning, then you draw using the second context and swap, which also waits. This means that each window is being drawn every other monitor refresh. So I can sort of deduce that you must be running your desktop at about 70hz refresh rate.

BTW, this problem has been discussed here:-
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=245330

outis
12-31-2008, 04:02 AM
Indeed, knackered, that is the problem. Both the contexts were running in double buffered mode, as soon as I ran one in single mode, problem was fixed.

Thanks for the explanation and the link.

dukey
01-05-2009, 09:18 AM
if you got a quadro card you can use the
http://opengl.org/registry/specs/NV/wgl_swap_group.txt
extension.

Otherwise for consumer cards you are probably [censored] out of luck.
(unless you disable vsync)

knackered
01-05-2009, 11:51 AM
last time i tried to use swapgroups on winxp with a quadro card, but without a gsync card, it would lock up the machine forcing a hard restart. Maybe they've fixed the problem now, but it scared me off using it unless i was syncing between machines. I think it will be a while before nvidia become as good as 3dlabs with this sort of thing.

tkunert
01-13-2009, 12:35 AM
Another solution would be to use two rendering threads instead of one.
Because they would be running in parallel (and using independend GL contexts), they won't wait on each other's vsync, resulting in full fps for each window.