PDA

View Full Version : same opengl code runs 1/3 slower on windows 7



wwuster
12-11-2009, 03:13 AM
I have 2 identical computers with nvidia geforce 7600 gs video cards. One runs windows7 and the other one is running Ubuntu linux 9.10. I'm testing an opengl program on both. As far as I
can tell the opengl code is the same for both operating systems. On linux I can get 247 frames per second if I let the program free-run. The windows 7 version will only run at 79 frames per second. The display monitor goes through a KVM switch and is 1920 x 1080.

Can someone suggest a reason for this or how I can locate the problem. I could post the GLIntercept dump of the opengl initializaion calls. I don't know if this matters, but I'm using the orthoganal mode.

nvidia geforce 7600 gs
win7: 79 FPS
linux: 247 FPS

thanks,
William

pjmlp
12-11-2009, 04:34 AM
Lack of proper OpenGL drivers on the Windows 7?

BionicBytes
12-11-2009, 04:41 AM
Is the same monitor and resolution used for both machines?
The app code can not be the same since one uses linus and the other is Windows...so is the application using the same GL extensions? (vertex arrays, texture formats, FBO formats, etc)

Also, is the windows implementation using vertical refesh sync (Vsync)?

Lastly, since the code between the two must be different by definition, perhaps the mechanusim to record fps is different too - have you determined exactly how you arrive at this figure? for both cases ?

Jan
12-11-2009, 05:07 AM
1) Check that under Windows V-Sync is off. 79 FPS sounds very much like a limit to 80 Hz.

2) As long as you get more than 60 FPS you can't really tell much about it. At high refresh-rates there will be very big speed-differences on different PCs, OSes, GPUs due to various reasons.
For example drivers often cache commands for several frames. But when they have cached 3 frames in advance, they usually block, because it makes no sense to continue. On linux this might not be the case (or the setting might be set higher) so you get much more FPS there, due to no artificial throttling.

When you do enough processing, so that you get <60 FPS on the faster PC, THEN we can start comparing the differences properly.

Jan.

wwuster
12-11-2009, 05:59 AM
Device manager says the drive is "working properly": Microsoft WDDM driver. I can't find any place that I can turn off vertical sync. How can I tell if that is the problem or adjust that?

It's the same monitor on both systems (using a KVM switch). The generic opengl code is the same. It IS different up to that point, WGL functions etc for windows.
I'm not using any opengl extensions, just opengl32 and glu32.

This is a test program. The real program was getting 5 FPS on windows, doing more processing, while the linux one was something like 120 FPS if I recall, so I was looking into differences in simpler code between windows and linux.

William

mark ds
12-11-2009, 06:29 AM
Make sure you have downloaded the latest drivers from nvidia's web site.

Go into nvidia control panel -> 'manage 3d settings' -> vertical sync. Make sure it's set to 'force off'.

Jan
12-11-2009, 06:31 AM
To turn off V-Sync:

Right-click on the desktop -> nVidia Control Panel -> Manage 3D Settings -> V-Sync -> Force OFF.


5 FPS vs 120 FPS sounds more like software-rendering vs. hardware. You might be doing something that the windows-driver doesn't like. Check your window-setup code, that you request a common framebuffer format.

Jan.

skynet
12-11-2009, 06:35 AM
Make sure, you use double buffering on Win7. Don't try to draw to the front buffer. More info here:

http://www.opengl.org/pipeline/article/vol003_7/

wwuster
12-11-2009, 07:20 AM
That's the problem: I can't find nvidia control panel anywhere. It's not there if I right-click on the desktop. Do I need a different driver, or to install nvidia control panel?

I'm using double buffering. Here's the windows initialization (simplified):


hinstance = GetModuleHandle(NULL);

windowrect.left = (long)0;
windowrect.right = (long)width;
windowrect.top = (long)0;
windowrect.bottom = (long)height;

WNDCLASS wc = {
CS_HREDRAW | CS_VREDRAW,
WndProc,
0,
0,
hinstance,
NULL,
LoadCursor(NULL, IDC_ARROW),
(HBRUSH)GetStockObject(BLACK_BRUSH),
NULL,
"classname"
};


gbrush = CreateSolidBrush(OGLBGCOLOR);
wc.hbrBackground = gbrush;

RegisterClass(&amp;wc);

dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;

AdjustWindowRectEx(&amp;windowrect, dwStyle, FALSE, dwExStyle);

hwnd = CreateWindowEx(
dwExStyle,
OGLCLASS,
title,
dwStyle,
x, y,
windowrect.right-windowrect.left,
windowrect.bottom-windowrect.top,
NULL,
0L,
hinstance,
0L);

SetWindowLong (hwnd, GWL_USERDATA, (long)this);

hdc = GetDC(hwnd);
planes = GetDeviceCaps(hdc,PLANES); // 1
bits = GetDeviceCaps(hdc, BITSPIXEL); // 32

GetClientRect(hwnd, &amp;clientrect);

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = bits;
pfd.cRedBits = 0;
pfd.cRedShift = 0;
pfd.cGreenBits = 0;
pfd.cGreenShift = 0;
pfd.cBlueBits = 0;
pfd.cBlueShift = 0;
pfd.cAlphaBits = 0;
pfd.cAlphaShift = 0;
pfd.cAccumBits = 0;
pfd.cAccumRedBits = 0;
pfd.cAccumGreenBits = 0;
pfd.cAccumBlueBits = 0;
pfd.cAccumAlphaBits = 0;
pfd.cDepthBits = 16;
pfd.cStencilBits = 0;
pfd.cAuxBuffers = 0;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.bReserved = 0;
pfd.dwLayerMask = 0;
pfd.dwVisibleMask = 0;
pfd.dwDamageMask = 0;


PixelFormat=ChoosePixelFormat(hdc, &amp;pfd);
SetPixelFormat(hdc, PixelFormat, &amp;pfd);
hRC = wglCreateContext(hdc);
wglMakeCurrent(hdc, hRC);


William

mark ds
12-11-2009, 07:40 AM
Are you getting your drivers from nvidia? If not, do so - I'm not certain if the windows update provides the nv control panel or not - I can't remember.

Stephen A
12-11-2009, 08:33 AM
As mark ds said, you need download correct drivers from nvidia.com. Windows don't install OpenGL drivers by default, so it's likely that your program is passing through Microsoft's OpenGL->Direct3D emulation layer (yes, that's bad).

wwuster
12-11-2009, 08:34 AM
That was it. I'm now getting 245 FPS on windows 7. I thought that Microsoft would install the best driver. I guess I thought wrong.

thanks,
William

barthold
12-11-2009, 12:59 PM
On Windows 7, the NVIDIA "in the box driver" is release 185.93. That is the driver you get with a new install of Win7. However, it is a driver with only core functionality. There is no control panel and no OpenGL ICD, for example. Thus yes, you do need to upgrade to a newer driver. Windows Update should have given you the option to do so.

Regards,
Barthold
(with my NVIDIA hat on)