diff --git a/.travis.sh b/.travis.sh index e0485bfb76..f0e8593d1d 100644 --- a/.travis.sh +++ b/.travis.sh @@ -86,7 +86,7 @@ travis_script() source /opt/qt512/bin/qt512-env.sh || true export VULKAN_SDK=$(pwd)/../${VULKAN_SDK_VERSION}/x86_64 export PATH=$PATH:/opt/qt512/lib/cmake - cmake .. -G"$BUILD_TYPE" -DCMAKE_INSTALL_PREFIX=./appdir/usr -DBUILD_LIBRETRO_CORE=yes; + cmake .. -G"$BUILD_TYPE" -DCMAKE_INSTALL_PREFIX=./appdir/usr -DBUILD_LIBRETRO_CORE=yes -DPROFILE=yes cmake --build . ctest cmake --build . --target install @@ -102,7 +102,7 @@ travis_script() elif [ "$TARGET_OS" = "OSX" ]; then export CMAKE_PREFIX_PATH="$(brew --prefix qt5)" export VULKAN_SDK=$(pwd)/../vulkansdk-macos-${VULKAN_SDK_VERSION}/macOS - cmake .. -G"$BUILD_TYPE" -DBUILD_LIBRETRO_CORE=yes + cmake .. -G"$BUILD_TYPE" -DBUILD_LIBRETRO_CORE=yes -DPROFILE=yes cmake --build . --config Release ctest -C Release $(brew --prefix qt5)/bin/macdeployqt Source/ui_qt/Release/Play.app diff --git a/Source/ui_qt/CMakeLists.txt b/Source/ui_qt/CMakeLists.txt index 816ab0e1a7..2496eb8d90 100644 --- a/Source/ui_qt/CMakeLists.txt +++ b/Source/ui_qt/CMakeLists.txt @@ -119,6 +119,8 @@ set(QT_SOURCES memorycardmanagerdialog.cpp memorycardmanagerdialog.h PreferenceDefs.h + profiledialog.cpp + profiledialog.h QStringUtils.cpp QStringUtils.h vfsmanagerdialog.cpp @@ -199,6 +201,7 @@ set(QT_MOC_HEADERS openglwindow.h outputwindow.h memorycardmanagerdialog.h + profiledialog.h S3FileBrowser.h vfsmanagerdialog.h vfsmodel.h @@ -213,6 +216,8 @@ set(QT_UIS Qt_ui/inputeventselectiondialog.ui Qt_ui/mainwindow.ui Qt_ui/memorycardmanager.ui + Qt_ui/profiledialog.ui + Qt_ui/profilemenu.ui Qt_ui/s3filebrowser.ui Qt_ui/settingsdialog.ui Qt_ui/vfsmanagerdialog.ui diff --git a/Source/ui_qt/Qt_ui/mainwindow.ui b/Source/ui_qt/Qt_ui/mainwindow.ui index 3a4779cae5..8e01d4fc64 100644 --- a/Source/ui_qt/Qt_ui/mainwindow.ui +++ b/Source/ui_qt/Qt_ui/mainwindow.ui @@ -209,6 +209,16 @@ Ctrl+L + + + Show Profile Dialog + + + + + Reset + + diff --git a/Source/ui_qt/Qt_ui/profiledialog.ui b/Source/ui_qt/Qt_ui/profiledialog.ui new file mode 100644 index 0000000000..3ef5abe063 --- /dev/null +++ b/Source/ui_qt/Qt_ui/profiledialog.ui @@ -0,0 +1,36 @@ + + + ProfileDialog + + + + 0 + 0 + 504 + 248 + + + + + 810 + 0 + + + + Profile Dialog + + + + + + + Courier + + + + + + + + + diff --git a/Source/ui_qt/Qt_ui/profilemenu.ui b/Source/ui_qt/Qt_ui/profilemenu.ui new file mode 100644 index 0000000000..af736409ec --- /dev/null +++ b/Source/ui_qt/Qt_ui/profilemenu.ui @@ -0,0 +1,23 @@ + + + ProfileMenu + + + Profile + + + + Show + + + + + Reset + + + + + + + + diff --git a/Source/ui_qt/mainwindow.cpp b/Source/ui_qt/mainwindow.cpp index bcd10b45e6..d7f90edc41 100644 --- a/Source/ui_qt/mainwindow.cpp +++ b/Source/ui_qt/mainwindow.cpp @@ -37,6 +37,12 @@ #else #include "tools/PsfPlayer/Source/SH_OpenAL.h" #endif + +#ifdef PROFILE +#include "profiledialog.h" +#include "ui_profilemenu.h" +#endif + #include "input/PH_GenericInput.h" #include "DiskUtils.h" #include "PathUtils.h" @@ -75,11 +81,13 @@ MainWindow::MainWindow(QWidget* parent) #ifdef PROFILE { - m_profileStatsLabel = new QLabel(this); - QFont courierFont("Courier"); - m_profileStatsLabel->setFont(courierFont); - m_profileStatsLabel->setAlignment(Qt::AlignTop); - ui->gridLayout->addWidget(m_profileStatsLabel, 0, 1); + m_profileDialog = new ProfileDialog(this); + auto profileMenu = new QMenu(this); + profileMenuUi = new Ui::ProfileMenu(); + profileMenuUi->setupUi(profileMenu); + ui->menuBar->insertMenu(ui->menuHelp->menuAction(), profileMenu); + connect(profileMenuUi->actionShowProfile, &QAction::triggered, m_profileDialog, &QWidget::show); + connect(profileMenuUi->actionResetProfile, &QAction::triggered, []() { CStatsManager::GetInstance().ResetStats(); }); } #endif @@ -475,7 +483,10 @@ void MainWindow::updateStats() uint32 drawCalls = CStatsManager::GetInstance().GetDrawCalls(); uint32 dcpf = (frames != 0) ? (drawCalls / frames) : 0; #ifdef PROFILE - m_profileStatsLabel->setText(QString::fromStdString(CStatsManager::GetInstance().GetProfilingInfo())); + if(m_profileDialog->isVisible()) + { + m_profileDialog->updateStats(CStatsManager::GetInstance().GetProfilingInfo()); + } #endif m_fpsLabel->setText(QString("%1 f/s, %2 dc/f").arg(frames).arg(dcpf)); CStatsManager::GetInstance().ClearStats(); diff --git a/Source/ui_qt/mainwindow.h b/Source/ui_qt/mainwindow.h index ae6b5e30cf..c84021c887 100644 --- a/Source/ui_qt/mainwindow.h +++ b/Source/ui_qt/mainwindow.h @@ -15,6 +15,14 @@ #include "InputProviderQtKey.h" #include "ScreenShotUtils.h" +#ifdef PROFILE +class ProfileDialog; +namespace Ui +{ + class ProfileMenu; +} +#endif + namespace Ui { class MainWindow; @@ -97,7 +105,8 @@ class MainWindow : public QMainWindow QLabel* m_fpsLabel = nullptr; QLabel* m_gsLabel = nullptr; #ifdef PROFILE - QLabel* m_profileStatsLabel = nullptr; + Ui::ProfileMenu* profileMenuUi = nullptr; + ProfileDialog* m_profileDialog; CPS2VM::ProfileFrameDoneSignal::Connection m_profileFrameDoneConnection; #endif ElidedLabel* m_msgLabel = nullptr; diff --git a/Source/ui_qt/profiledialog.cpp b/Source/ui_qt/profiledialog.cpp new file mode 100644 index 0000000000..87b13af748 --- /dev/null +++ b/Source/ui_qt/profiledialog.cpp @@ -0,0 +1,19 @@ +#include "profiledialog.h" +#include "ui_profiledialog.h" + +ProfileDialog::ProfileDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::ProfileDialog) +{ + ui->setupUi(this); +} + +ProfileDialog::~ProfileDialog() +{ + delete ui; +} + +void ProfileDialog::updateStats(std::string msg) +{ + ui->profileStatsLabel->setText(msg.c_str()); +} diff --git a/Source/ui_qt/profiledialog.h b/Source/ui_qt/profiledialog.h new file mode 100644 index 0000000000..741cbacfb0 --- /dev/null +++ b/Source/ui_qt/profiledialog.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace Ui +{ + class ProfileDialog; +} + +class + ProfileDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ProfileDialog(QWidget* parent = 0); + ~ProfileDialog(); + + void updateStats(std::string); + +private: + Ui::ProfileDialog* ui; +}; diff --git a/Source/ui_shared/StatsManager.cpp b/Source/ui_shared/StatsManager.cpp index 685061c03e..8bcdc60583 100644 --- a/Source/ui_shared/StatsManager.cpp +++ b/Source/ui_shared/StatsManager.cpp @@ -90,6 +90,20 @@ void CStatsManager::ClearStats() #endif } +void CStatsManager::ResetStats() +{ + std::lock_guard statsLock(m_statsMutex); +#ifdef PROFILE + for(auto& zonePair : m_profilerZones) + { + zonePair.second.minValue = ~0ULL; + zonePair.second.maxValue = 0; + zonePair.second.currentValue = 0; + } + m_cpuUtilisation = CPS2VM::CPU_UTILISATION_INFO(); +#endif +} + #ifdef PROFILE void CStatsManager::OnProfileFrameDone(CPS2VM* virtualMachine, const CProfiler::ZoneArray& zones) diff --git a/Source/ui_shared/StatsManager.h b/Source/ui_shared/StatsManager.h index 02832be157..45819c1334 100644 --- a/Source/ui_shared/StatsManager.h +++ b/Source/ui_shared/StatsManager.h @@ -19,6 +19,7 @@ class CStatsManager : public CSingleton #endif void ClearStats(); + void ResetStats(); #ifdef PROFILE void OnProfileFrameDone(CPS2VM*, const CProfiler::ZoneArray&); diff --git a/appveyor_build.cmd b/appveyor_build.cmd index f8733a2e44..a6306b644b 100644 --- a/appveyor_build.cmd +++ b/appveyor_build.cmd @@ -6,7 +6,7 @@ cd build if "%BUILD_PLAY%" == "ON" ( set BUILD_DIR=%cd% - cmake .. -G"%BUILD_TYPE%" -T v141_xp -DUSE_QT=on -DBUILD_LIBRETRO_CORE=yes -DCMAKE_PREFIX_PATH="C:\Qt\5.12\%QT_FLAVOR%" + cmake .. -G"%BUILD_TYPE%" -T v141_xp -DUSE_QT=on -DBUILD_LIBRETRO_CORE=yes -DPROFILE=yes -DCMAKE_PREFIX_PATH="C:\Qt\5.12\%QT_FLAVOR%" if !errorlevel! neq 0 exit /b !errorlevel! cmake --build . --config %CONFIG_TYPE%