Commit Graph

89 Commits

Author SHA1 Message Date
bc67fc97c3 Revert "Audit uses of IsRunning and GetState"
This reverts commit 72cf2bdb87.

SYSCONF settings are getting cleared when they shouldn't be. Let's
revert the change until I get proper time to figure out why it's broken.
2024-06-26 20:36:46 +02:00
72cf2bdb87 Audit uses of IsRunning and GetState
Some pieces of code are calling IsRunning because there's some
particular action that only makes sense when emulation is running, for
instance showing the state of the emulated CPU. IsRunning is appropriate
to use for this. Then there are pieces of code that are calling
IsRunning because there's some particular thing they must avoid doing
e.g. when the CPU thread is running or IOS is running. IsRunning isn't
quite appropriate for this. Such code should also be checking for the
states Starting and Stopping. Keep in mind that:

* When the state is Starting, the state can asynchronously change to
  Running at any time.
* When we try to stop the core, the state gets set to Stopping before we
  take any action to actually stop things.

This commit adds a new method Core::IsUninitialized, and changes all
callers of IsRunning and GetState that look to me like they should be
changed.
2024-06-21 20:52:55 +02:00
962230f91e Core: Store current state in less places
Core::GetState reads from four different pieces of state: s_is_stopping,
s_hardware_initialized, s_is_booting, and CPUManager::IsStepping.
I'm keeping that last one as is for now because there's code in Dolphin
that sets it directly, but we can unify the other three to make things
easier to reason about.

This commit also gets rid of s_is_started. This was previously used in
Core::IsRunningAndStarted to ensure true wouldn't be returned until the
CPU thread was started, but it wasn't used in Core::GetState, so
Core::GetState would happily return State::Running after we had
initialized the hardware but before we had initialized the CPU thread.
As far as I know, there are no callers that have any real need to know
whether the boot process is currently initializing the hardware or the
CPU thread. Perhaps once upon a time there was a desire to make the
apploader debuggable, but a long time has passed without anyone stepping
up to implement it, and the way CBoot::RunApploader is implemented makes
it rather difficult. So this commit makes all the functions in Core.cpp
consider the core to still be starting until the CPU thread is started.
2024-06-21 20:46:44 +02:00
0b04975c26 Core::SetState: Avoid Global System Accessor 2024-05-03 21:04:44 -07:00
0df401b164 Core::IsRunning: Avoid Global System Accessor 2024-05-01 08:54:17 -07:00
eb92d6f0a8 Core::GetState: Avoid Global System Accessor 2024-04-08 16:23:23 -07:00
6e6b298030 Core::RunOnCPUThread: Avoid Global System Accessor 2024-03-28 10:10:03 -07:00
73f9904f2a Core: Remove RunAsCPUThread
It's a fine function, but CPUThreadGuard is more vogue. Also, its potential for being confused with RunOnCPUThread will not be missed.
2024-03-23 03:33:26 -07:00
f8fdaf9b94 Merge pull request #12648 from mitaclaw/core-global-system
Core: Avoid (Some) Global System Accessor
2024-03-22 04:13:01 +01:00
11b628f250 Core: Remove Unused IsRunningInCurrentThread Function 2024-03-18 07:18:41 -07:00
f09b71582e Core: Avoid (Some) Global System Accessor 2024-03-18 01:35:42 -07:00
2155a61176 Core: Pass System through more of the emulation thread init process. 2024-01-05 05:19:29 +01:00
b57ba42a55 Core::SetState() allow state to change without sending a callback.
Some state changes are meant to be near instantanoues, before switching to something else. By reporting ithe instant switch, the UI will flicker between states (pause/play button) and the debugger will unnecessarily update. Skipping the callback avoids these issues.
2023-11-16 11:07:37 -07:00
b3c9f49cbe Core: Assert that only the Host thread may call PauseAndLock(). 2023-06-02 18:51:43 +02:00
3006c23c85 Core/CPUThreadGuard: Fetch System from Guard. 2023-03-13 18:13:20 +01:00
912cd456fb Core: Add System parameter to CPUThreadGuard. 2023-03-08 22:41:42 +01:00
3b364c5c16 HW/CPU: Refactor to class, move to System. 2023-03-08 12:23:37 +01:00
7cecb28bdf DolphinQt: Properly lock CPU before accessing emulated memory
This fixes a problem I was having where using frame advance with the
debugger open would frequently cause panic alerts about invalid addresses
due to the CPU thread changing MSR.DR while the host thread was trying
to access memory.

To aid in tracking down all the places where we weren't properly locking
the CPU, I've created a new type (in Core.h) that you have to pass as a
reference or pointer to functions that require running as the CPU thread.
2023-02-12 11:27:50 +01:00
df6f070a55 Core: Remove FPS, VPS and speed percentage from window title 2023-01-23 21:32:50 +01:00
673f81c18a New FrameTime/VBlank Analyzer + Graph 2022-12-23 19:52:53 -05:00
09089eeee0 Common::Timer: use chrono::steady_clock internally 2022-08-02 22:24:06 -07:00
3367e5e026 DolphinQt: Fix the panic alert deadlock, GPU thread edition
The fix in ef77872 worked for panic alerts from
the CPU thread, but there were still problems with
panic alerts from the GPU thread in dual core mode.
This change attempts to fix those.
2022-01-13 22:19:54 +01:00
e5ed9ee920 Core: Remove s_request_refresh_info
It's only used for frame stepping. We can use s_frame_step instead.
2021-09-18 13:39:38 +02:00
e149ad4f0a treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
3c7c2dfaa1 Implement Cursor Locking and new input focus checks for it 2021-05-27 10:31:12 +03:00
818672b585 Fix FPS counter and Game Window speed % breaking on pause/unpause
-Add pause state to FPSCounter.
-Add ability to have more than one "OnStateChanged" callback in core.
-Add GetActualEmulationSpeed() to Core. Returns 1 by default. It's used by my input PRs.
2021-05-06 01:10:04 +03:00
ee52f465b1 Android: Fix rotating EmulationActivity after boot fails
Time for yet another new iteration of working around the
"surface destruction during boot" problem...
This time, the strategy is to use a mutex in MainAndroid.cpp.
2020-11-09 10:38:49 +01:00
991eb6ae83 Android: Use DialogFragment for AlertMessage 2020-09-25 11:50:04 -04:00
13ee6bd7bb BTEmu/Wiimote: Cleanups/Fixes. 2020-08-16 11:38:13 -05:00
7385e9129c Remove wait_for_completion parameter from Renderer::SaveScreenshot
This is now unused. Seems like it was an improper fix
(there would be a race if saving the screenshot took longer
than 2 seconds) back when it was used too.
2020-08-06 21:57:12 +02:00
bf12bb3d43 Boot: Add ConsoleType enum class 2020-05-03 20:55:09 +04:00
1a42355f96 Core: Clarify Callback_VideoCopiedToXFB and FrameUpdate 2020-04-09 00:21:04 +02:00
903db48280 DolphinQt: Give hotkeys their own "background input" setting. 2020-02-10 20:06:29 -06:00
d66050375c Merge pull request #8347 from hosaka-corp/frame-advance-alignment
Align frame advance and movies to full field boundaries
2019-11-19 19:26:35 +01:00
9c5c3c055e Align frame advance and movies to full field boundaries 2019-11-18 15:05:06 -06:00
913cb08066 Merge pull request #8456 from jordan-woyak/input-gate-race-fix
InputCommon: Make the "input gate" not racy.
2019-11-11 10:59:49 +10:00
85ceb37ccd InputCommon: Make the "input gate" not racey. 2019-11-06 16:31:02 -06:00
c007dd1852 Android: Replace emulation rotation crash workaround with proper fix
The workaround was added in 0446a58.

The underlying problem is that we must not destroy the surface
while the video backend is initializing, otherwise the video
backend may reference nullptr.

I've also cleaned up the logic for when to destroy the surface.
Note that the comment in EmulationFragment.java about only being
able to destroy the surface when emulation is running is not true
anymore (due to de632fc, it seems like).
2019-11-05 09:28:40 +01:00
5c3e9a34c3 Merge pull request #8226 from lioncash/fmt-core
Core/Core: Use fmt where applicable
2019-08-09 23:43:39 +10:00
c212310fbe VideoCommon/OnScreenDisplay: Take Message's std::string parameter by value
Allows callers to std::move strings into the functions (or automatically
assume the move constructor/move assignment operator for rvalue
references, potentially avoiding copies altogether.
2019-07-28 23:00:58 -04:00
df45e714a3 Core: Support asynchronously executing functions on the CPU thread
The CPU thread will be interrupted to execute the callback, and then
restored to its old state after execution completes.
2019-07-24 04:08:19 +10:00
1f98188277 Core/Core: Use fmt where applicable
Continues the migration over to using fmt. Given fmt is also compatible
with std::string and std::string_view, we can convert some parameters
over to std::string_view, such as the message parameter for
StopMessage() and the name parameter for an overload of SaveScreenShot()
2019-07-23 08:42:29 -04:00
239af3cdf9 Step MemoryWatcher at end of each video frame. 2019-05-08 11:20:59 +01:00
eb284b5d66 VideoBackends: Pass window system info from host on creation 2018-10-20 21:11:34 +10:00
c5ae721eca Core/Core: Remove another leftover part of frameskip 2018-08-28 02:22:05 -04:00
e4b6d7626b WiimoteDevice: Make Callback_WiimoteInterruptChannel() accept its data as a u8* rather than void*
All current usages of the function pass in either u8 arrays or pointers,
so we can make this part of the function a concrete type.
2018-06-20 16:04:10 -04:00
4288bfe0f9 Common: Move host communication enum to Host.h
Given this is actually a part of the Host interface, this should be
placed with it.

While we're at it, turn it into an enum class so that we don't dump its
contained values into the surrounding scope. We can also make
Host_Message take the enum type itself directly instead of taking a
general int value.

After this, it'll be trivial to divide out the rest of Common.h and
remove the header from the repository entirely
2018-05-28 14:34:59 -04:00
9dd88d76dd Redesign the ability to load state at boot
BootParameters can now contain the path of a savestate to load at boot.
Movie has been made to use this instead of poking at Core.cpp's state.
2017-12-26 20:39:03 +01:00
8e805dcbf4 Core: SetOnStoppedCallback -> SetOnStateChangedCallback 2017-09-13 17:30:18 -07:00
22a9a08b24 Add Core::State::Starting 2017-09-13 17:30:18 -07:00