Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Counters: Tighten tolerances on framelimiter #3785

Merged
merged 3 commits into from
Oct 6, 2020

Conversation

RedPanda4552
Copy link
Contributor

@RedPanda4552 RedPanda4552 commented Oct 4, 2020

Smooths out frame pace and keeps average framerate closer to target.

Comparing PCSX2's old framelimiter with RTSS showed there was room for improvement. Frametimes regularly would jump up and down in various situations. This PR smooths out frame pace substantially (easily visible in RTSS) and, drum roll please, may appease the input lag folks for a time. We'll find out.

Extensive user tests required; some vsync functions were shuffled around, and this was tested on a high performance system. We should test low end systems, and a wide variety of games to make sure there are no outlier games that needed the old behavior for some reason.

Shoutout to Refraction for greasing the wheels and helping with the various vsync aspects.

Before (above) and after (below) of Xenosaga Ep. 1 save point inside the Elsa:
image

Smooths out frame pace and keeps average framerate closer to target.
Fixes graphics issues in some games
@MrCK1
Copy link
Member

MrCK1 commented Oct 4, 2020

Example comparison of master (top) vs PR (bottom) - Midway Arcade Treasures title screen

Master:
image

PR:
image

@MrCK1
Copy link
Member

MrCK1 commented Oct 4, 2020

Bonus
R&C3 (Obiani Draco)

Master:
image

PR:
image


// If any integer value of milliseconds exists, sleep it off.
// Prior comments suggested that 1-2 ms sleeps were inaccurate on some OSes;
// further testing suggests instead that this was utter bullshit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true and might compromise accuracy a bit - it's worth running a test without sleep at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested the theory, it does indeed make it smoother, how noticeable it'll be though is any bodies guess

sleepmsecs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other games such as SotC don't seem to care too much
sleepmsecs2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be that those games don't hit the condition for a sleep?

Copy link
Member

@refractionpcsx2 refractionpcsx2 Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run at well above the frame cap in those games. I get about 70fps in SotC, so there should be about 3.334ms (maybe 2.5ms, my calculation may have been off) my CPU is waiting every frame.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another look at the Xenosaga Ep. 1 Elsa save point. Master (top), msec >=1 then sleep(msec) (middle), msec > 1 then sleep(msec - 1) (bottom). I think we have our winner.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good approach, but I would go even further and make it something like msec - 3 or even 5. The threshold has to be pretty big or else you'll always risk people losing time on those e.g. due to running on a laptop battery.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I don't recommend people run the emulator on a laptop and if they do they should be using high performance mode and not running off battery (that's a really dumb idea :P) I'm honestly not concerned about people crazy enough to do that, it will still be head over shoulders above master (which was 1ms buffer)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that should be good enough as a starting point and could be revisited in the future if it's ever needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using a gaming laptop plugged in with high performance mode and it does improve significantly on specific games, u could stare blindly at squeezing an extra 5%-10%.

@CookiePLMonster
Copy link
Contributor

NASCAR Heat 2002 had good frametimes during the race, but entering a pit lane resulted in frametimes being all over the place:
image

With this PR, it doesn't seem to occur anymore:
image

@Dreadmoth
Copy link
Contributor

A different test (Drakan: The Ancients' Gates with FrameratePAL=119.98)

Master:
Master120
PR:
PR120

👍

@RedDevilus
Copy link
Contributor

RedDevilus commented Oct 4, 2020

All tested on default settings (commit-93823a3)
Game 1 Baroque;

Master:
image

PR:
image

Game 2 True Crime NY (Game needs a patch/fix);

Master:
image

PR:
image

Game 3 Prince Caspian Chapter 2;

Master:
image

PR:
image

Game 4 Rogue Galaxy;

Master:
image

PR:
image

@RedPanda4552
Copy link
Contributor Author

Another change has just been pushed that should (sometimes) tighten this up even further.

@MrCK1
Copy link
Member

MrCK1 commented Oct 4, 2020

Some more testing with new changes (I'll edit if I find anything substantial)

CoD Finest Hour (PR on top, master on bottom)
image

@RedDevilus
Copy link
Contributor

Latest PR (8aaae36)
Prince caspian Chapter 2
Seems an improvement did happen.

image

@Dreadmoth
Copy link
Contributor

Ratchet & Clank 2
RC2frametime

Champions - Return to Arms
CRTAframetime

Metal Arms - Glitch in the System 💯
MAframetime

@RedDevilus
Copy link
Contributor

Added more examples along with my system info

Laracroft Legend:
LaraCroftLegend-3758

Alter Echo:
AlterEcho-3758

FinalFantasyX:
FinalFantasyX-3758

FinalFantasyX-2:
FinalFantasyX-2-3758

@RedPanda4552
Copy link
Contributor Author

Has anyone checked Linux? RTSS is not available but at least to make sure stability is still good?

@RedDevilus
Copy link
Contributor

RedDevilus commented Oct 4, 2020

Examples when i change the msec

if (msec > 1): (original PR)
image
if (msec > 2):
image
if (msec > 3):
image

@RedPanda4552
It reduces spikes a bit more, but i'll let you decide what you want to do with it.

Seems it's my setup only. (Laptop)
Visual Studio 2019 makes the frametime worse, closing/closed is recommended.

@auscompgeek
Copy link

Just tested on Linux x86 with EGL and GTK2, with a few Kingdom Hearts games (KH1, KH2, Re:CoM). Seems stable.

@RedPanda4552
Copy link
Contributor Author

Discovered this article thanks to a forum user: https://randomascii.wordpress.com/2020/10/04/windows-timer-resolution-the-great-rule-change/

We may need to play with Win10 2004 release. Sounds like they are changing how thread sleeping will behave and sleep(1) is going to be a LOT more latent than ever before, if this is right.

@RedPanda4552
Copy link
Contributor Author

Update on the above: multiple testers have disclosed they did their tests on 2004 and had positive results. I am comfortable with where this is but more testing is always welcome. Up to everyone else.

@OCRBonk
Copy link

OCRBonk commented Oct 12, 2020

Frame pacing did seem quite a bit better in a few games I tried, although Xenosaga is one that still kind of gives weird readings.
As far as input lag goes, I tested DMC which is already a bit of a slightly laggy game on real hardware. I couldn't feel the difference between builds when I tested them back and forth. Mind you this was on Windows 7. I'll have to try again on my Win 10 drive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants