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

DSP: Eliminate most global state #9348

Merged
merged 2 commits into from Dec 28, 2020
Merged

Conversation

lioncash
Copy link
Member

@lioncash lioncash commented Dec 21, 2020

An unfortunately large single commit that deglobalizes the DSP code. (which I'm very sorry about).

This would have otherwise been extremely difficult to separate due to extensive use of the globals in very coupling ways that would result in more scaffolding to work around than is worth it.

Aside from the video code, I believe only the DSP code is the hairiest to deal with in terms of globals, so I guess it's best to get this dealt with right off the bat.

A summary of what this commit does:

  • Turns the DSPInterpreter into its own class
    This is the most involved portion of this change. The bulk of the changes are turning non-member functions into member
    functions that would be situated into the Interpreter class.

  • Eliminates all usages of globals within DSPCore.
    This generally involves turning a lot of non-member functions into member functions that are either situated within SDSP or DSPCore.

  • Discards DSPDebugInterface (it wasn't hooked up to anything, and for the sake of eliminating global state, I'd rather get rid of it than think up ways for this class to be integrated with everything else.
    This hasn't been used since the migration to Qt.

  • Readjusts the DSP JIT to handle calling out to member functions.
    In most cases, this just means wrapping respective member function calls into thunk functions.

Surprisingly, this doesn't even make use of the introduced System class. It was possible all along to do this without it. We can house everything within the DSPLLE class, which is quite nice =)

@lioncash lioncash force-pushed the dsp-deglobal branch 3 times, most recently from 5caffaf to 070b4bc Compare December 21, 2020 17:41
@iwubcode
Copy link
Contributor

Still need another pass but this looks really good!

@lioncash lioncash force-pushed the dsp-deglobal branch 2 times, most recently from 847150d to f5c783d Compare December 22, 2020 20:19
@lioncash lioncash force-pushed the dsp-deglobal branch 2 times, most recently from 44e443a to 8d4489b Compare December 22, 2020 20:42
An unfortunately large single commit that deglobalizes the DSP code.
(which I'm very sorry about).

This would have otherwise been extremely difficult to separate due to
extensive use of the globals in very coupling ways that would result in
more scaffolding to work around than is worth it.

Aside from the video code, I believe only the DSP code is the hairiest
to deal with in terms of globals, so I guess it's best to get this dealt
with right off the bat.

A summary of what this commit does:
  - Turns the DSPInterpreter into its own class
    This is the most involved portion of this change.
    The bulk of the changes are turning non-member functions into member
    functions that would be situated into the Interpreter class.

  - Eliminates all usages to globals within DSPCore.
    This generally involves turning a lot of non-member functions into
    member functions that are either situated within SDSP or DSPCore.

  - Discards DSPDebugInterface (it wasn't hooked up to anything,
    and for the sake of eliminating global state, I'd rather get rid of
    it than think up ways for this class to be integrated with
    everything else.

  - Readjusts the DSP JIT to handle calling out to member functions.
    In most cases, this just means wrapping respective member function
    calles into thunk functions.

Surprisingly, this doesn't even make use of the introduced System class.
It was possible all along to do this without it. We can house everything
within the DSPLLE class, which is quite nice =)
Localizes code that modifies m_dsp into the struct itself. This reduces
the overal coupling between DSPCore and SDSP by reducing access to its
member variables.

This commit is only code movement and has no functional changes.
@lioncash
Copy link
Member Author

Are there any more reviews to be done? Last review was 6 days ago

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Some files were difficult to review because of method reordering (which individually are just renames/relocations to match the new structure), so I kinda avoided this PR in the past days, but here we go. Code LGTM, untested. But I think we'll get some quick feedback once this is out in the wild in case something is really off.

Copy link
Member

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

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

lgtm, couldn't spot anything wrong

@leoetlino leoetlino merged commit 3f68ace into dolphin-emu:master Dec 28, 2020
10 checks passed
@lioncash lioncash deleted the dsp-deglobal branch December 28, 2020 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants