diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c2a880ae0..f775cdf87b 100644 --- a/CMakeLists.txt +++ b/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(ENABLE_MICROPROFILE "Enables microprofile capabilities" OFF) + option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}") if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index cd7b80a33c..9d63d53faf 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -51,6 +51,11 @@ endif() # MicroProfile add_library(microprofile INTERFACE) 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 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND MINGW) diff --git a/src/yuzu/debugger/profiler.cpp b/src/yuzu/debugger/profiler.cpp index 493ee0b178..4ea146aa62 100644 --- a/src/yuzu/debugger/profiler.cpp +++ b/src/yuzu/debugger/profiler.cpp @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: 2015 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#if MICROPROFILE_ENABLED + #include #include #include @@ -14,7 +16,7 @@ // 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). -#if MICROPROFILE_ENABLED + #define MICROPROFILEUI_IMPL 1 #include "common/microprofileui.h" @@ -43,8 +45,6 @@ private: qreal x_scale = 1.0, y_scale = 1.0; }; -#endif - MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) { setObjectName(QStringLiteral("MicroProfile")); setWindowTitle(tr("&MicroProfile")); @@ -52,8 +52,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di // Enable the maximize button setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); -#if MICROPROFILE_ENABLED - MicroProfileWidget* widget = new MicroProfileWidget(this); QLayout* layout = new QVBoxLayout(this); @@ -66,7 +64,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di setFocusProxy(widget); widget->setFocusPolicy(Qt::StrongFocus); widget->setFocus(); -#endif } QAction* MicroProfileDialog::toggleViewAction() { @@ -94,8 +91,6 @@ void MicroProfileDialog::hideEvent(QHideEvent* 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 /// QPainter available inside the drawing callbacks. static QPainter* mp_painter = nullptr; diff --git a/src/yuzu/debugger/profiler.h b/src/yuzu/debugger/profiler.h index 4c8ccd3c2f..9fc3865fa8 100644 --- a/src/yuzu/debugger/profiler.h +++ b/src/yuzu/debugger/profiler.h @@ -3,6 +3,8 @@ #pragma once +#if MICROPROFILE_ENABLED + #include class QAction; @@ -25,3 +27,4 @@ protected: private: QAction* toggle_view_action = nullptr; }; +#endif diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 9b35069307..a46c5cd881 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1348,6 +1348,11 @@ void GMainWindow::InitializeDebugWidgets() { microProfileDialog = new MicroProfileDialog(this); microProfileDialog->hide(); 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 waitTreeWidget = new WaitTreeWidget(*system, this); @@ -5630,10 +5635,13 @@ int main(int argc, char* argv[]) { #endif Common::DetachedTasks detached_tasks; + +#if MICROPROFILE_ENABLED MicroProfileOnThreadCreate("Frontend"); SCOPE_EXIT { MicroProfileShutdown(); }; +#endif Common::ConfigureNvidiaEnvironmentFlags(); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 7e7c00ec0b..b6f818099a 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -43,7 +43,9 @@ class GameList; class GImageInfo; class GRenderWindow; class LoadingScreen; +#if MICROPROFILE_ENABLED class MicroProfileDialog; +#endif class OverlayDialog; class ProfilerWidget; class ControllerDialog; @@ -565,7 +567,9 @@ private: // Debugger panes ProfilerWidget* profilerWidget; +#if MICROPROFILE_ENABLED MicroProfileDialog* microProfileDialog; +#endif WaitTreeWidget* waitTreeWidget; ControllerDialog* controller_dialog;