Author Topic: Uneven Frame Output (Microstutter)  (Read 20409 times)

Offline Aquashark

  • Newbies
  • *
  • Posts: 48
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #15 on: December 02, 2010, 05:48:29 AM »
glad to hear a new version is coming.. the win7 fix will rock!

Offline Walk Cancel

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #16 on: February 03, 2014, 11:53:33 AM »
Windows 7 x64

MAME .152
Code: [Select]
   Number of frames =  3580
   Processing data...



 **************************************************************************

   Global Average Frametime (ms):     16.764
   ... ie Average Framerate (fps):    59.650

   Average Local Frametime Variation (ms):     0.034


   *** Average Microstutter Index (%) ***:     0.201

       Apparent Framerate is:                 59.530

 **************************************************************************

FBA 0.2.97.29, DWM Fix enabled
Code: [Select]
Number of frames =  3576
   Processing data...



 **************************************************************************

   Global Average Frametime (ms):     16.780
   ... ie Average Framerate (fps):    59.596

   Average Local Frametime Variation (ms):     4.243


   *** Average Microstutter Index (%) ***:    25.379

       Apparent Framerate is:                 47.533

 **************************************************************************

Is anybody having more luck than me?

Offline BoggleMinds

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #17 on: March 15, 2017, 07:33:23 AM »
It seems that the reported "micro-stutter" issues unfortunately aren't really fixed by the Win7 DWM toggle. I've always wondered if the stuttering is just an inevitable side effect of imperfect emulation taken by FBA when compared to say, MAME.

Another possibly related issue is of input lag - has anyone ever looked into input latency with FBA? I'm just curious because there are builds of MAME (e.g. ShmupMAME, GroovyMAME) that deliver greatly reduced input latency, presumably by re-writing parts of the input handling in the core engine with the goal of minimising latency. Is such an effort possible with FBA at all? How difficult would it be to modify the code to further reduce input lag? I ask because we have been using FBA for fighting game netplay for years and any benefits in this area would be extremely welcome.
« Last Edit: March 15, 2017, 07:38:47 AM by BoggleMinds »

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: Uneven Frame Output (Microstutter)
« Reply #18 on: March 15, 2017, 09:27:28 AM »
Try using Xaudio2 instead of DX for sound, that might help a bit.  Gab75 tells me he gets a near perfect 60fps (on games that are 60fps) using XAudio2.  Most games hover between 58 and 60fps for me, but I have an ancient pc. 

So I can look into it deeper, where can I get this tool to measure microstutter?  The link for this is long gone, it seems :( http://www.5group.com/wordpress/2012/07/14/gpu-mist-pre-release-1-0-rc1/  Archive.org brings it up, but not the file to dl.



Offline jan_klaassen

  • FBNeo Dev
  • ******
  • Posts: 315
  • Karma: +10/-0
re: input latency
« Reply #19 on: March 15, 2017, 02:49:54 PM »
There is a way to reduce input latency to essentially nothing. However, that will require each and every driver to be individually modified.

As to the micro-stutter, I suspect Dink is right in that it has to do with the synchronisation of the emulation with the audio stream. The X-Audio module handles that differently. The same thing can actually be done with DirectSound, too, and it will be in FBA. The only potential problem is that some bad sound drivers might not work with it.

Offline Gab75

  • FBNeo Contributor
  • *****
  • Posts: 1481
  • Karma: +33/-0
  • All games deserve to be emulated, more or less! :P
Re: Uneven Frame Output (Microstutter)
« Reply #20 on: March 15, 2017, 03:37:58 PM »
Try using Xaudio2 instead of DX for sound, that might help a bit.  Gab75 tells me he gets a near perfect 60fps (on games that are 60fps) using XAudio2.  Most games hover between 58 and 60fps for me, but I have an ancient pc. 

Yes, the XAudio2 plugin allows a more stable emulation than the DirectSound plugin... almost always all frames are rendered (100%)... :)

PS: I use a quite old intel I5 laptop (about 5 years old).

Offline BoggleMinds

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #21 on: March 15, 2017, 09:42:54 PM »
I just tried out the XAudio2 plugin, and it definitely seems to make a difference! I have no objective way to measure input lag, but it certainly subjectively feels like perhaps a 1 or even 2 frame reduction in input latency. Quite confident that it's not a placebo. I also noticed an improvement in the visual smoothness and reduction in frame "stutter".  It's great that FBA has the option of using a faster/more low level sound API as it really does make a difference in gameplay!

There is a way to reduce input latency to essentially nothing. However, that will require each and every driver to be individually modified.

I know next to nothing about emulation - can you elaborate a bit on what modifications to each driver would entail? Just wanting to understand what is theoretically possible (separate from whether it's actually feasible or not).
« Last Edit: March 15, 2017, 10:00:52 PM by BoggleMinds »

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Uneven Frame Output (Microstutter)
« Reply #22 on: March 15, 2017, 10:07:17 PM »
I just tried out the XAudio2 plugin, and it definitely seems to make a difference! I have no objective way to measure input lag, but it certainly subjectively feels like perhaps a 1 or even 2 frame reduction in input latency. Quite confident that it's not a placebo. I also noticed an improvement in the visual smoothness and reduction in frame "stutter".  It's great that FBA has the option of using a faster/more low level sound API as it really does make a difference in gameplay!

I know next to nothing about emulation - can you elaborate a bit on what modifications to each driver would entail? Just wanting to understand what is theoretically possible (separate from whether it's actually feasible or not).

Generally the inputs are compiled at the start of each frame. The cpu then reads the compiled inputs. If, in the time the cpu is doing work, the input changes, the cpu won't get that information until the next frame (generally 1/60th of a second).
You an reduce latency by compiling the inputs as they are read by the cpu. However, I'm not entirely sure fba polls the actual hardware inputs more than once a frame, so the whole point may be moot.


Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: Uneven Frame Output (Microstutter)
« Reply #23 on: March 15, 2017, 10:52:14 PM »
Generally the inputs are compiled at the start of each frame. The cpu then reads the compiled inputs. If, in the time the cpu is doing work, the input changes, the cpu won't get that information until the next frame (generally 1/60th of a second).
You an reduce latency by compiling the inputs as they are read by the cpu. However, I'm not entirely sure fba polls the actual hardware inputs more than once a frame, so the whole point may be moot.

It might be possible to have the driver re-poll the inputs in cases like this.  I wouldn't attempt it myself, but it can be done :)

best regards,
- dink

Offline BoggleMinds

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #24 on: March 15, 2017, 11:43:23 PM »
I find it really interesting what was done in the case of ShmupMAME:

From https://shmupmame.wordpress.com/about/:
A few months after making the MAME shmups input delay list. Pulsewidth pointed out that Raine could emulate most of the laggier games in mame with less delay, after investigation and clarification by PsikyoFan it turns out that mame emulates a frame/sprite buffer for most arcade hardware. What I found out is that this buffer can ?safely? be removed on most hardware with very little consequences. So after messing around with the mame drivers for a few days I got a first version ready for release.

Is anything similar applicable to FBA?

A few years ago some input lag tests were done to compare an old build of FBA from 2008 against ShmupMAME (I assume using Windows XP as the OS):
http://forums.shoryuken.com/discussion/comment/8133809/#Comment_8133809
The conclusion from the above tests was that FBA has an additional 2 frame latency compared to ShmupMAME.

So in the case of MAME it was a combination of the core engine having frame/sprite buffers (introducing lag), plus additional per-driver optimisations that resulted in the greatly reduced latency. In the case of Super Street Fighter 2 Turbo (SSF2T), the base input delay of the game itself as measured on arcade is 4 frames. Now I'm really curious as to what optimisations might be possible at the driver level to get the input polling to be truly "next frame". I'm really only concerned with CPS2 emulation, so I took a quick look at cps_run.cpp, especially the Cps2Frame() function, but being unfamiliar with the source I have no idea if this is the right place to be looking at...

One thing that I haven't tried yet is to toggle the "Max frames to render ahead" setting (nVidia) from its default of 3 to 1. Presumably this also helps further reduce input lag and gets us that bit closer to the holy grail of arcade input latency.  :biggrin:
« Last Edit: March 16, 2017, 01:49:46 AM by BoggleMinds »

Offline jan_klaassen

  • FBNeo Dev
  • ******
  • Posts: 315
  • Karma: +10/-0
Re: Uneven Frame Output (Microstutter)
« Reply #25 on: March 16, 2017, 03:44:23 AM »
You an reduce latency by compiling the inputs as they are read by the cpu. However, I'm not entirely sure fba polls the actual hardware inputs more than once a frame, so the whole point may be moot.

I was thinking of something way simpler. Most (if not all) games will poll inputs in the vblank interrupt code. So, instead of starting each frame of the emulation at the 1st scanline of the frame, start at the point where the vblank interrupt is triggered (whereever that is). Then continue until the next vblank interrupt and draw the frame. There you go, input lag is gone.

It's certainly possible in theory to update inputs in real-time, but also pointless -- the emulation happens in, say, 10% of real time...

Offline BoggleMinds

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #26 on: March 16, 2017, 03:52:53 AM »
As a bit of an update, the nVidia driver setting  "Max frames render ahead" to 1 (default is 3) seems to have made by far the largest difference of anything I've tried so far. Running fullscreen (to bypass DWM), experimental blitter and XAudio2 all helped a bit, but this simple fix really takes the cake in terms of making everything that much more responsive.

It makes sense if what has actually happened is a linear reduction of -2 frames (32ms) of input lag basically for free! I'll start evangelizing the virtues of setting this value (or ATi equivalent) to all FBA users.  :biggrin:

Offline Walk Cancel

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Uneven Frame Output (Microstutter)
« Reply #27 on: August 12, 2017, 08:54:51 AM »
So I can look into it deeper, where can I get this tool to measure microstutter?

Try Frafs Bench Viewer.