Browse Source

Add cmake option to enable microprofile

Co-authored-by: PabloMK7 <hackyglitch2@gmail.com>
pull/179/head
Gamer64 8 months ago
committed by crueter
parent
commit
45ae3d5cd3
  1. 2
      CMakeLists.txt
  2. 5
      externals/CMakeLists.txt
  3. 11
      src/yuzu/debugger/profiler.cpp
  4. 3
      src/yuzu/debugger/profiler.h
  5. 8
      src/yuzu/main.cpp
  6. 4
      src/yuzu/main.h

2
CMakeLists.txt

@ -86,6 +86,8 @@ option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF)
option(ENABLE_MICROPROFILE "Enables microprofile capabilities" OFF)
option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")

5
externals/CMakeLists.txt

@ -51,6 +51,11 @@ endif()
# MicroProfile # MicroProfile
add_library(microprofile INTERFACE) add_library(microprofile INTERFACE)
target_include_directories(microprofile INTERFACE ./microprofile) target_include_directories(microprofile INTERFACE ./microprofile)
if (ENABLE_MICROPROFILE)
target_compile_definitions(microprofile INTERFACE MICROPROFILE_ENABLED=1)
else()
target_compile_definitions(microprofile INTERFACE MICROPROFILE_ENABLED=0)
endif()
# GCC bugs # GCC bugs
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND MINGW) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND MINGW)

11
src/yuzu/debugger/profiler.cpp

@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: 2015 Citra Emulator Project // SPDX-FileCopyrightText: 2015 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#if MICROPROFILE_ENABLED
#include <QAction> #include <QAction>
#include <QLayout> #include <QLayout>
#include <QMouseEvent> #include <QMouseEvent>
@ -14,7 +16,7 @@
// Include the implementation of the UI in this file. This isn't in microprofile.cpp because the // Include the implementation of the UI in this file. This isn't in microprofile.cpp because the
// non-Qt frontends don't need it (and don't implement the UI drawing hooks either). // non-Qt frontends don't need it (and don't implement the UI drawing hooks either).
#if MICROPROFILE_ENABLED
#define MICROPROFILEUI_IMPL 1 #define MICROPROFILEUI_IMPL 1
#include "common/microprofileui.h" #include "common/microprofileui.h"
@ -43,8 +45,6 @@ private:
qreal x_scale = 1.0, y_scale = 1.0; qreal x_scale = 1.0, y_scale = 1.0;
}; };
#endif
MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) {
setObjectName(QStringLiteral("MicroProfile")); setObjectName(QStringLiteral("MicroProfile"));
setWindowTitle(tr("&MicroProfile")); setWindowTitle(tr("&MicroProfile"));
@ -52,8 +52,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di
// Enable the maximize button // Enable the maximize button
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
#if MICROPROFILE_ENABLED
MicroProfileWidget* widget = new MicroProfileWidget(this); MicroProfileWidget* widget = new MicroProfileWidget(this);
QLayout* layout = new QVBoxLayout(this); QLayout* layout = new QVBoxLayout(this);
@ -66,7 +64,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di
setFocusProxy(widget); setFocusProxy(widget);
widget->setFocusPolicy(Qt::StrongFocus); widget->setFocusPolicy(Qt::StrongFocus);
widget->setFocus(); widget->setFocus();
#endif
} }
QAction* MicroProfileDialog::toggleViewAction() { QAction* MicroProfileDialog::toggleViewAction() {
@ -94,8 +91,6 @@ void MicroProfileDialog::hideEvent(QHideEvent* ev) {
QWidget::hideEvent(ev); QWidget::hideEvent(ev);
} }
#if MICROPROFILE_ENABLED
/// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the /// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the
/// QPainter available inside the drawing callbacks. /// QPainter available inside the drawing callbacks.
static QPainter* mp_painter = nullptr; static QPainter* mp_painter = nullptr;

3
src/yuzu/debugger/profiler.h

@ -3,6 +3,8 @@
#pragma once #pragma once
#if MICROPROFILE_ENABLED
#include <QWidget> #include <QWidget>
class QAction; class QAction;
@ -25,3 +27,4 @@ protected:
private: private:
QAction* toggle_view_action = nullptr; QAction* toggle_view_action = nullptr;
}; };
#endif

8
src/yuzu/main.cpp

@ -1348,6 +1348,11 @@ void GMainWindow::InitializeDebugWidgets() {
microProfileDialog = new MicroProfileDialog(this); microProfileDialog = new MicroProfileDialog(this);
microProfileDialog->hide(); microProfileDialog->hide();
debug_menu->addAction(microProfileDialog->toggleViewAction()); debug_menu->addAction(microProfileDialog->toggleViewAction());
#else
auto micro_profile_stub = new QAction(tr("MicroProfile (unavailable)"), this);
micro_profile_stub->setEnabled(false);
micro_profile_stub->setChecked(false);
debug_menu->addAction(micro_profile_stub);
#endif #endif
waitTreeWidget = new WaitTreeWidget(*system, this); waitTreeWidget = new WaitTreeWidget(*system, this);
@ -5630,10 +5635,13 @@ int main(int argc, char* argv[]) {
#endif #endif
Common::DetachedTasks detached_tasks; Common::DetachedTasks detached_tasks;
#if MICROPROFILE_ENABLED
MicroProfileOnThreadCreate("Frontend"); MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT { SCOPE_EXIT {
MicroProfileShutdown(); MicroProfileShutdown();
}; };
#endif
Common::ConfigureNvidiaEnvironmentFlags(); Common::ConfigureNvidiaEnvironmentFlags();

4
src/yuzu/main.h

@ -43,7 +43,9 @@ class GameList;
class GImageInfo; class GImageInfo;
class GRenderWindow; class GRenderWindow;
class LoadingScreen; class LoadingScreen;
#if MICROPROFILE_ENABLED
class MicroProfileDialog; class MicroProfileDialog;
#endif
class OverlayDialog; class OverlayDialog;
class ProfilerWidget; class ProfilerWidget;
class ControllerDialog; class ControllerDialog;
@ -565,7 +567,9 @@ private:
// Debugger panes // Debugger panes
ProfilerWidget* profilerWidget; ProfilerWidget* profilerWidget;
#if MICROPROFILE_ENABLED
MicroProfileDialog* microProfileDialog; MicroProfileDialog* microProfileDialog;
#endif
WaitTreeWidget* waitTreeWidget; WaitTreeWidget* waitTreeWidget;
ControllerDialog* controller_dialog; ControllerDialog* controller_dialog;

Loading…
Cancel
Save