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(ENABLE_MICROPROFILE "Enables microprofile capabilities" OFF)
option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")

5
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)

11
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 <QAction>
#include <QLayout>
#include <QMouseEvent>
@ -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;

3
src/yuzu/debugger/profiler.h

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

8
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();

4
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;

Loading…
Cancel
Save