How to fix fps?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: How to fix fps?

Post by Nadro »

I would prefer play 2h without jittering than 5h with missing frames etc. The sleep method is to much unpredictable in my opinion for differents platforms. Of course it's depend on target group. For simple, mobile games as You said a long battery life is important, but for more complex games more important is stability in my opinion :)
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: How to fix fps?

Post by randomMesh »

hendu wrote:Not only do you shorten my play time from 5h to 2h (for example), you're also frying my balls unnecessarily ;)
This is a hardware/wetware problem. And Sleep is just a workaround to this. An unpredictable workaround.
"Whoops..."
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to fix fps?

Post by hendu »

Let's assume it was better for complex games to eat cpu without consideration. Then why is no big-name game like that? They all sleep to conserve cpu instead of wasting as much as they can.

When they don't, it's a bug: IIRC it was a blizzard game where there was no sleep in the main menu, even though there was one in-game. The main menu caused some graphics cards to burn out, Nvidias IIRC.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: How to fix fps?

Post by Mel »

For that matter, VSync does the same, it synchronizes with the refresh of the screen, so, it removes the flicker also. And you don't really have to do anything to keep things going at 60 fps because the VSync will force it for you.

what i have found, not obstant, and it is an odd or at least, unexpected behavior, is that when the scene becomes too complex, the screen like stutters, Fraps or even the FPS counter method will report me that it runs for instance at 100 or 95 FPS, but the screen will look like it is going at 30 or 40 or the like, but when the VSync is on, and everything runs at 60 FPS fixed, all goes smooth. Any explanation?

I guess this can be related somehow to the original question of the thread because, although it is a diferent scenario, the solutions may apply. Any idea?
Last edited by Mel on Sun Jul 08, 2012 4:22 pm, edited 1 time in total.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to fix fps?

Post by hendu »

Vsync only works when fullscreen. But yes, when fullscreen it's essentially the same.

(I really don't get the sleep hate. Does Windows suck that bad, ie when you tell it to sleep 6ms and the system is otherwise idle it still sleeps 500ms, skipping frames?)
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: How to fix fps?

Post by Nadro »

Yep, for the menu this method is ok, because unstable (in some cases may be very unstable) frame time isn't too problematic here, but in-game situation is different.

I don't think so that AAA games use a sleep method in a game loop (exclude menu, inventory, pause, dialogs etc. so everywhere where a screen is mostly a static, because here this method will be acceptable). As I remember I didn't see a sleep method in a DOOM 3 source code when I looked to a game loop in this game.

As Mel said, the best solution for a save hardware power. is to use Vsync and this is the most popular method for it.

UPDATE:
Yes, many frames are skipped because of it (a screen is like a freezed for a short time) :( What about a Vsync which doesn't work without a fullscreen? I think that on current environments (like an Unity, KDE, Gnome 3 etc.) playing is uncomfortable without a fullscreen, so today, a game = fullscreen for me :) And I think that many gamers thinking similar.

@Mel
I think that these stutters is a normal behaviour when we don't use a VSync. I saw it in many AAA games (eg. Company of Heroes), mostly in RTS when we move a camera over a world. In a FPS games this isn't visible. I tried a fixed time step etc. for it, but it didn't help too much, mainly because of a GPU works asynchronously I think. But if someone have a solution for this (another than a VSync) issue I will be thankful for it too.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Sir_Hans
Posts: 143
Joined: Sun Dec 06, 2009 2:23 pm
Location: Germany

Re: How to fix fps?

Post by Sir_Hans »

I limit the fps in my game to 60 at the moment when it's running in windowed mode but without using the sleep method. If another window is focused I use the sleep method to hold the CPU usage very low but still have around 60 fps. I don't know whether the solution is good but works for me.
keynet
Posts: 18
Joined: Wed Jun 27, 2012 9:07 am

Re: How to fix fps?

Post by keynet »

@Sir_Hans

How did you do that? Honestly, I thought the same way that other people said, "using sleep() with each framerate"... But I also think this method is not very efficient.

Anyway, thank you all for your answers! I will consider all of your advice
From Seoul, South Korea
Noiecity
Posts: 92
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: How to fix fps?

Post by Noiecity »

interesting
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, free and in an anonymous way if necessary. You can send me a private message.

https://www.artstation.com/noiecty
**
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to fix fps?

Post by CuteAlien »

Note about sleep and yield in Irrlicht. Basically sleep() on Window is really a bad idea for games as it always is around 15ms minimum. So one call and you limit your game to ~65 FPS which people with 144hz screens these days won't like. Yield in Irrlicht 1.8 was just as bad as it used sleep(1) so it had the same problem (reason for that was some Windows 98 behavior...). It got rewritten in Irrlicht svn trunk recently to use sleep(0) which on modern Windows just gives up the thread and doesn't sleep. That in combination with checking time in a loop could be used in theory to get a more exact sleep call which is still friendly to CPU.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Noiecity
Posts: 92
Joined: Wed Aug 23, 2023 7:22 pm
Contact:

Re: How to fix fps?

Post by Noiecity »

CuteAlien wrote: Mon Mar 11, 2024 10:57 am Note about sleep and yield in Irrlicht. Basically sleep() on Window is really a bad idea for games as it always is around 15ms minimum. So one call and you limit your game to ~65 FPS which people with 144hz screens these days won't like. Yield in Irrlicht 1.8 was just as bad as it used sleep(1) so it had the same problem (reason for that was some Windows 98 behavior...). It got rewritten in Irrlicht svn trunk recently to use sleep(0) which on modern Windows just gives up the thread and doesn't sleep. That in combination with checking time in a loop could be used in theory to get a more exact sleep call which is still friendly to CPU.
Thanks for the information Lord Cutealien
**
If you are looking for people with whom to develop your game, even to try functionalities, I can help you, free and in an anonymous way if necessary. You can send me a private message.

https://www.artstation.com/noiecty
**
Post Reply