PDA

View Full Version : Framerate Problems



GoLeM-OZ-
08-12-2003, 03:55 PM
Im looking for help
I was working on a win32 opengl program, I am writing a multithread program(single rendering thread), but am having problems with the framerates, What I have found is that When rendering I draw about 20 GL_TRIANGLES I get a framerate of 60.0 limited by my refresh rate, then when I draw 21 GL_TRIANGLES my framerate drops to 30 it a non-linear change.

I have turned off depth testing and this doesnt change the Framerate neither does disabling textures. I thought it must be the threads, e.g. due to the 20ms switching, but I have also made sure to set the rendering thread the MAX priority and still no dice. Im running out of ideas to what it could be.

Any Suggestions
Peter Beardsley

PS if anyone in interest in the source I will email it.

evanGLizr
08-12-2003, 04:51 PM
Originally posted by GoLeM-OZ-:
What I have found is that When rendering I draw about 20 GL_TRIANGLES I get a framerate of 60.0 limited by my refresh rate, then when I draw 21 GL_TRIANGLES my framerate drops to 30 it a non-linear change.

The "non-linear" drop in fps is an effect of having vsync on (vertical sync=refresh rate). Note that having vsync on means that SwapBuffers won't take place until a vsync happens.

For clarity's sake, lets assume your vsync is set to 1Hz. This means that not only the fastest you can SwapBuffers is every second but that SwapBuffers will take place at an integer number of seconds.

Case 1: Imagine that your rendering task takes 0.5secs to execute, this means that you do your rendering and then swapbuffers, which causes SwapBuffers to block for 0.5 (until next vsync). In this case you render at 1fps.

Case 2: Now your rendering task takes 1.1 secs to execute. Because when you finish rendering, the last vsync happened 0.1secs ago, when you issue the SwapBuffers it will block for the next vsync to happen to effectively swapbuffers (idle wait of 0.9secs). Net result: 0.5 fps, as you can only swap once every 2 secs.

If you change 1Hz to 60Hz and do the math, you will see that it matches what you are seeing.

All this is assuming the graphics card blocks on SwapBuffers calls when vsync is on, which seems to be the case of your graphics card (there are graphics cards that don't block on SwapBuffers even with vsync on).

GoLeM-OZ-
08-12-2003, 05:55 PM
Thanks for your response, But how do i turn off Vsync in program?

Ostsol
08-12-2003, 06:52 PM
You can't. The drivers override application settings.

JanHH
08-12-2003, 08:09 PM
but it must be possible somehow? at least, change refresh rate to at least 75 hz, better for the eyes anyways http://www.opengl.org/discussion_boards/ubb/wink.gif. in a lot of games, you can switch vsync, and I am absolutely sure that nearly all graphics cards can render withoug vsymc, so it MUST be possible somehow.. what card have you gto?

secnuop
08-12-2003, 08:42 PM
Have a look at the WGL_EXT_swap_control extension (assuming you're on Windows).

Jared@ETC
08-13-2003, 06:26 AM
wglSwapIntervalEXT(0)

Will wait 0Hz between swaps. This is equivalent to turning off vsync.

zix99
08-13-2003, 06:54 AM
You said win32, right? So all you have to do is go into the display properties, advanced, OpenGL tab, and turn off V-sync. If you want to do this in the program there must be some form of API to do this.

ZIX

ehart
08-13-2003, 11:10 AM
FWIW, a lot of drivers these days have several settings. Each of settings generally fall into one of these catagories:

Force V-synch on, ignore the app
Force V-synch off, ignore the app
Default to V-synch on, but obey the app
Default to V-synch off, but obey the app

Understnading how these map to what the driver on your system does can avoid a lot of frustration. Also, be aware that some HW/drivers can only make v-synch work when the app is full screen.

-Evan