JIT optimizations and refactoring (#675)

* CPU/Recompiler: Use rel32 call where possible for no-args

* JitCodeBuffer: Support using preallocated buffer

* CPU/Recompiler/AArch64: Use bl instead of blr for short branches

* CPU/CodeCache: Allocate recompiler buffer in program space

This means we don't need 64-bit moves for every call out of the
recompiler.

* GTE: Don't store as u16 and load as u32

* CPU/Recompiler: Add methods to emit global load/stores

* GTE: Convert class to namespace

* CPU/Recompiler: Call GTE functions directly

* Settings: Turn into a global variable

* GPU: Replace local pointers with global

* InterruptController: Turn into a global pointer

* System: Replace local pointers with global

* Timers: Turn into a global instance

* DMA: Turn into a global instance

* SPU: Turn into a global instance

* CDROM: Turn into a global instance

* MDEC: Turn into a global instance

* Pad: Turn into a global instance

* SIO: Turn into a global instance

* CDROM: Move audio FIFO to the heap

* CPU/Recompiler: Drop ASMFunctions

No longer needed since we have code in the same 4GB window.

* CPUCodeCache: Turn class into namespace

* Bus: Local pointer -> global pointers

* CPU: Turn class into namespace

* Bus: Turn into namespace

* GTE: Store registers in CPU state struct

Allows relative addressing on ARM.

* CPU/Recompiler: Align code storage to page size

* CPU/Recompiler: Fix relative branches on A64

* HostInterface: Local references to global

* System: Turn into a namespace, move events out

* Add guard pages

* Android: Fix build
This commit is contained in:
Connor McLaughlin
2020-07-31 17:09:18 +10:00
committed by GitHub
parent 1f9fc6ab74
commit b6f871d2b9
88 changed files with 4993 additions and 5045 deletions

View File

@ -61,9 +61,9 @@ bool CommonHostInterface::Initialize()
Log_ErrorPrintf("Failed to set working directory to '%s'", m_user_directory.c_str());
LoadSettings();
UpdateLogSettings(m_settings.log_level, m_settings.log_filter.empty() ? nullptr : m_settings.log_filter.c_str(),
m_settings.log_to_console, m_settings.log_to_debug, m_settings.log_to_window,
m_settings.log_to_file);
UpdateLogSettings(g_settings.log_level, g_settings.log_filter.empty() ? nullptr : g_settings.log_filter.c_str(),
g_settings.log_to_console, g_settings.log_to_debug, g_settings.log_to_window,
g_settings.log_to_file);
m_game_list = std::make_unique<GameList>();
m_game_list->SetCacheFilename(GetUserDirectoryRelativePath("cache/gamelist.cache"));
@ -102,7 +102,7 @@ void CommonHostInterface::Shutdown()
ShutdownDiscordPresence();
#endif
m_system.reset();
System::Shutdown();
m_audio_stream.reset();
if (m_display)
ReleaseHostDisplay();
@ -155,13 +155,13 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
}
// enter fullscreen if requested in the parameters
if (!m_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) ||
(!parameters.override_fullscreen.has_value() && m_settings.start_fullscreen)))
if (!g_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) ||
(!parameters.override_fullscreen.has_value() && g_settings.start_fullscreen)))
{
SetFullscreen(true);
}
if (m_settings.audio_dump_on_boot)
if (g_settings.audio_dump_on_boot)
StartDumpingAudio();
UpdateSpeedLimiterState();
@ -170,30 +170,28 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters)
void CommonHostInterface::PauseSystem(bool paused)
{
if (paused == m_paused || !m_system)
if (paused == System::IsPaused() || System::IsShutdown())
return;
m_paused = paused;
m_audio_stream->PauseOutput(m_paused);
System::SetState(paused ? System::State::Paused : System::State::Running);
m_audio_stream->PauseOutput(paused);
OnSystemPaused(paused);
UpdateSpeedLimiterState();
if (!paused)
m_system->ResetPerformanceCounters();
System::ResetPerformanceCounters();
}
void CommonHostInterface::DestroySystem()
{
SetTimerResolutionIncreased(false);
m_paused = false;
HostInterface::DestroySystem();
}
void CommonHostInterface::PowerOffSystem()
{
if (m_settings.save_state_on_exit)
if (g_settings.save_state_on_exit)
SaveResumeSaveState();
HostInterface::PowerOffSystem();
@ -469,20 +467,20 @@ std::unique_ptr<ControllerInterface> CommonHostInterface::CreateControllerInterf
bool CommonHostInterface::LoadState(bool global, s32 slot)
{
if (!global && (!m_system || m_system->GetRunningCode().empty()))
if (!global && (System::IsShutdown() || System::GetRunningCode().empty()))
{
ReportFormattedError("Can't save per-game state without a running game code.");
return false;
}
std::string save_path =
global ? GetGlobalSaveStateFileName(slot) : GetGameSaveStateFileName(m_system->GetRunningCode().c_str(), slot);
global ? GetGlobalSaveStateFileName(slot) : GetGameSaveStateFileName(System::GetRunningCode().c_str(), slot);
return LoadState(save_path.c_str());
}
bool CommonHostInterface::SaveState(bool global, s32 slot)
{
const std::string& code = m_system->GetRunningCode();
const std::string& code = System::GetRunningCode();
if (!global && code.empty())
{
ReportFormattedError("Can't save per-game state without a running game code.");
@ -504,7 +502,7 @@ bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_
if (!BootSystem(boot_params))
return false;
const bool global = m_system->GetRunningCode().empty();
const bool global = System::GetRunningCode().empty();
if (global)
{
ReportFormattedError("Cannot resume system with undetectable game code from '%s'.", filename);
@ -516,7 +514,7 @@ bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_
}
else
{
const std::string path = GetGameSaveStateFileName(m_system->GetRunningCode().c_str(), -1);
const std::string path = GetGameSaveStateFileName(System::GetRunningCode().c_str(), -1);
if (FileSystem::FileExists(path.c_str()))
{
if (!LoadState(path.c_str()) && !boot_on_failure)
@ -527,8 +525,8 @@ bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_
}
else if (!boot_on_failure)
{
ReportFormattedError("Resume save state not found for '%s' ('%s').", m_system->GetRunningCode().c_str(),
m_system->GetRunningTitle().c_str());
ReportFormattedError("Resume save state not found for '%s' ('%s').", System::GetRunningCode().c_str(),
System::GetRunningTitle().c_str());
DestroySystem();
return false;
}
@ -551,34 +549,36 @@ bool CommonHostInterface::ResumeSystemFromMostRecentState()
void CommonHostInterface::UpdateSpeedLimiterState()
{
if (!m_system || !m_audio_stream || !m_display)
return;
m_speed_limiter_enabled = g_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled;
m_speed_limiter_enabled = m_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled;
const bool is_non_standard_speed = (std::abs(m_settings.emulation_speed - 1.0f) > 0.05f);
const bool is_non_standard_speed = (std::abs(g_settings.emulation_speed - 1.0f) > 0.05f);
const bool audio_sync_enabled =
m_paused || (m_speed_limiter_enabled && m_settings.audio_sync_enabled && !is_non_standard_speed);
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.audio_sync_enabled && !is_non_standard_speed);
const bool video_sync_enabled =
m_paused || (m_speed_limiter_enabled && m_settings.video_sync_enabled && !is_non_standard_speed);
!System::IsRunning() || (m_speed_limiter_enabled && g_settings.video_sync_enabled && !is_non_standard_speed);
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
(audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : ""));
m_audio_stream->SetSync(audio_sync_enabled);
if (audio_sync_enabled)
m_audio_stream->EmptyBuffers();
if (m_audio_stream)
{
m_audio_stream->SetSync(audio_sync_enabled);
if (audio_sync_enabled)
m_audio_stream->EmptyBuffers();
}
m_display->SetVSync(video_sync_enabled);
if (m_display)
m_display->SetVSync(video_sync_enabled);
if (m_settings.increase_timer_resolution)
if (g_settings.increase_timer_resolution)
SetTimerResolutionIncreased(m_speed_limiter_enabled);
m_system->ResetPerformanceCounters();
if (System::IsValid())
System::ResetPerformanceCounters();
}
void CommonHostInterface::RecreateSystem()
{
const bool was_paused = m_paused;
const bool was_paused = System::IsPaused();
HostInterface::RecreateSystem();
if (was_paused)
PauseSystem(true);
@ -588,12 +588,12 @@ void CommonHostInterface::UpdateLogSettings(LOGLEVEL level, const char* filter,
bool log_to_window, bool log_to_file)
{
Log::SetFilterLevel(level);
Log::SetConsoleOutputParams(m_settings.log_to_console, filter, level);
Log::SetDebugOutputParams(m_settings.log_to_debug, filter, level);
Log::SetConsoleOutputParams(g_settings.log_to_console, filter, level);
Log::SetDebugOutputParams(g_settings.log_to_debug, filter, level);
if (log_to_file)
{
Log::SetFileOutputParams(m_settings.log_to_file, GetUserDirectoryRelativePath("duckstation.log").c_str(), true,
Log::SetFileOutputParams(g_settings.log_to_file, GetUserDirectoryRelativePath("duckstation.log").c_str(), true,
filter, level);
}
else
@ -707,7 +707,7 @@ void CommonHostInterface::OnControllerTypeChanged(u32 slot)
void CommonHostInterface::DrawImGuiWindows()
{
if (m_system)
if (System::IsValid())
{
DrawDebugWindows();
DrawFPSWindow();
@ -721,7 +721,7 @@ void CommonHostInterface::DrawImGuiWindows()
void CommonHostInterface::DrawFPSWindow()
{
if (!(m_settings.display_show_fps | m_settings.display_show_vps | m_settings.display_show_speed))
if (!(g_settings.display_show_fps | g_settings.display_show_vps | g_settings.display_show_speed))
return;
const ImVec2 window_size =
@ -739,12 +739,12 @@ void CommonHostInterface::DrawFPSWindow()
}
bool first = true;
if (m_settings.display_show_fps)
if (g_settings.display_show_fps)
{
ImGui::Text("%.2f", m_system->GetFPS());
ImGui::Text("%.2f", System::GetFPS());
first = false;
}
if (m_settings.display_show_vps)
if (g_settings.display_show_vps)
{
if (first)
{
@ -757,9 +757,9 @@ void CommonHostInterface::DrawFPSWindow()
ImGui::SameLine();
}
ImGui::Text("%.2f", m_system->GetVPS());
ImGui::Text("%.2f", System::GetVPS());
}
if (m_settings.display_show_speed)
if (g_settings.display_show_speed)
{
if (first)
{
@ -772,7 +772,7 @@ void CommonHostInterface::DrawFPSWindow()
ImGui::SameLine();
}
const float speed = m_system->GetEmulationSpeed();
const float speed = System::GetEmulationSpeed();
const u32 rounded_speed = static_cast<u32>(std::round(speed));
if (speed < 90.0f)
ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "%u%%", rounded_speed);
@ -823,7 +823,7 @@ void CommonHostInterface::DrawOSDMessages()
continue;
}
if (!m_settings.display_show_osd_messages)
if (!g_settings.display_show_osd_messages)
continue;
const float opacity = std::min(time_remaining, 1.0f);
@ -848,28 +848,25 @@ void CommonHostInterface::DrawOSDMessages()
void CommonHostInterface::DrawDebugWindows()
{
const Settings::DebugSettings& debug_settings = m_system->GetSettings().debugging;
if (debug_settings.show_gpu_state)
m_system->GetGPU()->DrawDebugStateWindow();
if (debug_settings.show_cdrom_state)
m_system->GetCDROM()->DrawDebugWindow();
if (debug_settings.show_timers_state)
m_system->GetTimers()->DrawDebugStateWindow();
if (debug_settings.show_spu_state)
m_system->GetSPU()->DrawDebugStateWindow();
if (debug_settings.show_mdec_state)
m_system->GetMDEC()->DrawDebugStateWindow();
if (g_settings.debugging.show_gpu_state)
g_gpu->DrawDebugStateWindow();
if (g_settings.debugging.show_cdrom_state)
g_cdrom.DrawDebugWindow();
if (g_settings.debugging.show_timers_state)
g_timers.DrawDebugStateWindow();
if (g_settings.debugging.show_spu_state)
g_spu.DrawDebugStateWindow();
if (g_settings.debugging.show_mdec_state)
g_mdec.DrawDebugStateWindow();
}
void CommonHostInterface::DoFrameStep()
{
if (!m_system)
if (System::IsShutdown())
return;
m_frame_step_request = true;
if (m_paused)
PauseSystem(false);
PauseSystem(false);
}
std::optional<CommonHostInterface::HostKeyCode>
@ -926,11 +923,9 @@ void CommonHostInterface::AddControllerRumble(u32 controller_index, u32 num_moto
void CommonHostInterface::UpdateControllerRumble()
{
DebugAssert(m_system);
for (ControllerRumbleState& rumble : m_controller_vibration_motors)
{
Controller* controller = m_system->GetController(rumble.controller_index);
Controller* controller = System::GetController(rumble.controller_index);
if (!controller)
continue;
@ -984,7 +979,7 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si)
for (u32 controller_index = 0; controller_index < 2; controller_index++)
{
const ControllerType ctype = m_settings.controller_types[controller_index];
const ControllerType ctype = g_settings.controller_types[controller_index];
if (ctype == ControllerType::None)
continue;
@ -1004,10 +999,10 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si)
continue;
AddButtonToInputMap(binding, device, button, [this, controller_index, button_code](bool pressed) {
if (!m_system)
if (System::IsShutdown())
return;
Controller* controller = m_system->GetController(controller_index);
Controller* controller = System::GetController(controller_index);
if (controller)
controller->SetButtonState(button_code, pressed);
});
@ -1029,10 +1024,10 @@ void CommonHostInterface::UpdateControllerInputMap(SettingsInterface& si)
continue;
AddAxisToInputMap(binding, device, axis, [this, controller_index, axis_code](float value) {
if (!m_system)
if (System::IsShutdown())
return;
Controller* controller = m_system->GetController(controller_index);
Controller* controller = System::GetController(controller_index);
if (controller)
controller->SetAxisState(axis_code, value);
});
@ -1253,23 +1248,23 @@ void CommonHostInterface::RegisterGeneralHotkeys()
RegisterHotkey(StaticString("General"), StaticString("TogglePause"), StaticString("Toggle Pause"),
[this](bool pressed) {
if (!pressed)
PauseSystem(!m_paused);
if (System::IsValid() && !pressed)
PauseSystem(!System::IsPaused());
});
RegisterHotkey(StaticString("General"), StaticString("PowerOff"), StaticString("Power Off System"),
[this](bool pressed) {
if (!pressed && m_system)
if (!pressed && System::IsValid())
{
if (m_settings.confim_power_off && !m_batch_mode)
if (g_settings.confim_power_off && !m_batch_mode)
{
SmallString confirmation_message("Are you sure you want to stop emulation?");
if (m_settings.save_state_on_exit)
if (g_settings.save_state_on_exit)
confirmation_message.AppendString("\n\nThe current state will be saved.");
if (!ConfirmMessage(confirmation_message))
{
m_system->ResetPerformanceCounters();
System::ResetPerformanceCounters();
return;
}
}
@ -1280,7 +1275,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
RegisterHotkey(StaticString("General"), StaticString("Screenshot"), StaticString("Save Screenshot"),
[this](bool pressed) {
if (!pressed && m_system)
if (!pressed && System::IsValid())
SaveScreenshot();
});
@ -1363,33 +1358,33 @@ void CommonHostInterface::RegisterSaveStateHotkeys()
void CommonHostInterface::RegisterAudioHotkeys()
{
RegisterHotkey(StaticString("Audio"), StaticString("AudioMute"), StaticString("Toggle Mute"), [this](bool pressed) {
if (m_system && !pressed)
if (System::IsValid() && !pressed)
{
m_settings.audio_output_muted = !m_settings.audio_output_muted;
m_audio_stream->SetOutputVolume(m_settings.audio_output_muted ? 0 : m_settings.audio_output_volume);
if (m_settings.audio_output_muted)
g_settings.audio_output_muted = !g_settings.audio_output_muted;
m_audio_stream->SetOutputVolume(g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume);
if (g_settings.audio_output_muted)
AddOSDMessage("Volume: Muted", 2.0f);
else
AddFormattedOSDMessage(2.0f, "Volume: %d%%", m_settings.audio_output_volume);
AddFormattedOSDMessage(2.0f, "Volume: %d%%", g_settings.audio_output_volume);
}
});
RegisterHotkey(StaticString("Audio"), StaticString("AudioVolumeUp"), StaticString("Volume Up"), [this](bool pressed) {
if (m_system && pressed)
if (System::IsValid() && pressed)
{
m_settings.audio_output_volume = std::min<s32>(m_settings.audio_output_volume + 10, 100);
m_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(m_settings.audio_output_volume);
AddFormattedOSDMessage(2.0f, "Volume: %d%%", m_settings.audio_output_volume);
g_settings.audio_output_volume = std::min<s32>(g_settings.audio_output_volume + 10, 100);
g_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(g_settings.audio_output_volume);
AddFormattedOSDMessage(2.0f, "Volume: %d%%", g_settings.audio_output_volume);
}
});
RegisterHotkey(StaticString("Audio"), StaticString("AudioVolumeDown"), StaticString("Volume Down"),
[this](bool pressed) {
if (m_system && pressed)
if (System::IsValid() && pressed)
{
m_settings.audio_output_volume = std::max<s32>(m_settings.audio_output_volume - 10, 0);
m_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(m_settings.audio_output_volume);
AddFormattedOSDMessage(2.0f, "Volume: %d%%", m_settings.audio_output_volume);
g_settings.audio_output_volume = std::max<s32>(g_settings.audio_output_volume - 10, 0);
g_settings.audio_output_muted = false;
m_audio_stream->SetOutputVolume(g_settings.audio_output_volume);
AddFormattedOSDMessage(2.0f, "Volume: %d%%", g_settings.audio_output_volume);
}
});
}
@ -1443,7 +1438,7 @@ void CommonHostInterface::ClearAllControllerBindings(SettingsInterface& si)
{
for (u32 controller_index = 1; controller_index <= NUM_CONTROLLER_AND_CARD_PORTS; controller_index++)
{
const ControllerType ctype = m_settings.controller_types[controller_index - 1];
const ControllerType ctype = g_settings.controller_types[controller_index - 1];
if (ctype == ControllerType::None)
continue;
@ -1483,7 +1478,7 @@ void CommonHostInterface::ApplyInputProfile(const char* profile_path, SettingsIn
return;
}
m_settings.controller_types[controller_index - 1] = *ctype;
g_settings.controller_types[controller_index - 1] = *ctype;
HostInterface::OnControllerTypeChanged(controller_index - 1);
si.SetStringValue(section_name, "Type", Settings::GetControllerTypeName(*ctype));
@ -1520,8 +1515,8 @@ void CommonHostInterface::ApplyInputProfile(const char* profile_path, SettingsIn
}
}
if (m_system)
m_system->UpdateControllers();
if (System::IsValid())
System::UpdateControllers();
UpdateInputMap(si);
@ -1540,7 +1535,7 @@ bool CommonHostInterface::SaveInputProfile(const char* profile_path, SettingsInt
for (u32 controller_index = 1; controller_index <= NUM_CONTROLLER_AND_CARD_PORTS; controller_index++)
{
const ControllerType ctype = m_settings.controller_types[controller_index - 1];
const ControllerType ctype = g_settings.controller_types[controller_index - 1];
if (ctype == ControllerType::None)
continue;
@ -1802,32 +1797,27 @@ void CommonHostInterface::CheckForSettingsChanges(const Settings& old_settings)
{
HostInterface::CheckForSettingsChanges(old_settings);
if (m_system)
if (System::IsValid())
{
if (m_settings.audio_backend != old_settings.audio_backend ||
m_settings.audio_buffer_size != old_settings.audio_buffer_size)
{
m_audio_stream->PauseOutput(m_paused);
UpdateSpeedLimiterState();
}
if (m_settings.video_sync_enabled != old_settings.video_sync_enabled ||
m_settings.audio_sync_enabled != old_settings.audio_sync_enabled ||
m_settings.speed_limiter_enabled != old_settings.speed_limiter_enabled ||
m_settings.increase_timer_resolution != old_settings.increase_timer_resolution ||
m_settings.emulation_speed != old_settings.emulation_speed)
if (g_settings.audio_backend != old_settings.audio_backend ||
g_settings.audio_buffer_size != old_settings.audio_buffer_size ||
g_settings.video_sync_enabled != old_settings.video_sync_enabled ||
g_settings.audio_sync_enabled != old_settings.audio_sync_enabled ||
g_settings.speed_limiter_enabled != old_settings.speed_limiter_enabled ||
g_settings.increase_timer_resolution != old_settings.increase_timer_resolution ||
g_settings.emulation_speed != old_settings.emulation_speed)
{
UpdateSpeedLimiterState();
}
}
if (m_settings.log_level != old_settings.log_level || m_settings.log_filter != old_settings.log_filter ||
m_settings.log_to_console != old_settings.log_to_console ||
m_settings.log_to_window != old_settings.log_to_window || m_settings.log_to_file != old_settings.log_to_file)
if (g_settings.log_level != old_settings.log_level || g_settings.log_filter != old_settings.log_filter ||
g_settings.log_to_console != old_settings.log_to_console ||
g_settings.log_to_window != old_settings.log_to_window || g_settings.log_to_file != old_settings.log_to_file)
{
UpdateLogSettings(m_settings.log_level, m_settings.log_filter.empty() ? nullptr : m_settings.log_filter.c_str(),
m_settings.log_to_console, m_settings.log_to_debug, m_settings.log_to_window,
m_settings.log_to_file);
UpdateLogSettings(g_settings.log_level, g_settings.log_filter.empty() ? nullptr : g_settings.log_filter.c_str(),
g_settings.log_to_console, g_settings.log_to_debug, g_settings.log_to_window,
g_settings.log_to_file);
}
UpdateInputMap();
@ -1912,27 +1902,27 @@ void CommonHostInterface::GetGameInfo(const char* path, CDImage* image, std::str
bool CommonHostInterface::SaveResumeSaveState()
{
if (!m_system)
if (System::IsShutdown())
return false;
const bool global = m_system->GetRunningCode().empty();
const bool global = System::GetRunningCode().empty();
return SaveState(global, -1);
}
bool CommonHostInterface::IsDumpingAudio() const
{
return m_system ? m_system->GetSPU()->IsDumpingAudio() : false;
return g_spu.IsDumpingAudio();
}
bool CommonHostInterface::StartDumpingAudio(const char* filename)
{
if (!m_system)
if (System::IsShutdown())
return false;
std::string auto_filename;
if (!filename)
{
const auto& code = m_system->GetRunningCode();
const auto& code = System::GetRunningCode();
if (code.empty())
{
auto_filename = GetUserDirectoryRelativePath("dump/audio/%s.wav", GetTimestampStringForFileName().GetCharArray());
@ -1946,7 +1936,7 @@ bool CommonHostInterface::StartDumpingAudio(const char* filename)
filename = auto_filename.c_str();
}
if (m_system->GetSPU()->StartDumpingAudio(filename))
if (g_spu.StartDumpingAudio(filename))
{
AddFormattedOSDMessage(5.0f, "Started dumping audio to '%s'.", filename);
return true;
@ -1960,7 +1950,7 @@ bool CommonHostInterface::StartDumpingAudio(const char* filename)
void CommonHostInterface::StopDumpingAudio()
{
if (!m_system || !m_system->GetSPU()->StopDumpingAudio())
if (System::IsShutdown() || !g_spu.StopDumpingAudio())
return;
AddOSDMessage("Stopped dumping audio.", 5.0f);
@ -1969,13 +1959,13 @@ void CommonHostInterface::StopDumpingAudio()
bool CommonHostInterface::SaveScreenshot(const char* filename /* = nullptr */, bool full_resolution /* = true */,
bool apply_aspect_ratio /* = true */)
{
if (!m_system)
if (System::IsShutdown())
return false;
std::string auto_filename;
if (!filename)
{
const auto& code = m_system->GetRunningCode();
const auto& code = System::GetRunningCode();
const char* extension = "png";
if (code.empty())
{
@ -1991,9 +1981,9 @@ bool CommonHostInterface::SaveScreenshot(const char* filename /* = nullptr */, b
filename = auto_filename.c_str();
}
m_system->GetGPU()->ResetGraphicsAPIState();
g_gpu->ResetGraphicsAPIState();
const bool screenshot_saved = m_display->WriteDisplayTextureToFile(filename, full_resolution, apply_aspect_ratio);
m_system->GetGPU()->RestoreGraphicsAPIState();
g_gpu->RestoreGraphicsAPIState();
if (!screenshot_saved)
{
AddFormattedOSDMessage(10.0f, "Failed to save screenshot to '%s'", filename);
@ -2052,10 +2042,10 @@ void CommonHostInterface::UpdateDiscordPresence()
rp.startTimestamp = std::time(nullptr);
SmallString details_string;
if (m_system)
if (System::IsValid())
{
details_string.AppendFormattedString("%s (%s)", m_system->GetRunningTitle().c_str(),
m_system->GetRunningCode().c_str());
details_string.AppendFormattedString("%s (%s)", System::GetRunningTitle().c_str(),
System::GetRunningCode().c_str());
}
else
{

View File

@ -280,7 +280,6 @@ protected:
std::deque<OSDMessage> m_osd_messages;
std::mutex m_osd_messages_lock;
bool m_paused = false;
bool m_frame_step_request = false;
bool m_speed_limiter_temp_disabled = false;
bool m_speed_limiter_enabled = false;

View File

@ -21,17 +21,6 @@ void ControllerInterface::Shutdown()
m_host_interface = nullptr;
}
System* ControllerInterface::GetSystem() const
{
return m_host_interface->GetSystem();
}
Controller* ControllerInterface::GetController(u32 slot) const
{
System* system = GetSystem();
return system ? system->GetController(slot) : nullptr;
}
void ControllerInterface::SetHook(Hook::Callback callback)
{
std::unique_lock<std::mutex> lock(m_event_intercept_mutex);

View File

@ -7,7 +7,6 @@
#include <mutex>
class HostInterface;
class System;
class Controller;
class ControllerInterface
@ -75,8 +74,6 @@ public:
void ClearHook();
protected:
System* GetSystem() const;
Controller* GetController(u32 slot) const;
bool DoEventHook(Hook::Type type, int controller_index, int button_or_axis_number, float value);
void OnControllerConnected(int host_id);

View File

@ -42,13 +42,12 @@ void SaveStateSelectorUI::RefreshList()
{
ClearList();
const System* system = m_host_interface->GetSystem();
if (system && !system->GetRunningCode().empty())
if (!System::GetRunningCode().empty())
{
for (s32 i = 1; i <= CommonHostInterface::GLOBAL_SAVE_STATE_SLOTS; i++)
{
std::optional<CommonHostInterface::ExtendedSaveStateInfo> ssi =
m_host_interface->GetExtendedSaveStateInfo(system->GetRunningCode().c_str(), i);
m_host_interface->GetExtendedSaveStateInfo(System::GetRunningCode().c_str(), i);
ListEntry li;
if (ssi)