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

Add VBI Overclock #13046

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

SuperSamus
Copy link
Contributor

@SuperSamus SuperSamus commented Sep 1, 2024

Rebase of #11486, which seems to have been abandoned.

The highlight of this feature is the ability to play games at higher than 60 FPS, at normal gameplay speed, and without affecting the audio.

NFSNitro-144.mp4

(More videos on #11486)

This feature works, it's simple and non-invasive, and put formally, it is very cool.

However, the current user experience isn't the best.
Here are the current problems, with proposed solutions. I'm asking for feedback on the "IMO"s.

CPU Overclock

A game with more FPS is obviously going to be more demanding for the emulated console, but if the emulated CPU clock doesn't change, then the console is basically going to be underclocked.
At best, this will cause the game to not run at the target framerate (which defeats the whole point).
At worst, the game will freeze.1

IMO, a simple solution would be that changing VBI Overclock will also "secretly" multiply the emulated CPU clock. Done!

Cheat codes

There are different types of games.

  • Some will speed up.2
    • Worst case, you can do nothing about it.
      • Many Nintendo games like Mario Kart Wii or Super Mario Galaxy have their speed completely tied to the frame rate. They even ignore PAL 50 Hz!
    • Best case, the game doesn't dynamically change the game speed, but it can be changed with a cheat code.
      • A good chunk of codes is probably just going to replace a 3C888889 (1/60) with 1/DesiredFPS.
      • If the game speed is adjusted in PAL 50 Hz, then it's a good sign that this is likely possible.
  • Others seem to not react at all.
    • Best case, the rendering is capped by a time-based frame rate limiter. It can be theoretically uncapped with a cheat code.
    • Worst case, the game logic is capped by a time-based/MaxFPS frame rate limiter. Forcing the game to render more often simply results in duplicated frames. (e.g. PokéPark Wii, which internally runs at 60 FPS no matter what, even in PAL50.)
  • Some are... a weird mix of these?
  • And some play at normal speed at higher framerates with no (or minor) issues!

So, the situation here is extremely game-dependent.

The golden standard for this is probably Cemu: its graphics packs, which are automatically downloaded, offer a choice of presets that patch the game and set the settings required to play at a specific framerate.

Dolphin could do something like it with its per-game settings, but... there can only be one per game. You can't "choose" a preset.

The discoverability of cheat codes in general is also bad. Currently, all "enhancement" cheat codes are only located in the Dolphin wiki, and must be manually inserted. This is in contrast to, for instance, PCSX2 and RPCS3, which do have patches included (for the former they are in a separate repo, for the latter they are scraped from the wiki).

This is a complicated issue, and affects more than this PR.3 However, because there are games that don't require this, I don't think that it needs to be tackled now, IMO.

Plus, giving cheat-makers the ability to cook these codes for the games that need it is valuable, even before the feature has good UX, IMO.

Where to put the option?

image

What this says: #11486 (comment)

IMO, it could be exposed exclusively in the in-game settings (like RPCS3)? That would make the options harder to discover for the users that shouldn't touch it, while allowing the cheat-makers to have fun with it.

Vsync

What if VBI Overclock makes framerate higher than the display's refresh rate, and Vsync is on?

Footnotes

  1. For instance, Skylanders: Swap Force is affected by this. Do note that this happens when the emulated CPU is underclocked, even without VBI Overclock.

  2. Though, I guess being able to play a game in fast-forward without affecting audio is a use case, assuming the game doesn't depend on audio timings.

  3. Something I was thinking is, Dolphin currently has a problem in giving a user the choice of performance vs accuracy. The current situation is that performance is favored, and to get accuracy, the user needs to visit the wiki and manually apply the settings listed there. Whatever system is going to solve this could also be applied here.

@SuperSamus
Copy link
Contributor Author

SuperSamus commented Sep 4, 2024

Implemented "secretly" multiplying CPU speed, and prevent <100% in Hardcore mode.

I didn't test hardcore mode. In theory, the two might have this not-great interaction - with CPU Overclock at 100% and Hardcore Mode active, you reduce VBI overclock to <100%:

  1. In CoreTimingManager::RefreshConfig(), it sets the CPU overclock to <100%
  2. In VideoInterfaceManager::RefreshConfig(), it sets VBI Overclock to 100%
  3. In CoreTimingManager::RefreshConfig(), it sets the CPU overclock to 100%
  4. Finally, RefreshConfig() sets nothing, nowhere.

So a 4-level deep recursion.

@JMC47
Copy link
Contributor

JMC47 commented Sep 4, 2024

I'm not against this feature, but here's a few points.

1: We can add default cheatcodes/patches/etc. to GameINIs that users can enable/disable without having to go to the wiki to download them. If you were to add the framerate patches to the INIs (disabled by default, of course) I'm perfectly fine with merging that. Same with things like widescreen codes as long as they're verified to not cause serious issues, or if they do cause issues, to note them in the cheat description so users know when enabling it.
2: I do want profiles someday, but it's been a problem to do that.
3: Right now Dolphin doesn't have async presentation, so if the framerate is higher than the monitor refresh, the game will vsync down and "lag" to monitor's refresh rate on single core or probably crash on dualcore.

Additionally - if this is going to secretly override the Emulated CPU clockrate, then we should probably disable/tell the user it's been disabled when this is enabled? Right now I don't know if I like doing it secretly.

So yeah, separate from this pull request, we could start moving some wiki cheats/patches into Dolphin proper if we wanted, along with other things. I think Wind Waker has a few patches included by default if you're looking for an example of how that works.

@iwubcode
Copy link
Contributor

iwubcode commented Sep 5, 2024

I threw probably ten 30fps Wii games at this. Hoping for bullet four. A majority of them were double speed, with a couple not changing speed at all. I'd say we'd have to see how many games this actually helps before deciding if it is worthwhile.

EDIT: Reading samb's PR, I guess this is just enhancing the VI rate, so my results are expected. This does sound similar to the vbeam hack which was removed.

@SuperSamus
Copy link
Contributor Author

if this is going to secretly override the Emulated CPU clockrate, then we should probably disable/tell the user it's been disabled when this is enabled? Right now I don't know if I like doing it secretly.

I added a note in the description: "Also adjusts the emulated CPU's clock rate, to keep it relatively the same."

This does sound similar to the vbeam hack which was removed.

That hack could only double the VBI rate, and it was also touching audio timings.

@PCSX1
Copy link

PCSX1 commented Sep 7, 2024

also trying lag the game same orignal hardware but keeps 60 fps

@Sam-Belliveau
Copy link
Contributor

I've been seeing your posts under my original VBI overclock PR and I'm not sure exactly what it's used for but it's really cool it works.

One thing is I think that you should make it clear that people shouldn't go < 100% for performance reasons, because thats what VBI Skip does.

VBI Skip effectively is like lowering the % to where it wont lag audio automatically, so setting it to 50% to avoid audio stutters isnt worth it compared to VBI Skip.

But for increasing the frame rate I think this can be interesting.

@SuperSamus
Copy link
Contributor Author

There are reasons to go < 100%:

  • If the computer is too weak and never reaches full speed, it's better to have a stable low framerate, than an unstable "high" framerate.
    • Especially for games that don't have a dynamic framerate, and you must set the game speed with a cheat code beforehand. With just VBI Skip, the game would run in slow-motion.
  • Some games have problems with VBI Skip, but don't have any with VBI Overclock. (e.g. The first two Skylanders games)

Still, these two options should definitely be together in the UI.
So... both in Config > Advanced, or both in Graphics > Hacks, or even somewhere else?
Between the two, I'd vote for Config > Advanced.
IMO, VBI Skip, being able to causes freezes and crashes depending on the game, doesn't belong in a page where every other setting... doesn't do that. (And if they do, they are automatically disabled by INIs when needed.)

@Sam-Belliveau
Copy link
Contributor

All VBI Skip does is skip over the current VBI interrupt if the computer is throttling, which is equivalent to lowering the %. The freezes occur when the CPU is too slow and no matter how many VBI's are skipped the computer can't stop throttling.

I'd be ok with VBI Skip being moved next to the VBI Overclock, especially since it could better give context to what VBI skip does.

I'm curious, would it be useful to make VBI Overclock configurable from a cheat code? i.e., a code is able to edit the VBI Overclock setting so that you could just have a "120fps" code?

@SuperSamus
Copy link
Contributor Author

I'm curious, would it be useful to make VBI Overclock configurable from a cheat code? i.e., a code is able to edit the VBI Overclock setting so that you could just have a "120fps" code?

The code itself can't do it: AR and Gecko codes, AFAIK, are implemented at a low level.
I don't know about Dolphin's patches, but even if they are high level, they are extremely limited (for instance, it has no equivalent for Gecko's C2 codetype).

So, to achieve a "one 120 FPS checkbox and play", Dolphin would need a system to set multiple settings at once. (Whether a cheat code is enabled or not is a setting, after all.)
I wrote about the UX issues in the main post.

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

Successfully merging this pull request may close these issues.

5 participants