Frontends: Add frame time performance counters
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "qtsettingsinterface.h"
|
||||
#include "settingsdialog.h"
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <cmath>
|
||||
|
||||
static constexpr char DISC_IMAGE_FILTER[] =
|
||||
"All File Types (*.bin *.img *.cue *.exe *.psexe);;Single-Track Raw Images (*.bin *.img);;Cue Sheets "
|
||||
@@ -124,6 +125,16 @@ void MainWindow::switchRenderer()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onPerformanceCountersUpdated(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(
|
||||
QStringLiteral("FPS: %1/%2").arg(std::round(fps), 0, 'f', 0).arg(std::round(vps), 0, 'f', 0));
|
||||
m_status_frame_time_widget->setText(
|
||||
QStringLiteral("%1ms average, %2ms worst").arg(average_frame_time, 0, 'f', 2).arg(worst_frame_time, 0, 'f', 2));
|
||||
}
|
||||
|
||||
void MainWindow::onStartDiscActionTriggered()
|
||||
{
|
||||
QString filename =
|
||||
@@ -183,6 +194,21 @@ void MainWindow::setupAdditionalUi()
|
||||
|
||||
m_ui.mainContainer->setCurrentIndex(0);
|
||||
|
||||
m_status_speed_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_speed_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
m_status_speed_widget->setFixedSize(40, 16);
|
||||
m_status_speed_widget->hide();
|
||||
|
||||
m_status_fps_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_fps_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
m_status_fps_widget->setFixedSize(80, 16);
|
||||
m_status_fps_widget->hide();
|
||||
|
||||
m_status_frame_time_widget = new QLabel(m_ui.statusBar);
|
||||
m_status_frame_time_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
m_status_frame_time_widget->setFixedSize(190, 16);
|
||||
m_status_frame_time_widget->hide();
|
||||
|
||||
for (u32 i = 0; i < static_cast<u32>(GPURenderer::Count); i++)
|
||||
{
|
||||
const GPURenderer renderer = static_cast<GPURenderer>(i);
|
||||
@@ -215,6 +241,27 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
|
||||
m_ui.actionSaveState->setDisabled(starting);
|
||||
|
||||
m_ui.actionFullscreen->setDisabled(starting || !running);
|
||||
|
||||
if (running && m_status_speed_widget->isHidden())
|
||||
{
|
||||
m_status_speed_widget->show();
|
||||
m_status_fps_widget->show();
|
||||
m_status_frame_time_widget->show();
|
||||
m_ui.statusBar->addPermanentWidget(m_status_speed_widget);
|
||||
m_ui.statusBar->addPermanentWidget(m_status_fps_widget);
|
||||
m_ui.statusBar->addPermanentWidget(m_status_frame_time_widget);
|
||||
}
|
||||
else if (!running && m_status_speed_widget->isVisible())
|
||||
{
|
||||
m_ui.statusBar->removeWidget(m_status_speed_widget);
|
||||
m_ui.statusBar->removeWidget(m_status_fps_widget);
|
||||
m_ui.statusBar->removeWidget(m_status_frame_time_widget);
|
||||
m_status_speed_widget->hide();
|
||||
m_status_fps_widget->hide();
|
||||
m_status_frame_time_widget->hide();
|
||||
}
|
||||
|
||||
m_ui.statusBar->clearMessage();
|
||||
}
|
||||
|
||||
void MainWindow::switchToGameListView()
|
||||
@@ -259,6 +306,8 @@ void MainWindow::connectSignals()
|
||||
connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped);
|
||||
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);
|
||||
connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen);
|
||||
connect(m_host_interface, &QtHostInterface::performanceCountersUpdated, this,
|
||||
&MainWindow::onPerformanceCountersUpdated);
|
||||
|
||||
connect(m_game_list_widget, &GameListWidget::bootEntryRequested, [this](const GameList::GameListEntry* entry) {
|
||||
// if we're not running, boot the system, otherwise swap discs
|
||||
@@ -274,6 +323,15 @@ void MainWindow::connectSignals()
|
||||
switchToEmulationView();
|
||||
}
|
||||
});
|
||||
connect(m_game_list_widget, &GameListWidget::entrySelected, [this](const GameList::GameListEntry* entry) {
|
||||
if (!entry)
|
||||
{
|
||||
m_ui.statusBar->clearMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui.statusBar->showMessage(QString::fromStdString(entry->path));
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::doSettings(SettingsDialog::Category category)
|
||||
@@ -289,4 +347,4 @@ void MainWindow::doSettings(SettingsDialog::Category category)
|
||||
|
||||
if (category != SettingsDialog::Category::Count)
|
||||
m_settings_dialog->setCategory(category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
class QLabel;
|
||||
|
||||
class GameList;
|
||||
class GameListWidget;
|
||||
class QtHostInterface;
|
||||
@@ -26,6 +28,8 @@ private Q_SLOTS:
|
||||
void onEmulationPaused(bool paused);
|
||||
void toggleFullscreen();
|
||||
void switchRenderer();
|
||||
void onPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
|
||||
float worst_frame_time);
|
||||
|
||||
void onStartDiscActionTriggered();
|
||||
void onChangeDiscActionTriggered();
|
||||
@@ -53,6 +57,10 @@ private:
|
||||
GameListWidget* m_game_list_widget = nullptr;
|
||||
QWidget* m_display_widget = nullptr;
|
||||
|
||||
QLabel* m_status_speed_widget = nullptr;
|
||||
QLabel* m_status_fps_widget = nullptr;
|
||||
QLabel* m_status_frame_time_widget = nullptr;
|
||||
|
||||
SettingsDialog* m_settings_dialog = nullptr;
|
||||
|
||||
bool m_emulation_running = false;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<string>DuckStation</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/duck.png</normaloff>:/icons/duck.png</iconset>
|
||||
</property>
|
||||
<widget class="QStackedWidget" name="mainContainer">
|
||||
@@ -30,7 +30,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>754</width>
|
||||
<height>21</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSystem">
|
||||
@@ -128,9 +128,10 @@
|
||||
<addaction name="actionFullscreen"/>
|
||||
<addaction name="actionSettings"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionStartDisc">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/drive-optical.png</normaloff>:/icons/drive-optical.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -139,7 +140,7 @@
|
||||
</action>
|
||||
<action name="actionStartBios">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/drive-removable-media.png</normaloff>:/icons/drive-removable-media.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -148,7 +149,7 @@
|
||||
</action>
|
||||
<action name="actionPowerOff">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/system-shutdown.png</normaloff>:/icons/system-shutdown.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -157,7 +158,7 @@
|
||||
</action>
|
||||
<action name="actionReset">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -169,7 +170,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -178,7 +179,7 @@
|
||||
</action>
|
||||
<action name="actionLoadState">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -187,7 +188,7 @@
|
||||
</action>
|
||||
<action name="actionSaveState">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -201,7 +202,7 @@
|
||||
</action>
|
||||
<action name="actionConsoleSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/utilities-system-monitor.png</normaloff>:/icons/utilities-system-monitor.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -210,7 +211,7 @@
|
||||
</action>
|
||||
<action name="actionPortSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/input-gaming.png</normaloff>:/icons/input-gaming.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -219,7 +220,7 @@
|
||||
</action>
|
||||
<action name="actionHotkeySettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/applications-other.png</normaloff>:/icons/applications-other.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -228,7 +229,7 @@
|
||||
</action>
|
||||
<action name="actionGPUSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/video-display.png</normaloff>:/icons/video-display.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -237,7 +238,7 @@
|
||||
</action>
|
||||
<action name="actionFullscreen">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/view-fullscreen.png</normaloff>:/icons/view-fullscreen.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -290,7 +291,7 @@
|
||||
</action>
|
||||
<action name="actionChangeDisc">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/media-optical.png</normaloff>:/icons/media-optical.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -299,7 +300,7 @@
|
||||
</action>
|
||||
<action name="actionAudioSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/audio-card.png</normaloff>:/icons/audio-card.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -308,7 +309,7 @@
|
||||
</action>
|
||||
<action name="actionGameListSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/folder-open.png</normaloff>:/icons/folder-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -317,7 +318,7 @@
|
||||
</action>
|
||||
<action name="actionOpenDirectory">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/edit-find.png</normaloff>:/icons/edit-find.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -326,7 +327,7 @@
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<iconset resource="resources/icons.qrc">
|
||||
<normaloff>:/icons/applications-system.png</normaloff>:/icons/applications-system.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -335,7 +336,7 @@
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
<include location="resources/icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -185,6 +185,13 @@ void QtHostInterface::onDisplayWindowResized(int width, int height)
|
||||
m_display_window->onWindowResized(width, height);
|
||||
}
|
||||
|
||||
void QtHostInterface::OnPerformanceCountersUpdated()
|
||||
{
|
||||
HostInterface::OnPerformanceCountersUpdated();
|
||||
|
||||
emit performanceCountersUpdated(m_speed, m_fps, m_vps, m_average_frame_time, m_worst_frame_time);
|
||||
}
|
||||
|
||||
void QtHostInterface::updateInputMap()
|
||||
{
|
||||
if (!isOnWorkerThread())
|
||||
@@ -508,8 +515,7 @@ void QtHostInterface::threadEntryPoint()
|
||||
|
||||
// execute the system, polling events inbetween frames
|
||||
// simulate the system if not paused
|
||||
if (m_system && !m_paused)
|
||||
m_system->RunFrame();
|
||||
RunFrame();
|
||||
|
||||
// rendering
|
||||
{
|
||||
@@ -519,7 +525,6 @@ void QtHostInterface::threadEntryPoint()
|
||||
m_system->GetGPU()->ResetGraphicsAPIState();
|
||||
}
|
||||
|
||||
DrawFPSWindow();
|
||||
DrawOSDMessages();
|
||||
|
||||
m_display->Render();
|
||||
@@ -531,8 +536,6 @@ void QtHostInterface::threadEntryPoint()
|
||||
if (m_speed_limiter_enabled)
|
||||
Throttle();
|
||||
}
|
||||
|
||||
UpdatePerformanceCounters();
|
||||
}
|
||||
|
||||
m_worker_thread_event_loop->processEvents(QEventLoop::AllEvents);
|
||||
|
||||
@@ -71,6 +71,7 @@ Q_SIGNALS:
|
||||
void gameListRefreshed();
|
||||
void toggleFullscreenRequested();
|
||||
void switchRendererRequested();
|
||||
void performanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time, float worst_frame_time);
|
||||
|
||||
public Q_SLOTS:
|
||||
void powerOffSystem();
|
||||
@@ -87,6 +88,9 @@ private Q_SLOTS:
|
||||
void doHandleKeyEvent(int key, bool pressed);
|
||||
void onDisplayWindowResized(int width, int height);
|
||||
|
||||
protected:
|
||||
void OnPerformanceCountersUpdated() override;
|
||||
|
||||
private:
|
||||
using InputButtonHandler = std::function<void(bool)>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user