Skip to main content
GameDev.net gamedev.net
🔒 Locked

nVidia cards problem

Started by JakeM Dec 15, 2005 at 8:25 PM 6 replies 1.2k views
Original Post
JakeM
JakeM
Do nVidia cards have any control panel settings that prevent the GL command SwapBuffers() not to update until certain amount of time has passed? Because I'm expecting the GL screen to update immediately whenever I call it, however it's not. The GL screen does update, however it takes a certain amount of time to do it. This isn't a refresh problem, but more of a repaint problem. I do not have this problem with ATI cards.
LilBudyWizer
LilBudyWizer
What kind of frame rate are you getting?
Keys to success: Ability, ambition and opportunity.
theZapper
theZapper
I'm guessing you havn't disabled Vsync?

As LilBudyWizer says, what frame rate are you getting, if it's the same as your current monitor refresh rate, you need to disable Vsync.
---When I'm in command, every mission's a suicide mission!
JakeM
JakeM
Quote:

I'm guessing you havn't disabled Vsync?

As LilBudyWizer says, what frame rate are you getting, if it's the same as your current monitor refresh rate, you need to disable Vsync.


You mean programmically? Where and how?
deavik
deavik
Quote:
Original post by JakeM
Quote:

I'm guessing you havn't disabled Vsync?

As LilBudyWizer says, what frame rate are you getting, if it's the same as your current monitor refresh rate, you need to disable Vsync.


You mean programmically? Where and how?

Were you referring to obtaining the frames-per-second count, or how to disable vsync? The latter seems more obvious so here goes. There is a wgl extension WGL_EXT_swap_control and also others for glx exist I think which enable yu to disable/enable vsync from within an opengl app. For testing purposes, it's easier to just toggle it in the driver settings. (This is ofcourse dependent on your card/driver)
JakeM
JakeM
Awesome! That was it! It's working!

// Manually

Start -> Settings -> Control Panel -> Display -> Settings -> Advanced ->
Geforce TAB -> Performance & Quality Settings -> Basic Settings -> Vertical sync -> OFF

By default, it is set to "Application-controlled".


// Programmically

http://steinsoft.net/index.php?site=Programming/Code%20Snippets/OpenGL/no7

//function pointer typdefstypedef void (APIENTRY *PFNWGLEXTSWAPCONTROLPROC) (int);typedef int (*PFNWGLEXTGETSWAPINTERVALPROC) (void); //declare functionsPFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL;PFNWGLEXTGETSWAPINTERVALPROC wglGetSwapIntervalEXT = NULL; //init VSync funcvoid InitVSync(){   //get extensions of graphics card   char* extensions = (char*)glGetString(GL_EXTENSIONS);     //is WGL_EXT_swap_control in the string? VSync switch possible?   if (strstr(extensions,"WGL_EXT_swap_control"))   {      //get address's of both functions and save them      wglSwapIntervalEXT = (PFNWGLEXTSWAPCONTROLPROC)          wglGetProcAddress("wglSwapIntervalEXT");      wglGetSwapIntervalEXT = (PFNWGLEXTGETSWAPINTERVALPROC)          wglGetProcAddress("wglGetSwapIntervalEXT");  }} bool VSyncEnabled(){   //if interval is positif, it is not 0 so enabled ;)   return (wglGetSwapIntervalEXT() > 0);} void SetVSyncState(bool enable){    if (enable)       wglSwapIntervalEXT(1); //set interval to 1 -> enable    else       wglSwapIntervalEXT(0); //disable}////////////////////////////////////////////////////////////////Don't forget to call this first (AND AFTER OPENGL CONTEXT CREATION!!!!!)InitVSync(); //...if (VSyncEnabled())  MessageBox(NULL,"VSync is enabled","VSYNC ENABLED",MB_OK); //..//disable VSyncSetVSyncState(false);

LilBudyWizer
LilBudyWizer
Hum, well, normally things happen so fast you have to time it to tell it isn't immediate. So exactly what is happening? Are you getting a noticable delay between the return from the swap call to the screen being updated? Or is the swap call taking a long time to return? How long of a delay are you talking about?

OpenGL queues commands for execution. It writes commands and their parameters to a buffer and when the buffer is full it sends the buffer to the graphics card. You can use glFlush to force the current buffer to be transferred whether it is full or not and glFinish to do that as well as waiting for execution of the buffer to complete. So if swap returns immediately, but it takes awhile for the screen to actually update then pretty well the swap must be setting in a buffer awaiting transfer. I've never seen that happen under windows, but I'm no expert.

If it takes a long time for swap to return then it's the time it's taking to execute the pending commands. I don't know shaders, but presumably a poorly coded shader could slow rendering way down. Perhaps a bug that on one card causes little problem and creates havok on another. All your commands complete virtually immediately because they are just written to a buffer, but the actual execution is taking a long time and you don't see it until you wait for all pending commands to complete. Stick a glFinish in front of the swap and the glFinish takes a long time instead.

So that's two things that might happen and exhibit themselves differantly. More detail on exactly what is happening would help a good deal though. Also what you are running on would help.
Keys to success: Ability, ambition and opportunity.
JakeM
JakeM
Turning off vsync, either manually or programmically, solved my problem.
Calling glFinish or glFlush did not help.

Thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.