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

RetroArch Runahead issues #29

Open
rtretiakov opened this issue Jan 15, 2020 · 2 comments
Open

RetroArch Runahead issues #29

rtretiakov opened this issue Jan 15, 2020 · 2 comments

Comments

@rtretiakov
Copy link

This is an issue moved from my personal repository to this one, from @Dwedit

There are two different RunAhead features.

* One is provided within Core Options, and you use it from the "Options" menu after running a game.  This feature works fine.

* The other is the RunAhead feature provided by RetroArch.  When you use this option, you get half speed emulation, sound problems, and in-game freezes during fade transitions.

So I wrote some code to fix it:

Dwedit@68ad3e5

I'll summarize the changes I made to libretro.cpp:

In retro_run, we now check for Audio and Video being enabled, then apply those settings to bsnes. However, bsnes does not have individual toggles for audio and video being enabled or disabled. Instead, it has a flag which disables both, which is named "runahead". So when RetroArch wants to disable both audio and video at the same time, I set the "runahead" flag. This is good enough for now, but separate toggles would be better. Setting the audio/video disable flags fixes the half speed gameplay and sound problems.

In retro_serialize and retro_serialize_size, we now check for the "Fast Savestates" flag, and use that to determine whether to use internal code pointers in the savestate or not. This fixes the in-game crashes due to having a more accurate savestate.

But there's a big issue with doing this that breaks Secondary Instance mode. I had foolishly designed the RunAhead feature to use the same flag (Fast Savestates) for both serialization within one instance, and transferring state between the Main instance and Secondary instance. Transferring internal code pointers from the Main instance to the Secondary instance is guaranteed to crash.

So the flags I'm providing with RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE aren't adequate for catching that case. I'd need more flags to indicate what's going on. Example, add a flag to indicate that a savestate is okay to store internal pointers in, add a flag to indicate that runahead is enabled, add a flag to indicate that runahead is in Secondary Instance mode, add a flag to indicate which is the main instance and which is the secondary instance, etc...

Since RetroArch is already released with RunAhead mode without any additional flags, I'd need a stopgap solution to block second instance mode. One way (platform specific for Windows and Linux) is to check if another library with the same name (but different path) has already loaded, then claim initialization has failed, so it will unload the core.

@Dwedit
Copy link

Dwedit commented Jan 15, 2020

Thank you for moving the issue, I wasn't sure which repository it should be in.

@realnc
Copy link

realnc commented Jan 15, 2020

@Dwedit Left some comments on your code.

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

No branches or pull requests

3 participants