Jump to content



Photo
* * * * * 1 votes

Technical information on frame lag/stutter in VP


  • Please log in to reply
12 replies to this topic

#1 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 07 March 2014 - 09:37 PM

Be warned: this is highly technical stuff and probably only useful to other devs, if at all. But it took me so long to figure out that it would be a shame not to preserve somewhere for later reference. A wiki would be the perfect place for stuff like this, but oh well.

 

To understand this post, some familiarity with GPUView is required. It's a great tool but not exactly intuitive to use. Here's an introduction by its programmer: http://graphics.stan...er/GPUView.html

 

So here's a GPUView capture of VP9_DX9_test7 when starting a particular table:

 

Attached File  Screenshot 2014-03-07 22.54.14.png   393.2KB   23 downloads

 

The red vertical lines are the Present() intervals, i.e., basically the times when a frame is rendered. We want these to be as equidistant as possible in order to have constant FPS and smooth gameplay. In the left part of the screenshot, this is not the case: there are often gaps between the regular intervals. In the right part, everything is completely even and smooth.

 

So what happened between the "bad" and the "good" part? The answer is: a ball was launched onto the table.

 

To understand why this smooths out the framerate, we have to look at the reddish/purple peaks and valleys. These are the command buffers VP submits to the D3D runtime. Since VP is GPU-bound in its DX9 incarnation, the CPU has an easy time completely filling the existing buffer, so up to 4 frames are pre-rendered at the start of the above chart. This manifests itself in the high reddish peak in the left part. Now, this part I still don't understand completely, but I assume that somehow when this buffer gets too congested, either VP or the D3D runtime skips a beat and a laggy frame is introduced. These are the gaps between Present calls which are felt as stutter.

 

In Test7, balls still used a static vertex buffer which was locked every frame, something you shouldn't do in general. The reason is that this stalls the CPU until the vertex buffer in question isn't needed by the GPU anymore. In our graph, however, this kind of turns out to be a good thing: the GPU can catch up while the CPU stalls; only one frame worth of drawahead is produced; the command buffer queue isn't congested anymore; and we get a stable framerate without stutter.

 

In Test8, I changed the ball rendering to use a dynamic vertex buffer. This eliminated the pipeline stall and increased the FPS, but now the whole plot would look like the left part above, and we get stutter even after the ball is launched.

 

So in the upcoming Test9, I introduced a new mechanism which artificially creates a partial pipeline stall and produces a similar behavior as the right part of the above chart consistently, but without decreasing the framerate unnecessarily when multiple balls are in play. As an added benefit, this also reduces the latency (input lag).

 

All of this is tested only on Nvidia and Windows 7. I have no idea if and how this is relevant on AMD cards. So this is a very experimental change at this point and might well make things worse for some people.

 

Thanks to jimmyfingers for first noticing this particular form of stutter and sending me on this wild goose chase in the first place.


Edited by mukuste, 07 March 2014 - 09:39 PM.


#2 LoadedWeapon

LoadedWeapon

    The Night Owl..

  • Members
  • PipPipPipPipPip
  • 2,562 posts
  • Location:South Carolina USA

  • Flag: United States of America

  • Favorite Pinball: Star Trek TNG



Posted 07 March 2014 - 10:40 PM

cool read and it makes sense.. Tho I havent really noticed any stutter on 8a I know some people have and we all appreciate the extra mile you have went to make this the best it can be.. Thanks!  :love39:



#3 boiydiego

boiydiego

    Pinball Fan

  • Members
  • PipPipPipPip
  • 978 posts
  • Location:baal

  • Flag: Belgium

  • Favorite Pinball: flinstones,t2 chrome edition,wcs,afm,fish tales,medieval,rollercoaster tycoon,taxi

Posted 07 March 2014 - 11:02 PM

go get the stutter :love39: :love39:


boiydiego___gebruik-n2kbkyc.png


#4 bodydump

bodydump

    down and out

  • VIP
  • 578 posts
  • Location:California

  • Flag: United States of America

  • Favorite Pinball: High Speed, Creature

Posted 07 March 2014 - 11:06 PM

Thanks mukuste and JF for working to fix the stutter. All the features and eye candy in the world are worthless if the game stutters even a little.  It ruins the gameplay and the immersive experience.  So again, many, many thanks.



#5 DJRobX

DJRobX

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 941 posts
  • Location:Valencia, CA

  • Flag: United States of America

  • Favorite Pinball: F14 Tomcat

Posted 07 March 2014 - 11:08 PM

Interesting...

 

NVidia has a setting for maximum pre-rendered frames.   I've always set this to 1 because it's known to improve responsiveness in Pinball FX2 and Pinball Arcade.   Would that affect this at all?   



#6 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 08 March 2014 - 12:07 AM

Interesting...

 

NVidia has a setting for maximum pre-rendered frames.   I've always set this to 1 because it's known to improve responsiveness in Pinball FX2 and Pinball Arcade.   Would that affect this at all?   

 

I thought that it should do exactly this, but I tried it and it didn't seem to have any effect. So either I'm misunderstanding that setting or it doesn't work for VP for some reason.



#7 LoadedWeapon

LoadedWeapon

    The Night Owl..

  • Members
  • PipPipPipPipPip
  • 2,562 posts
  • Location:South Carolina USA

  • Flag: United States of America

  • Favorite Pinball: Star Trek TNG



Posted 08 March 2014 - 12:31 AM

i do have mine set to one as well..



#8 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 08 March 2014 - 12:45 AM

i do have mine set to one as well..

 

Can you tell a difference in VP? At the very least it should lower the framerate.



#9 chinzman93

chinzman93

    "All humans are vermin in the eyes of Morbo!"

  • Platinum Supporter
  • 403 posts
  • Location:Here

  • Flag: United States of America

  • Favorite Pinball: Fish Tales, BSD, AFM

Posted 08 March 2014 - 01:10 AM

If you need someone with an AMD card to look at something let me know. I don't know how deep of an AMD card pool we have around here. I know Fuzzel used to run one, maybe still does. I have the same version he had/has. I am sure there are others as well, but NVIDIA cards are pretty dominate around here.

 

However, I have always found that the simplest solution for stuttering in any game is to just pretend you are blinking...... :P



#10 The Loafer

The Loafer

    Pinball Wizard

  • VIP
  • 3,468 posts
  • Location:Embrun, Ontario, Canada

  • Flag: ---------

  • Favorite Pinball: Superman, Firepower & Tron



Posted 08 March 2014 - 01:40 AM

Awesome post, makes sense and looking forward to testing this out. I am very curious at the input lag comment, as if that actually gets improved, I think I will freak out (in a good way) because it's pretty awesome right now!

#11 LoadedWeapon

LoadedWeapon

    The Night Owl..

  • Members
  • PipPipPipPipPip
  • 2,562 posts
  • Location:South Carolina USA

  • Flag: United States of America

  • Favorite Pinball: Star Trek TNG



Posted 08 March 2014 - 01:46 AM

well i have always had it set to one.. but i just tried it on default and the fps is the exact same.. so dont look like it does anything for VP

 

i do have mine set to one as well..

 

Can you tell a difference in VP? At the very least it should lower the framerate.

 



#12 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 08 March 2014 - 02:06 AM

 

well i have always had it set to one.. but i just tried it on default and the fps is the exact same.. so dont look like it does anything for VP

 

Yeah, I found the same. Anyway it's more convenient to have a built-in solution, and doesn't require the user to fumble around in any control panels, which most people won't do.


Edited by mukuste, 08 March 2014 - 02:07 AM.


#13 MadBit

MadBit

    Neophyte

  • Members
  • Pip
  • 4 posts

  • Flag: United States of America

  • Favorite Pinball: Monster Bash

Posted 08 March 2014 - 04:48 AM

I just thought I'd add my experience to this FWIW. My system is modest by most people I've seen on here. Athlon 64 X2 6000+ (3.10GHz), 8GB RAM, Radeon HD 6670 1GB. Using DX9 8a I get great results with adaptive vsync set to 1 (auto). Set to 0 I get high frame rates but ball stutter.

 

For example running Monster Bash (2.1) (FS)  w/adaptive vsync = 0 from VP:

FPS: 197.8 FPS(avg): 191.8, period: 4.6ms (5.2 avg 7.5 max) and get horrible stutter

 

Same table w/adaptive vsync = 1:

FPS: 60.0 FPS(avg): 60.0, period: 16.5ms (16.7avg 18.6 max) and I have no stutter, butter smooth.

 

No extra tweaks. Driver defaults. No FXAA. Windowed 1920x1080.