• 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
cozzie

How long is your average frame?

8 posts in this topic

Hi,

 

I've been profiling my DIY 3d engine after doing some major improvements on my renderqueue. With this I'm using pix.

The results per frame are somewhere between:

 

100.000.000 and 200.000.000 duration (FPS 5.1?)

 

I'm assuming that these are nano seconds, coming down to 0.1 to 0.2 seconds per frame.

With 60 fps I'd assume without skipping frames, a frame should take 1 / 60 = 0.016 second.

 

A few questions:

- are these assumptions correct?

- if so, why does it seem to run so 'flawless' with somewhere to 6 FPS?

- how can I see in PIX if I might be CPU versus GPU bound?

- how lang are your average frames taking, with similar measurements?

 

Ps.; I'm not aiming to start off and go optimizing, because I don't have performance issues with the current scenes and things I'm doing. Just curious and wanting to understand the measurements. Here's a screenshot of a captured frame in PIX.

 

PIX_captured_frame.jpg
 

0

Share this post


Link to post
Share on other sites

There are 1,000,000,000 nanoseconds in a single second so a frame time between 100 and 200 nanoseconds would corresponding to an fps between 10,000,000 and 5,000,000.  This is highly unlikely.  I believe PIX can be configured to display times in cycles, milliseconds, microseconds and possibly other units.  I'm only familiar with PIX for the 360 which I routinely switch between displaying cycle counts and milliseconds elapsed.  Poke around the GUI to figure out how to do this or search the documentation.

 

It's possible your measured frame time of 100 and 200 is actually in microseconds corresponding to a frame rate of 10,000 to 5,000 fps.  This is still extremely high and therefore suspicious.

 

An average frame rate is somewhere between 16 and 33 milliseconds roughly corresponding to 60 to 30 fps.

Edited by nonoptimalrobot
0

Share this post


Link to post
Share on other sites
Thanks. If somewhere between 16 and 33ms roughly corresponds to 30 up to 60fps, then my 100 to 200ms for a frame would be 'bad'/ quite slow?
(when I reach almost 200, in the screenshot above, the FPS column says 5.1 fps)

Not sure if I understand correct, but this tells then that having between 16.000.000 and 32.000.000 measured time for a frame would be between 30 and 60fps. Have to fid out what's going wrong then, the number of state changes, shader constant sets and drawcalls is not that high (even quite low then I reach 100ms, with 6 esh instances, 3 different materials and one shader/ effect, single pass).
0

Share this post


Link to post
Share on other sites

Thanks. If somewhere between 16 and 33ms roughly corresponds to 30 up to 60fps, then my 100 to 200ms for a frame would be 'bad'/ quite slow?
(when I reach almost 200, in the screenshot above, the FPS column says 5.1 fps)

Not sure if I understand correct, but this tells then that having between 16.000.000 and 32.000.000 measured time for a frame would be between 30 and 60fps. Have to fid out what's going wrong then, the number of state changes, shader constant sets and drawcalls is not that high (even quite low then I reach 100ms, with 6 esh instances, 3 different materials and one shader/ effect, single pass).

 

Yeah, somewhere things are going wrong.  I can't deduce much from your PIX screen grab but you appear to be creating a 1920x1080 surface every frame?  That's probably not necessary and would definitely slow things down.  There is also some locking and unlocking of a surface, maybe the same surface?

0

Share this post


Link to post
Share on other sites

Thanks, I've been playing around with PIX and found the following things:

- the screenshot above was where I captured one single frame (with F12)

- when I do a 'run' (record it), and look at individual frames during the run, they all appear around 16 milliseconds

(a few examples: 16.671.232, 16.522.240)

- I found out about the creation of the surface... too stupid, F12 in my engine creates a screenshot ...., changed that now

 

I see now that a single frame goes down from about 15ms up to 90ms (90ms for a more 'complex' scene).

 

I have a FPS timer updating each frame, giving a certain speedfactor, this factor is multiplied by the amounts of movement, freelook etc. The requested 'speed' I set here is 50fps. But this shouldn't affect the framerate in rendering I'd think.

 

Although it seems to 'strange' that almost all frames hit around 16ms, when I record a run.

Edited by cozzie
0

Share this post


Link to post
Share on other sites

Although it seems to 'strange' that almost all frames hit around 16ms, when I record a run.

 

sound like wait for vsync is turned on. at 60Hz refresh rate, your monitor runs at 60 fps = 16.666 ms per frame. with wait for vsync turned on, the monitor's refresh rate acts as a frame rate limiter. this keeps the game from running faster on faster pc's.   since the monitor only copies the vidram to the screen at 60 fps, there's no reason to draw faster. so you get 180 fps? who cares! all that means is you write to vidram 3 times and then the monitor copies to the screen once. the other two writes are lost (overwritten before they can be displayed).

 

anything longer than 66ms per frame (15 fps) will be unplayable. your 200ms scenes will need work (scene simplification and / or code optimization).

 

if you're not rock steady at 16ms all the time for all scenes (or 33ms or whatever you choose), a variable time step may cause problems as well.  variable time steps do not degrade gracefully under heavy load.

 

note that the traditional targets speeds of 30 and 60 fps were originally based on light weight shooters with an emphasis on animation smoothness over scene complexity and simulation depth.  games can actually run as slow as 15 fps and be sufficiently responsive to not inhibit game play.

 

i actually target 15 fps, which gives me 66ms to put some serious game behind those frames i'm drawing - or the time to draw complex scenes (like 100 animated characters onscreen at once).

Edited by Norman Barrows
0

Share this post


Link to post
Share on other sites

Thanks for clearing up, sounds clear. I'll turn V-sync off just to see the difference and as practice (and then back on).

 

The strange thing is that I only get higher frame times when I capture a single frame with PIX (somewhere from 16ms up to 90ms).

But when I record a certain amount of time, I actually can only find frames with about 16ms (or 1 or 2 ms lower).

Not sure of PIX does something different when I capture just one frame. Doing this is definately usefull to profile settings shader constants, states etc.

 

pix_run.jpg

By using PIX I actually found quite some 'stupid' things I was doing, setting materials that don't have any meshes (instances) visable. Selecting meshes (indices/ streamsource), for meshes that have no visible instances at al. and more and more :)

 

One thing I don't understand yet using PIX, is how 'to read' the bar on top, showing you the load on CPU and GPU. To figure out if the CPU is 'frames' ahead or of the GPU is idling. Telling me I could do less on the CPU side, and more to the GPU etc.

 

If anyone knows how 'to read' this....

Here's an example of my 'run':

 

pix_cpu-gpu.jpg

0

Share this post


Link to post
Share on other sites
Update; I've tried it without v-sync, then my framerate goes from 60 up to around 600fps, but offcourse my time delta is messed up :) turned it back off and did no further profiling.

I'll just do a check once in a while if I keep hitting up to around 16ms per fame.

Any advice on understanding the gpu/cpu load in PIX is still appreciated
0

Share this post


Link to post
Share on other sites

Found it, I didn't enable 'Statistics for each frame, using counter set'.

My conclusions:

 

- in about 95% of all frames, it looks fine, GPU is just a bit later than the CPU (blue means 'rendering a packet of work sent by the CPU').

The difference in the timeline looks fine to me

- in some exceptions there's some red (GPU blocked, waiting for a resource) or grey (GPU is idle)

 

If I'm interpreting wrong, please let me know.

For now I'm happy with the results and going back to introducing nice and fun new stuff :)

 

pix_cpu_with_gpu.jpg

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