views:

39

answers:

2

I was contemplating the fact that inflicting frame per second restrictions is not ideal in regards to latency and performance since a monitor still has a chance to show something sooner (assuming no vertical sync which is mainly for stability).

However, it occurred to me that process might have ramifications on audio subsystems (or also input devices), assuming frames per second also governs the global loop of the engine itself (the case in almost all 3D accelerated applications).

Do audio cards/audio devices on an operating system have a concept of "Hertz" that might be related? Do we assume the faster the global loop of the application the better the latency for the audio subsystems?

+2  A: 

Typically the game processing and the display aren't coupled, so reducing the FPS of the display won't affect the central game processing, which would include things like input (and presumably audio).

This article explains it pretty well, including different options for having FPS linked to game speed or not.

Grant Crofton
This is an amazing Article. It's not what I asked at all but it's better.
Lela Dax
Uhm, I think I spotted a potential loohole in the article. He dismisses the very 1st case as something simplistic and wrong while he could have had timing implementation on the gameplay() itself and avoid any throttling whatsoever.
Lela Dax
Good article, though I think he's one of those guy who likes it that the game eats every bit of CPU it can get, just for more FPS. But he's correct, interpolation is the only way to do it right, especially when it comes to multiplayer/online games where you might have to deal with the fact that certain objects only get updated a few times per second. But keep in mind that prediction and interpolation can get fairly complicated in such cases.
Ivo Wetzel
@Lela Dax - I wouldn't say he dismisses it, just points out some pretty serious problems. One of the problems with having FPS and gameplay linked in that case is if the machine is struggling, everything will slow down together, so things like how far a character moves according to input will also change. It usually gives a better experience to have the game speed constant, with the FPS getting worse if the machine is slow.
Grant Crofton
@Ivo Yeah, to be honest I've never done this, I used something like option 3, which is fine for a lot of cases.
Grant Crofton
Yes but, if one thinks CPU power has to be throttled to save power or be comfortable with other processes, that's a different subject which he does not cover since he assumes it's either a fast machine or a slow machine (with efficiency of the engine being needed). If the problem he sees on the first case is timing then he can simply do timing on the game logic and leave everything else unthrottled (not even the loop of the game logic, since it would be covered explicitly by its timing considerations). If the problem is power saving, it can be done explicitly elsewhere.
Lela Dax
What could make it more efficient is throttling either game logic or rendering merely for giving more 'powah' to the other. This can be done in cases where e.g. 'audio calc needs better latency, take more from rendering'. etc.
Lela Dax
True, throttling the processor to let other processes work isn't really considered, but I think in most cases it's assumed that people are using only the game and that the game should use all resources available. This seems to be the case he's addressing, anyway - although option 1 does allow for other processes while the game loop is sleeping. And timing the game and leaving the display to run is what he describes in the 3rd option.
Grant Crofton
Also consider that there may well be a GPU for graphics, so 'routing' processing power around may not be feasible, regardless of whether it was possible or a good idea.
Grant Crofton
On 'GPU for graphics'; well I meant even with a GPU one can simply delay it with timers to give more CPU time to game logic, if that is desired (I had a GPU in mind actually).
Lela Dax
+3  A: 

Audio is not typically affected at all. The audio has a separate buffer which you fill up in advance, maybe a hundred milliseconds or more, and the sound card plays back from that regardless of what your game loop is doing.

It is possible, if you fill that buffer in your game loop, that taking too long to get back to the game loop will result in the sound buffer being empty and a looping sound being heard. To avoid this, developers will either use a big buffer or fill the buffer from a background thread.

As you might guess, audio is already running at some sort of latency, proportional to the amount of data in the buffer that the game attempts to keep in there at all times. This is usually not so noticeable since sound takes a non-negligible time to travel in real life anyway. Pro audio applications have to keep this buffer small for low latency and responsiveness, but they don't have graphical frames to worry about...

As far as input, yes, it is often affected. If a game does not decouple the rendering rate from the input handling rate, then there will be some additional latency on the way in. There will always be some additional perceived latency on the way out too, if you consider input latency as the length of time between performing an action and seeing it take effect. But that perceived latency may well be larger than the simulation latency, since the affected entity may have been altered at an earlier timestep than the one displayed in the next frame.

Kylotan