• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Frank Force

Expert question: How to get a better time delta?

30 posts in this topic

That fraps article was interesting reading, but using fraps to capture all the images that come out of the app is still valid, which lets you spot some stuttering issues (like my duplicate frames problem).
At my last job, we used external HDMI capture and high speed video of a CRT to help diagnose other timing issues as well.

With regards to predicting future timing, you can't *in general*.
If you're vsync'ing, and you're always under your frame-time budget, then you can... But if you start missing vsync intervals, your timing won't be perfect around those points in time. E.g you might have advanced the simulation 16.6ms, but displayed that image 33.3ms later, so the animation will be 16.6ms back in time from where it should be.
Also, whether your CPU or GPU (or both) is over it's frame time budget makes a big difference as to whether stuttering can be absorbed by buffering.

On the last console game that I shipped, we sync'ed to a 30Hz refresh, but in some scenes it was possible for us to miss that window. If a frame was late, we'd temporarily disable vsync (and get tearing at ~30-20Hz) while also reducing the internal rendering resolution in the hopes of getting GPU frame time back down to 33ms... So sometimes it would be possible for us to get perfect timing, but other times we had all the issues of a variable frame rate game :(
0

Share this post


Link to post
Share on other sites

You don't have to always be under frame-time budget to not get stutter.  If you are triple buffering you can have a long frame that is over your frame time budget as long as your next couple frames are fast enough to keep up and eventually put it far enough ahead to buffer out the next skip.  In my experience the OS will not normally eat up that much time especially when running in full screen mode.   The sacrifice is latency, that's what the triple buffering smooths out.  It is running 1 frame ahead (hopefully) so that when you lose a frame it won't stutter, it just gets less latent and when it drops that frame it will need to work faster to catch up.

 

Ok, I thought of a different way to explain the issue...

 

Lets say I'm writing a story at the same time you are reading it.  You read at exactly 60 pages per hour, in fact you read so precisely that every minute on the dot you finish the old page and start reading a new one.  I can write much faster then 60 pages per hour, maybe even twice as fast but sometimes I need to slow down to think and write much slower.   Problem is we only have 3 pieces of paper to share between us and I can't write on the same page you are reading.  To make matters worse we are in different rooms and can't see each other.  We have a helper who brings my new papers to you and your old papers back to me, but there is a bit of variance when we actually get that paper from the other person.   I can magically erase papers instantly when I get them.  Also we don't have synchronized clocks or any other way to communicate.

 

The question is can I keep feeding you papers without you every stalling out with nothing new to read?  The answer is pretty obviously yes I can as long as I don't fall too far behind because we have an extra paper to use as buffer.  As long as I keep that extra paper/buffer full I can take almost twice as long to write one page and we won't even miss a beat because you will just read the buffer while waiting.  After that happens I need to work hard to get that buffer full again, it might take a few pages before I am back on track but the important thing is you didn't have to stop reading.

 

We can also work the time delta thing into this.  Lets say we want every paper to have a time stamp on it.  We want those time stamps to be exactly 1 minute apart from each other because maybe in the story I'm writing each page accounts for exactly 1 minute of time in the fictional world I'm writing about.  Well I don't write pages at exactly 1 minute per page but I can just start with time index 0 and increment it by 1 minute for each page even if it takes me more/less then 1 minute to write it.  Basically I know that I need to write each page to represent 1 minute of fictional time regardless of how long it takes to write.  As far as you know the time stamps are correct and exactly 1 minute apart regardless of our relative times. Since you are reading at exactly the same rate as the time stamps then to you it will appear that each time stamp matches up with your own time.  The story you are reading represents 1 minute per page in the fictional world and it takes you exactly 1 minute to read each page. I'm writing you a story for you in real time and passing it back and forth without any stutter and only 3 pages to share.  It seems so simple when you think about it like that.  This is really no different then simulating physics on a computer and rendering with that specific interval rather then what time was measured between updates. 

 

With double buffering the situation gets a little worse.  We would only have 2 pieces of paper which means I always need to write faster then you can read plus enough to cover any variance we have when passing papers back and forth.  With a single buffer I'm basically writing to the same page you are reading, erasing the lines as I go.

 

Anyway I hope that helps someone understand a bit better what is going on. Or if I'm not making any sense, please let me know!

Edited by Frank Force
0

Share this post


Link to post
Share on other sites
Yeah, but just change 'missing a vblank to' missing 2 in a row, or 3 in a row, etc and the same issue presents itself. At the transition from one frame rate to another, the correct timing to advance the simulation by is unpredictable.

Situations where a single-frame is over budget can be fixed usually as they're usually caused by some single expensive operation that's obvious to spot. In other situations where you miss your frame time budget, it's usually because there's simply 'too much stuff' in the sim / visible scene at the moment, and you'll keep missing the budget until the scene changes.
0

Share this post


Link to post
Share on other sites

If you write a decent game engine there is no reason why you should EVER have a frame that takes more then twice as long as your vsync.  If that is the case you need to either lower your worst case scenario (reduce geometry, particle counts, or whatever is killing it) or smooth out the computation so it's distributed over many frames (async collision tests, staggered ai).  Also you can always add more buffers which will increase latency but give you another frame of buffer time.  Obviously that is undesirable but if we think about trying to run at 120 hz it might make sense to have 4 or more buffers since each frame is only half as long.

 

Stutter really has nothing to do with the OS or variance in timing or any of that.  Developers blame it on that because they don't understand how things actually work.  As a developer you have it within your power to completely eliminate the stutter.  If your game is running slow then it needs to be optimized.  If your game runs fast but still stutters it's your own fault.

Edited by Frank Force
0

Share this post


Link to post
Share on other sites

If you write a decent game engine there is no reason why you should EVER have a frame that takes more then twice as long as your vsync. If that is the case you need to either lower your worst case scenario (reduce geometry, particle counts, or whatever is killing it) or smooth out the computation so it's distributed over many frames (async collision tests, staggered ai).

If you're saying that every game should be able to run at 60Hz, that's not really true - for example, the vast majority of PS3/360 games run at 30Hz, because it basically allows there to be twice as much 'stuff'/detail on screen.
For many games, there is definitely a point where you just decide that 60Hz on your target hardware is not feasible / worth the sacrifices, and set your target as 30Hz.
Surely you've been in one of these situations in your career?

To use a "pick 2 out of 3" analogy, you've got quality, quantity and frame-time. Sometimes the content creators (not the game engine team) will want quality and quantity at 30Hz, rather than halving one to get 60Hz. In the real wold there's also dev-time, maybe you want higher quality, but want lower dev time more...
At a 60Hz refresh, they key frame-rates are 60, 30 and 20Hz, matching 1, 2 and 3 vblanks worth of time.
If we say it's normal to take between 1 to 2 vblanks to render a scene (i.e. a target of 30Hz), then it's possible for a very small addition by the content team to push the frame time out to being just over 2 vblanks, into the 2-3 window, which results in a 20Hz display. It's very easy to imagine a situation where this happens but no compromises to quality/quantity are allowed by management, which only leaves an increase in development time for the engine team to find some magic optimization to make this new content possible at 30Hz. It's also easy to imagine a situation where there is simply no time/money spare for this engine task, so the game ships with some scenes that drop to 20Hz... That's an understandable thing that happens, and sometimes it might be the right choice.

On PC, we've also got to deal with variable hardware. Imagine:
• on our lowest settings on a target PC, our frame times are 10-15ms depending on the scene, resulting in a smooth 60Hz.
• on a low-end PC, frame times are 20-30ms, resulting in a smooth 30Hz.
• on a slightly better than low-end PC, frame times are 15-25ms, resulting in either 30 or 60Hz, depending on the scene.
There's a whole, near continuous, spectrum of hardware out there with different performance characteristics (e.g. on one GPU, your code might be bottlenecked by ALU, but on another it's bottlenecked by bandwidth - often you can't optimize fully for both), and different refresh rates, so there'll be someone who's frame times will be sitting dangerously close enough to a vblank interval to be osscillating across that boundary as the scene changes. The only way to avoid that is to force a fixed frame time ("30Hz for everybody!!!") or not use vsync. To be polite, your game should give the user the option whether to use vsync or not...
0

Share this post


Link to post
Share on other sites

I am not saying that all code should be perfect and every game should run perfectly at 60 fps in every situation!  What I'm trying to say is that as a developer if you want to make a game that runs at 60 fps without stuttering it is possible.  The thing is that people say that stutter is unavoidable regardless of how good your system and graphics card is.  I say it is very avoidable, and actually fairly easy to eliminate for high end systems.  If I'm running your game on an awesome computer that is well above spec it shouldn't stutter.  Yet most games do.  That is all I am saying. 

 

Most console games run at 30 even though HDTV is 60.  That is fine, basically they have decided to ignore every other vsync and pretend their vsync is 30 which changes nothing.  The point is they chose to run at 30 and if they are stay at a solid 30 it should look pretty smooth, any stutter is only introduced by their poor code/planning.  If it has situations where it drops to 20 fps and there's no time to fix it that does suck and maybe it is the right decision to just move on and fix higher priority issues.  But the fact is the reason it dropped to 20 is because of all the bad decisions that led up to that whether they were programming, design or art decisions.  It's certainly not the console's fault if you get stuttering or fps drops when you are in such a predictable environment.

 

When you are making a PC game, of course people can run it with low end PCs and it might run really shitty.  That is not what I am talking about at all.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0