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

Discussion: Having the Teakra user own DSP RAM instead of Teakra itself #55

Open
wheremyfoodat opened this issue Dec 1, 2024 · 2 comments

Comments

@wheremyfoodat
Copy link

Hi! At the moment, Teakra itself creates and owns DSP RAM, with the user being able to get a pointer to it via the interface. I'd like to inquire about your thoughts on (optionally?) allowing for the user to own DSP RAM themselves, and pass it to Teakra instead.

There's a handful of reasons why I believe this would be helpful for DSi/3DS emulators.

  • The current design does not allow for fastmem to be used with DSP RAM. Fastmem is a technique that creates a mirror of the emulated system's vaddr space inside a sectiom of the host's vaddr space. Then, an access to a guest vaddr can be performed by just accessing fastmem_base + vaddr. This significantly speeds up memory accesses, as they no longer have to go through any address decoding or pagetables, everything is handled by the host MMU.
    • In order to achieve this, we typically create a memory arena using VirtualAlloc/mmap, from which we allocate the emulated system's memory (eg FCRAM and DSP RAM on 3DS). As Teakra wants to own and manage its own memory, we can't do this, thus DSP RAM can't be used with fastmem, and needs slow memory access fallbacks instead.
  • Letting the user manage DSP RAM themselves would allow for things like using shared memory for it. This lets the emulator easily share DSP RAM between processes which opens up some nice possibilities, like hooking it up to external debugging tools.
  • Albeit a niche use case, there could be situations where one wants DSP RAM to persist even after the Teakra object is destroyed.

Thank you for your time.

@wwylele
Copy link
Owner

wwylele commented Dec 1, 2024

Sounds like a good idea to me! I don't see any problem with this. I haven't touched this code base for quite long, though, and I don't have much time working on it at the moment... Feel free to fork and/or send PR with the change.

@wheremyfoodat wheremyfoodat changed the title Discussion: Having the Teakra user own DSP RAM instead of Teakra iteelf Discussion: Having the Teakra user own DSP RAM instead of Teakra itself Dec 1, 2024
@wheremyfoodat
Copy link
Author

wheremyfoodat commented Dec 8, 2024

Sorry for the inactivity, been busy with other things.

@raphaelthegreat told me he already has a commit that makes this change here raphaelthegreat@ad82541

This could be cherry-picked and merged if deemed fit.

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