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

PS2 Retroarch Fix Core GBA #17076

Open
andres0021 opened this issue Oct 4, 2024 · 3 comments
Open

PS2 Retroarch Fix Core GBA #17076

andres0021 opened this issue Oct 4, 2024 · 3 comments

Comments

@andres0021
Copy link

andres0021 commented Oct 4, 2024

First and foremost consider this:

  • Only RetroArch bugs should be filed here. Not core bugs or game bugs
  • This is not a forum or a help section, this is strictly developer oriented

Description

[Description of the bug]
Hello, good afternoon. I wanted to ask if there are plans to fix the GBA core freezes for PS2. The core has had problems since it was included in RetroArch for PS2. I wanted to know if there is a solution. I hope you can answer. I clarify that the freezes happen in all GBA games, randomly, for a few seconds or minutes. Greetings!

Expected behavior

[What you expected to happen]

Actual behavior

[What is actually happening]

Steps to reproduce the bug

  1. [First step]
  2. [Second step]
  3. [and so on...]

Bisect Results

[Try to bisect and tell us when this started happening]

Version/Commit

You can find this information under Information/System Information

  • RetroArch: [version/commit]

Environment information

  • OS: [The operating system you're running]
  • Compiler: [In case you are running local builds]
@andymcca
Copy link
Contributor

andymcca commented Oct 5, 2024

This issue will likely get closed by a moderator because it will be deemed a core issue, not a Retroarch issue.

I can give a little insight into this @andres0021 because as you know we have discussed this issue before.

From my testing I believe the issue is linked to cache clearing/invalidation. In the gpsp dynarec, every time a block is translated into native code, we flush/invalidate the CPU cache using platform specific code. For the PS2, this takes the form of FlushCache(0) to flush/invalidate the dcache and FlushCache(2) to invalidate the icache.

If the current block has already been translated then we won't do the above because there is no need - the correct native code will already have been committed to memory via the flush routine above.

If I change the function so that we DO flush after each block unconditionally i.e. whether or not we have to translate the block, then the intermittent crashes you describe go away. At the cost of a massive speed-hit of course because we're effectively making the cache redundant.

So I SUSPECT there is another device somehow invalidating the dcache periodically without performing a writeback (this would be a Flushcache(1) or Flushcache(3) command or equivalent) which then trashes the recently written dynarec code which is still sitting in the cache. This MIGHT be something like the audio driver in Retroarch, rather than a gpsp issue.

Happy for someone to tell me that all of the above is rubbish 😆 Also - I believe the Picodrive core has a dynarec on PS2 and doesn't have this issue?

@andres0021
Copy link
Author

andres0021 commented Oct 5, 2024 via email

@andymcca
Copy link
Contributor

andymcca commented Oct 5, 2024

I wouldn't say anyone has given up on it - it's just that I don't think anyone has spent a lot of time looking into it except me 😆

I will keep looking at it when I can but it is very time-consuming and I don't have a lot of spare time. But it is an intriguing issue for me so I keep coming back to it. It would be great if someone who is more familiar with PS2 Dev would look into it as I am definitely not a PS2 developer!

There are cache-related issues with a handful of PS2 games which make them difficult to emulate (e.g. Dead or Alive 2), because PCSX2 doesn't emulate the cache by default but those games rely on it to function correctly. This is kind of the reverse of that, because I think David told me before that the gpsp core works on Retroarch if you run it on PCSX2, so that makes me think even more that it's a cache issue.

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

2 participants