duronrulez's picture

OpenTK FPS and CPU load question

Hello! I've recently started using OpenTk :)
But i noticed some strange behavior, it may be my code but still i'll ask :)

I'm using a demo from the examples, made some changes to it though. The main class extends GameWindow.

1. FPS seems to be limited to 30-31 FPS on an empty scene.
- FPS calculation is located in OnRenderFrame - Just Below SwapBuffers();

2. CPU load is 50% on an empty scene.

My system is 2.2 Ghz Core 2 Duo, 2 Gb Ram, GF 8600 GT

If anyone have any ideas what I may be doing wrong, please share!
It would be great if FPS is atleast 60 (vsync-ed) on an empty scene and CPU load is not 50% :)

Thanks in advance!


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
duronrulez's picture

Oookay, i think i found my issue :(

If we run the window with 30 fps limit (which i did by mistake). We get limit at 30 (which we obviously want), but the CPU Load jumps sky high.
example.Run(30.0, 30.0);

With this:
example.Run(30.0, 0.0);

the cpu load is normal.

Dunno if its a bug or something, just though its worth mentioning.

the Fiddler's picture

An empty scene should render at a few thousand FPS with hardware acceleration.

The second parameter of GameWindow.Run() is a "soft" framerate limiter, i.e.

gw.Run(60, 30);

specifies an UpdateFrame rate of 60Hz and a RenderFrame rate of 30Hz.

Instead of this, you should use:

gw.Run(60);

to specify your target update rate and leave your render rate unlimited.

If you wish to reduce CPU usage, either enable VSync or call System.Threading.Thread.Sleep(1) right after SwapBuffers(). (You should probably check if your framerate is high enough before sleeping).

Edit: you posted while I was replying! :)

The high CPU usage is a side-effect of the frame limiter (it uses a busy wait loop). This code is undergoing changes right now, so this should be fixed in future versions one way or another (the frame limiter will probably be removed, as its value is dubious).

inTagger's picture
the Fiddler wrote:

The high CPU usage is a side-effect of the frame limiter (it uses a busy wait loop). This code is undergoing changes right now, so this should be fixed in future versions one way or another (the frame limiter will probably be removed, as its value is dubious).

What's the state of the issue?