diff options
Diffstat (limited to 'src/yuzu/main.cpp')
| -rw-r--r-- | src/yuzu/main.cpp | 145 |
1 files changed, 108 insertions, 37 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5802b9855..aa9028399 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -18,7 +18,6 @@ #include "common/logging/log.h" #include "common/logging/text_formatter.h" #include "common/microprofile.h" -#include "common/platform.h" #include "common/scm_rev.h" #include "common/scope_exit.h" #include "common/string_util.h" @@ -26,12 +25,14 @@ #include "core/gdbstub/gdbstub.h" #include "core/loader/loader.h" #include "core/settings.h" +#include "video_core/debug_utils/debug_utils.h" #include "yuzu/about_dialog.h" #include "yuzu/bootmanager.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_dialog.h" +#include "yuzu/debugger/graphics/graphics_breakpoints.h" +#include "yuzu/debugger/graphics/graphics_surface.h" #include "yuzu/debugger/profiler.h" -#include "yuzu/debugger/registers.h" #include "yuzu/debugger/wait_tree.h" #include "yuzu/game_list.h" #include "yuzu/hotkeys.h" @@ -42,6 +43,15 @@ Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); #endif +#ifdef _WIN32 +extern "C" { +// tells Nvidia and AMD drivers to use the dedicated GPU by default on laptops with switchable +// graphics +__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; +__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +} +#endif + /** * "Callouts" are one-time instructional messages shown to the user. In the config settings, there * is a bitfield "callout_flags" options, used to track if a message has already been shown to the @@ -69,10 +79,16 @@ static void ShowCalloutMessage(const QString& message, CalloutFlag flag) { void GMainWindow::ShowCallouts() {} GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { + + debug_context = Tegra::DebugContext::Construct(); + setAcceptDrops(true); ui.setupUi(this); statusBar()->hide(); + default_theme_paths = QIcon::themeSearchPaths(); + UpdateUITheme(); + InitializeWidgets(); InitializeDebugWidgets(); InitializeRecentFileMenuActions(); @@ -152,14 +168,15 @@ void GMainWindow::InitializeDebugWidgets() { debug_menu->addAction(microProfileDialog->toggleViewAction()); #endif - registersWidget = new RegistersWidget(this); - addDockWidget(Qt::RightDockWidgetArea, registersWidget); - registersWidget->hide(); - debug_menu->addAction(registersWidget->toggleViewAction()); - connect(this, &GMainWindow::EmulationStarting, registersWidget, - &RegistersWidget::OnEmulationStarting); - connect(this, &GMainWindow::EmulationStopping, registersWidget, - &RegistersWidget::OnEmulationStopping); + graphicsBreakpointsWidget = new GraphicsBreakPointsWidget(debug_context, this); + addDockWidget(Qt::RightDockWidgetArea, graphicsBreakpointsWidget); + graphicsBreakpointsWidget->hide(); + debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction()); + + graphicsSurfaceWidget = new GraphicsSurfaceWidget(debug_context, this); + addDockWidget(Qt::RightDockWidgetArea, graphicsSurfaceWidget); + graphicsSurfaceWidget->hide(); + debug_menu->addAction(graphicsSurfaceWidget->toggleViewAction()); waitTreeWidget = new WaitTreeWidget(this); addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget); @@ -308,6 +325,24 @@ void GMainWindow::OnDisplayTitleBars(bool show) { } } +bool GMainWindow::SupportsRequiredGLExtensions() { + QStringList unsupported_ext; + + if (!GLAD_GL_ARB_program_interface_query) + unsupported_ext.append("ARB_program_interface_query"); + if (!GLAD_GL_ARB_separate_shader_objects) + unsupported_ext.append("ARB_separate_shader_objects"); + if (!GLAD_GL_ARB_shader_storage_buffer_object) + unsupported_ext.append("ARB_shader_storage_buffer_object"); + if (!GLAD_GL_ARB_vertex_attrib_binding) + unsupported_ext.append("ARB_vertex_attrib_binding"); + + for (const QString& ext : unsupported_ext) + NGLOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString()); + + return unsupported_ext.empty(); +} + bool GMainWindow::LoadROM(const QString& filename) { // Shutdown previous session if the emu thread is still active... if (emu_thread != nullptr) @@ -323,23 +358,34 @@ bool GMainWindow::LoadROM(const QString& filename) { return false; } + if (!SupportsRequiredGLExtensions()) { + QMessageBox::critical( + this, tr("Error while initializing OpenGL Core!"), + tr("Your GPU may not support one or more required OpenGL extensions. Please " + "ensure you have the latest graphics driver. See the log for more details.")); + return false; + } + Core::System& system{Core::System::GetInstance()}; - const Core::System::ResultStatus result{system.Load(render_window, filename.toStdString())}; + system.SetGPUDebugContext(debug_context); - Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); + const Core::System::ResultStatus result{system.Load(render_window, filename.toStdString())}; if (result != Core::System::ResultStatus::Success) { switch (result) { case Core::System::ResultStatus::ErrorGetLoader: - LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", - filename.toStdString().c_str()); + NGLOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filename.toStdString()); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("The ROM format is not supported.")); break; - + case Core::System::ResultStatus::ErrorUnsupportedArch: + NGLOG_CRITICAL(Frontend, "Unsupported architecture detected!", filename.toStdString()); + QMessageBox::critical(this, tr("Error while loading ROM!"), + tr("The ROM uses currently unusable 32-bit architecture")); + break; case Core::System::ResultStatus::ErrorSystemMode: - LOG_CRITICAL(Frontend, "Failed to load ROM!"); + NGLOG_CRITICAL(Frontend, "Failed to load ROM!"); QMessageBox::critical(this, tr("Error while loading ROM!"), tr("Could not determine the system mode.")); break; @@ -351,9 +397,9 @@ bool GMainWindow::LoadROM(const QString& filename) { "yuzu. A real Switch is required.<br/><br/>" "For more information on dumping and decrypting games, please see the following " "wiki pages: <ul>" - "<li><a href='https://citra-emu.org/wiki/dumping-game-cartridges/'>Dumping Game " + "<li><a href='https://yuzu-emu.org/wiki/dumping-game-cartridges/'>Dumping Game " "Cartridges</a></li>" - "<li><a href='https://citra-emu.org/wiki/dumping-installed-titles/'>Dumping " + "<li><a href='https://yuzu-emu.org/wiki/dumping-installed-titles/'>Dumping " "Installed Titles</a></li>" "</ul>")); break; @@ -384,11 +430,12 @@ bool GMainWindow::LoadROM(const QString& filename) { } return false; } + Core::Telemetry().AddField(Telemetry::FieldType::App, "Frontend", "Qt"); return true; } void GMainWindow::BootGame(const QString& filename) { - LOG_INFO(Frontend, "yuzu starting..."); + NGLOG_INFO(Frontend, "yuzu starting..."); StoreRecentFile(filename); // Put the filename on top of the list if (!LoadROM(filename)) @@ -403,17 +450,12 @@ void GMainWindow::BootGame(const QString& filename) { connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame); // BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views // before the CPU continues - connect(emu_thread.get(), &EmuThread::DebugModeEntered, registersWidget, - &RegistersWidget::OnDebugModeEntered, Qt::BlockingQueuedConnection); connect(emu_thread.get(), &EmuThread::DebugModeEntered, waitTreeWidget, &WaitTreeWidget::OnDebugModeEntered, Qt::BlockingQueuedConnection); - connect(emu_thread.get(), &EmuThread::DebugModeLeft, registersWidget, - &RegistersWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection); connect(emu_thread.get(), &EmuThread::DebugModeLeft, waitTreeWidget, &WaitTreeWidget::OnDebugModeLeft, Qt::BlockingQueuedConnection); // Update the GUI - registersWidget->OnDebugModeEntered(); if (ui.action_Single_Window_Mode->isChecked()) { game_list->hide(); } @@ -636,6 +678,7 @@ void GMainWindow::OnConfigure() { auto result = configureDialog.exec(); if (result == QDialog::Accepted) { configureDialog.applyConfiguration(); + UpdateUITheme(); config->Save(); } } @@ -674,18 +717,18 @@ void GMainWindow::UpdateStatusBar() { void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { QMessageBox::StandardButton answer; QString status_message; - const QString common_message = - tr("The game you are trying to load requires additional files from your 3DS to be dumped " - "before playing.<br/><br/>For more information on dumping these files, please see the " - "following wiki page: <a " - "href='https://citra-emu.org/wiki/" - "dumping-system-archives-and-the-shared-fonts-from-a-3ds-console/'>Dumping System " - "Archives and the Shared Fonts from a 3DS Console</a>.<br/><br/>Would you like to quit " - "back to the game list? Continuing emulation may result in crashes, corrupted save " - "data, or other bugs."); + const QString common_message = tr( + "The game you are trying to load requires additional files from your Switch to be dumped " + "before playing.<br/><br/>For more information on dumping these files, please see the " + "following wiki page: <a " + "href='https://yuzu-emu.org/wiki/" + "dumping-system-archives-and-the-shared-fonts-from-a-switch-console/'>Dumping System " + "Archives and the Shared Fonts from a Switch Console</a>.<br/><br/>Would you like to quit " + "back to the game list? Continuing emulation may result in crashes, corrupted save " + "data, or other bugs."); switch (result) { case Core::System::ResultStatus::ErrorSystemFiles: { - QString message = "Citra was unable to locate a 3DS system archive"; + QString message = "yuzu was unable to locate a Switch system archive"; if (!details.empty()) { message.append(tr(": %1. ").arg(details.c_str())); } else { @@ -700,7 +743,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det } case Core::System::ResultStatus::ErrorSharedFont: { - QString message = tr("Citra was unable to locate the 3DS shared fonts. "); + QString message = tr("yuzu was unable to locate the Switch shared fonts. "); message.append(common_message); answer = QMessageBox::question(this, tr("Shared Fonts Not Found"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No); @@ -751,9 +794,11 @@ void GMainWindow::closeEvent(QCloseEvent* event) { return; } - UISettings::values.geometry = saveGeometry(); + if (ui.action_Fullscreen->isChecked()) { + UISettings::values.geometry = saveGeometry(); + UISettings::values.renderwindow_geometry = render_window->saveGeometry(); + } UISettings::values.state = saveState(); - UISettings::values.renderwindow_geometry = render_window->saveGeometry(); #if MICROPROFILE_ENABLED UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); UISettings::values.microprofile_visible = microProfileDialog->isVisible(); @@ -816,6 +861,32 @@ void GMainWindow::filterBarSetChecked(bool state) { emit(OnToggleFilterBar()); } +void GMainWindow::UpdateUITheme() { + QStringList theme_paths(default_theme_paths); + if (UISettings::values.theme != UISettings::themes[0].second && + !UISettings::values.theme.isEmpty()) { + QString theme_uri(":" + UISettings::values.theme + "/style.qss"); + QFile f(theme_uri); + if (!f.exists()) { + NGLOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); + } else { + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); + qApp->setStyleSheet(ts.readAll()); + GMainWindow::setStyleSheet(ts.readAll()); + } + theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme}); + QIcon::setThemeName(":/icons/" + UISettings::values.theme); + } else { + qApp->setStyleSheet(""); + GMainWindow::setStyleSheet(""); + theme_paths.append(QStringList{":/icons/default"}); + QIcon::setThemeName(":/icons/default"); + } + QIcon::setThemeSearchPaths(theme_paths); + emit UpdateThemedIcons(); +} + #ifdef main #undef main #endif |
