HostInterface: Move throttle and perf stats to System class

This commit is contained in:
Connor McLaughlin
2020-02-09 22:16:25 +09:00
parent 895cefec60
commit c820ddba79
10 changed files with 180 additions and 182 deletions

View File

@ -124,8 +124,8 @@ void MainWindow::recreateDisplayWidget(bool create_device_context)
updateDebugMenuGPURenderer();
}
void MainWindow::onPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time)
void MainWindow::onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time)
{
m_status_speed_widget->setText(QStringLiteral("%1%").arg(speed, 0, 'f', 0));
m_status_fps_widget->setText(
@ -345,8 +345,8 @@ void MainWindow::connectSignals()
connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen);
connect(m_host_interface, &QtHostInterface::recreateDisplayWidgetRequested, this, &MainWindow::recreateDisplayWidget,
Qt::BlockingQueuedConnection);
connect(m_host_interface, &QtHostInterface::performanceCountersUpdated, this,
&MainWindow::onPerformanceCountersUpdated);
connect(m_host_interface, &QtHostInterface::systemPerformanceCountersUpdated, this,
&MainWindow::onSystemPerformanceCountersUpdated);
connect(m_host_interface, &QtHostInterface::runningGameChanged, this, &MainWindow::onRunningGameChanged);
connect(m_game_list_widget, &GameListWidget::bootEntryRequested, [this](const GameListEntry* entry) {

View File

@ -29,8 +29,8 @@ private Q_SLOTS:
void onEmulationPaused(bool paused);
void toggleFullscreen();
void recreateDisplayWidget(bool create_device_context);
void onPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time);
void onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time);
void onRunningGameChanged(QString filename, QString game_code, QString game_title);
void onStartDiscActionTriggered();

View File

@ -52,9 +52,7 @@ void QtHostInterface::ReportMessage(const char* message)
void QtHostInterface::setDefaultSettings()
{
HostInterface::UpdateSettings([this]() {
HostInterface::SetDefaultSettings();
});
HostInterface::UpdateSettings([this]() { HostInterface::SetDefaultSettings(); });
// default input settings for Qt
std::lock_guard<std::mutex> guard(m_qsettings_mutex);
@ -263,16 +261,18 @@ void QtHostInterface::SwitchGPURenderer()
m_audio_stream->PauseOutput(false);
UpdateSpeedLimiterState();
}
}
ResetPerformanceCounters();
m_system->ResetPerformanceCounters();
}
}
void QtHostInterface::OnPerformanceCountersUpdated()
void QtHostInterface::OnSystemPerformanceCountersUpdated()
{
HostInterface::OnPerformanceCountersUpdated();
HostInterface::OnSystemPerformanceCountersUpdated();
emit performanceCountersUpdated(m_speed, m_fps, m_vps, m_average_frame_time, m_worst_frame_time);
DebugAssert(m_system);
emit systemPerformanceCountersUpdated(m_system->GetEmulationSpeed(), m_system->GetFPS(), m_system->GetVPS(),
m_system->GetAverageFrameTime(), m_system->GetWorstFrameTime());
}
void QtHostInterface::OnRunningGameChanged()
@ -592,7 +592,7 @@ void QtHostInterface::threadEntryPoint()
// execute the system, polling events inbetween frames
// simulate the system if not paused
RunFrame();
m_system->RunFrame();
// rendering
{
@ -611,7 +611,7 @@ void QtHostInterface::threadEntryPoint()
m_system->GetGPU()->RestoreGraphicsAPIState();
if (m_speed_limiter_enabled)
Throttle();
m_system->Throttle();
}
}

View File

@ -71,7 +71,8 @@ Q_SIGNALS:
void gameListRefreshed();
void toggleFullscreenRequested();
void recreateDisplayWidgetRequested(bool create_device_context);
void performanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time, float worst_frame_time);
void systemPerformanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time,
float worst_frame_time);
void runningGameChanged(QString filename, QString game_code, QString game_title);
public Q_SLOTS:
@ -90,7 +91,7 @@ private Q_SLOTS:
protected:
void SwitchGPURenderer() override;
void OnPerformanceCountersUpdated() override;
void OnSystemPerformanceCountersUpdated() override;
void OnRunningGameChanged() override;
private: