Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Qt profile #900

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Source/ui_qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ set(QT_SOURCES
memorycardmanagerdialog.cpp
memorycardmanagerdialog.h
PreferenceDefs.h
profiledialog.cpp
profiledialog.h
QStringUtils.cpp
QStringUtils.h
vfsmanagerdialog.cpp
Expand Down Expand Up @@ -199,6 +201,7 @@ set(QT_MOC_HEADERS
openglwindow.h
outputwindow.h
memorycardmanagerdialog.h
profiledialog.h
S3FileBrowser.h
vfsmanagerdialog.h
vfsmodel.h
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Source/ui_qt/Qt_ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@
<string>Ctrl+L</string>
</property>
</action>
<action name="actionShow_Profile_Dialog">
<property name="text">
<string>Show Profile Dialog</string>
</property>
</action>
<action name="actionProfileReset">
<property name="text">
<string>Reset</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
Expand Down
36 changes: 36 additions & 0 deletions Source/ui_qt/Qt_ui/profiledialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileDialog</class>
<widget class="QDialog" name="ProfileDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>248</height>
</rect>
</property>
<property name="sizeIncrement">
<size>
<width>810</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Profile Dialog</string>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QTextEdit" name="profileStatsLabel">
<property name="font">
<font>
<family>Courier</family>
</font>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
23 changes: 23 additions & 0 deletions Source/ui_qt/Qt_ui/profilemenu.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileMenu</class>
<widget class="QMenu" name="ProfileMenu">
<property name="title">
<string>Profile</string>
</property>
<action name="actionShowProfile">
<property name="text">
<string>Show</string>
</property>
</action>
<action name="actionResetProfile">
<property name="text">
<string>Reset</string>
</property>
</action>
<addaction name="actionShowProfile"/>
<addaction name="actionResetProfile"/>
</widget>
<resources/>
<connections/>
</ui>
23 changes: 17 additions & 6 deletions Source/ui_qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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();
Expand Down
11 changes: 10 additions & 1 deletion Source/ui_qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
#include "InputProviderQtKey.h"
#include "ScreenShotUtils.h"

#ifdef PROFILE
class ProfileDialog;
namespace Ui
{
class ProfileMenu;
}
#endif

namespace Ui
{
class MainWindow;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions Source/ui_qt/profiledialog.cpp
Original file line number Diff line number Diff line change
@@ -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());
}
23 changes: 23 additions & 0 deletions Source/ui_qt/profiledialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <QDialog>

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;
};
14 changes: 14 additions & 0 deletions Source/ui_shared/StatsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ void CStatsManager::ClearStats()
#endif
}

void CStatsManager::ResetStats()
{
std::lock_guard<std::mutex> 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)
Expand Down
1 change: 1 addition & 0 deletions Source/ui_shared/StatsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CStatsManager : public CSingleton<CStatsManager>
#endif

void ClearStats();
void ResetStats();

#ifdef PROFILE
void OnProfileFrameDone(CPS2VM*, const CProfiler::ZoneArray&);
Expand Down
2 changes: 1 addition & 1 deletion appveyor_build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand Down