From 1d914e195cc2a3ccd865496562ab7314276e5b57 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 24 May 2023 23:36:23 +0200 Subject: [PATCH] early-access version 3610 --- README.md | 2 +- src/video_core/buffer_cache/buffer_cache.h | 4 +- src/video_core/texture_cache/texture_cache.h | 4 +- src/yuzu/configuration/config.cpp | 36 ++++ src/yuzu/configuration/config.h | 6 + src/yuzu/main.cpp | 181 +++++++++++-------- 6 files changed, 157 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 79f64659e..03abe93a0 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3609. +This is the source code for early-access 3610. ## Legal Notice diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index c5caf2d77..99ef90e50 100755 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -30,8 +30,8 @@ BufferCache

::BufferCache(VideoCore::RasterizerInterface& rasterizer_, } const s64 device_memory = static_cast(runtime.GetDeviceLocalMemory()); - const s64 min_spacing_expected = device_memory - 1_GiB; - const s64 min_spacing_critical = device_memory - 512_MiB; + const s64 min_spacing_expected = device_memory - 1_GiB - 512_MiB; + const s64 min_spacing_critical = device_memory - 1_GiB; const s64 mem_threshold = std::min(device_memory, TARGET_THRESHOLD); const s64 min_vacancy_expected = (6 * mem_threshold) / 10; const s64 min_vacancy_critical = (3 * mem_threshold) / 10; diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 9e798e377..0f66631cf 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -49,8 +49,8 @@ TextureCache

::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& if constexpr (HAS_DEVICE_MEMORY_INFO) { const s64 device_memory = static_cast(runtime.GetDeviceLocalMemory()); - const s64 min_spacing_expected = device_memory - 1_GiB; - const s64 min_spacing_critical = device_memory - 512_MiB; + const s64 min_spacing_expected = device_memory - 1_GiB - 512_MiB; + const s64 min_spacing_critical = device_memory - 1_GiB; const s64 mem_threshold = std::min(device_memory, TARGET_THRESHOLD); const s64 min_vacancy_expected = (6 * mem_threshold) / 10; const s64 min_vacancy_critical = (3 * mem_threshold) / 10; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 8b958412e..65c33ae8f 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -65,6 +65,42 @@ const std::array Config::default_ringcon_analogs{{ Qt::Key_D, }}; +const std::map Config::anti_aliasing_texts_map = { + {Settings::AntiAliasing::None, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "None"))}, + {Settings::AntiAliasing::Fxaa, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "FXAA"))}, + {Settings::AntiAliasing::Smaa, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "SMAA"))}, +}; + +const std::map Config::scaling_filter_texts_map = { + {Settings::ScalingFilter::NearestNeighbor, + QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Nearest"))}, + {Settings::ScalingFilter::Bilinear, + QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Bilinear"))}, + {Settings::ScalingFilter::Bicubic, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Bicubic"))}, + {Settings::ScalingFilter::Gaussian, + QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Gaussian"))}, + {Settings::ScalingFilter::ScaleForce, + QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "ScaleForce"))}, + {Settings::ScalingFilter::Fsr, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "FSR"))}, +}; + +const std::map Config::use_docked_mode_texts_map = { + {true, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Docked"))}, + {false, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Handheld"))}, +}; + +const std::map Config::gpu_accuracy_texts_map = { + {Settings::GPUAccuracy::Normal, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Normal"))}, + {Settings::GPUAccuracy::High, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "High"))}, + {Settings::GPUAccuracy::Extreme, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Extreme"))}, +}; + +const std::map Config::renderer_backend_texts_map = { + {Settings::RendererBackend::Vulkan, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Vulkan"))}, + {Settings::RendererBackend::OpenGL, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "OpenGL"))}, + {Settings::RendererBackend::Null, QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "Null"))}, +}; + // This shouldn't have anything except static initializers (no functions). So // QKeySequence(...).toString() is NOT ALLOWED HERE. // This must be in alphabetical order according to action name as it must have the same order as diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index e304e7977..edc6fbad9 100755 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -49,6 +49,12 @@ public: static const std::array default_keyboard_mods; static const std::array default_hotkeys; + static const std::map anti_aliasing_texts_map; + static const std::map scaling_filter_texts_map; + static const std::map use_docked_mode_texts_map; + static const std::map gpu_accuracy_texts_map; + static const std::map renderer_backend_texts_map; + static constexpr UISettings::Theme default_theme{ #ifdef _WIN32 UISettings::Theme::DarkColorful diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 2657b92e3..203ddec78 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1054,6 +1054,24 @@ void GMainWindow::InitializeWidgets() { bottomLeft.setY(bottomLeft.y() - volume_popup->geometry().height()); volume_popup->setGeometry(QRect(bottomLeft, QSize(rect.width(), rect.height()))); }); + volume_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(volume_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + context_menu.addAction( + Settings::values.audio_muted ? tr("Unmute") : tr("Mute"), [this] { + Settings::values.audio_muted = !Settings::values.audio_muted; + UpdateVolumeUI(); + }); + + context_menu.addAction(tr("Reset Volume"), [this] { + Settings::values.volume.SetValue(100); + UpdateVolumeUI(); + }); + + context_menu.exec(volume_button->mapToGlobal(menu_location)); + volume_button->repaint(); + }); statusBar()->insertPermanentWidget(0, volume_button); // setup AA button @@ -1074,6 +1092,19 @@ void GMainWindow::InitializeWidgets() { UpdateAAText(); aa_status_button->setCheckable(true); aa_status_button->setChecked(true); + aa_status_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(aa_status_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + for (auto const& aa_text_pair : Config::anti_aliasing_texts_map) { + context_menu.addAction(aa_text_pair.second, [this, aa_text_pair] { + Settings::values.anti_aliasing.SetValue(aa_text_pair.first); + UpdateAAText(); + }); + } + context_menu.exec(aa_status_button->mapToGlobal(menu_location)); + aa_status_button->repaint(); + }); statusBar()->insertPermanentWidget(0, aa_status_button); // Setup Filter button @@ -1085,6 +1116,19 @@ void GMainWindow::InitializeWidgets() { UpdateFilterText(); filter_status_button->setCheckable(true); filter_status_button->setChecked(true); + filter_status_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(filter_status_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + for (auto const& filter_text_pair : Config::scaling_filter_texts_map) { + context_menu.addAction(filter_text_pair.second, [this, filter_text_pair] { + Settings::values.scaling_filter.SetValue(filter_text_pair.first); + UpdateFilterText(); + }); + } + context_menu.exec(filter_status_button->mapToGlobal(menu_location)); + filter_status_button->repaint(); + }); statusBar()->insertPermanentWidget(0, filter_status_button); // Setup Dock button @@ -1094,14 +1138,47 @@ void GMainWindow::InitializeWidgets() { connect(dock_status_button, &QPushButton::clicked, this, &GMainWindow::OnToggleDockedMode); dock_status_button->setCheckable(true); UpdateDockedButton(); + dock_status_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(dock_status_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + + for (auto const& docked_mode_pair : Config::use_docked_mode_texts_map) { + context_menu.addAction(docked_mode_pair.second, [this, docked_mode_pair] { + if (docked_mode_pair.first != Settings::values.use_docked_mode.GetValue()) { + OnToggleDockedMode(); + } + }); + } + context_menu.exec(dock_status_button->mapToGlobal(menu_location)); + dock_status_button->repaint(); + }); statusBar()->insertPermanentWidget(0, dock_status_button); + // Setup GPU Accuracy button gpu_accuracy_button = new QPushButton(); gpu_accuracy_button->setObjectName(QStringLiteral("GPUStatusBarButton")); gpu_accuracy_button->setCheckable(true); gpu_accuracy_button->setFocusPolicy(Qt::NoFocus); connect(gpu_accuracy_button, &QPushButton::clicked, this, &GMainWindow::OnToggleGpuAccuracy); UpdateGPUAccuracyButton(); + gpu_accuracy_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(gpu_accuracy_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + + for (auto const& gpu_accuracy_pair : Config::gpu_accuracy_texts_map) { + if (gpu_accuracy_pair.first == Settings::GPUAccuracy::Extreme) { + continue; + } + context_menu.addAction(gpu_accuracy_pair.second, [this, gpu_accuracy_pair] { + Settings::values.gpu_accuracy.SetValue(gpu_accuracy_pair.first); + UpdateGPUAccuracyButton(); + }); + } + context_menu.exec(gpu_accuracy_button->mapToGlobal(menu_location)); + gpu_accuracy_button->repaint(); + }); statusBar()->insertPermanentWidget(0, gpu_accuracy_button); // Setup Renderer API button @@ -1114,6 +1191,24 @@ void GMainWindow::InitializeWidgets() { renderer_status_button->setCheckable(true); renderer_status_button->setChecked(Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::Vulkan); + renderer_status_button->setContextMenuPolicy(Qt::CustomContextMenu); + connect(renderer_status_button, &QPushButton::customContextMenuRequested, + [this](const QPoint& menu_location) { + QMenu context_menu; + + for (auto const& renderer_backend_pair : Config::renderer_backend_texts_map) { + if (renderer_backend_pair.first == Settings::RendererBackend::Null) { + continue; + } + context_menu.addAction( + renderer_backend_pair.second, [this, renderer_backend_pair] { + Settings::values.renderer_backend.SetValue(renderer_backend_pair.first); + UpdateAPIText(); + }); + } + context_menu.exec(renderer_status_button->mapToGlobal(menu_location)); + renderer_status_button->repaint(); + }); statusBar()->insertPermanentWidget(0, renderer_status_button); statusBar()->setVisible(true); @@ -3980,94 +4075,38 @@ void GMainWindow::UpdateStatusBar() { } void GMainWindow::UpdateGPUAccuracyButton() { - switch (Settings::values.gpu_accuracy.GetValue()) { - case Settings::GPUAccuracy::Normal: { - gpu_accuracy_button->setText(tr("GPU NORMAL")); - gpu_accuracy_button->setChecked(false); - break; - } - case Settings::GPUAccuracy::High: { - gpu_accuracy_button->setText(tr("GPU HIGH")); - gpu_accuracy_button->setChecked(true); - break; - } - case Settings::GPUAccuracy::Extreme: { - gpu_accuracy_button->setText(tr("GPU EXTREME")); - gpu_accuracy_button->setChecked(true); - break; - } - default: { - gpu_accuracy_button->setText(tr("GPU ERROR")); - gpu_accuracy_button->setChecked(true); - break; - } - } + const auto gpu_accuracy = Settings::values.gpu_accuracy.GetValue(); + const auto gpu_accuracy_text = Config::gpu_accuracy_texts_map.find(gpu_accuracy)->second; + gpu_accuracy_button->setText(gpu_accuracy_text.toUpper()); + gpu_accuracy_button->setChecked(gpu_accuracy != Settings::GPUAccuracy::Normal); } void GMainWindow::UpdateDockedButton() { const bool is_docked = Settings::values.use_docked_mode.GetValue(); dock_status_button->setChecked(is_docked); - dock_status_button->setText(is_docked ? tr("DOCKED") : tr("HANDHELD")); + dock_status_button->setText( + Config::use_docked_mode_texts_map.find(is_docked)->second.toUpper()); } void GMainWindow::UpdateAPIText() { const auto api = Settings::values.renderer_backend.GetValue(); - switch (api) { - case Settings::RendererBackend::OpenGL: - renderer_status_button->setText(tr("OPENGL")); - break; - case Settings::RendererBackend::Vulkan: - renderer_status_button->setText(tr("VULKAN")); - break; - case Settings::RendererBackend::Null: - renderer_status_button->setText(tr("NULL")); - break; - } + const auto renderer_status_text = Config::renderer_backend_texts_map.find(api)->second; + renderer_status_button->setText(renderer_status_text.toUpper()); } void GMainWindow::UpdateFilterText() { const auto filter = Settings::values.scaling_filter.GetValue(); - switch (filter) { - case Settings::ScalingFilter::NearestNeighbor: - filter_status_button->setText(tr("NEAREST")); - break; - case Settings::ScalingFilter::Bilinear: - filter_status_button->setText(tr("BILINEAR")); - break; - case Settings::ScalingFilter::Bicubic: - filter_status_button->setText(tr("BICUBIC")); - break; - case Settings::ScalingFilter::Gaussian: - filter_status_button->setText(tr("GAUSSIAN")); - break; - case Settings::ScalingFilter::ScaleForce: - filter_status_button->setText(tr("SCALEFORCE")); - break; - case Settings::ScalingFilter::Fsr: - filter_status_button->setText(tr("FSR")); - break; - default: - filter_status_button->setText(tr("BILINEAR")); - break; - } + const auto filter_text = Config::scaling_filter_texts_map.find(filter)->second; + filter_status_button->setText(filter == Settings::ScalingFilter::Fsr ? tr("FSR") + : filter_text.toUpper()); } void GMainWindow::UpdateAAText() { const auto aa_mode = Settings::values.anti_aliasing.GetValue(); - switch (aa_mode) { - case Settings::AntiAliasing::None: - aa_status_button->setText(tr("NO AA")); - break; - case Settings::AntiAliasing::Fxaa: - aa_status_button->setText(tr("FXAA")); - break; - case Settings::AntiAliasing::Smaa: - aa_status_button->setText(tr("SMAA")); - break; - default: - aa_status_button->setText(tr("NO AA")); - break; - } + const auto aa_text = Config::anti_aliasing_texts_map.find(aa_mode)->second; + aa_status_button->setText(aa_mode == Settings::AntiAliasing::None + ? QStringLiteral(QT_TRANSLATE_NOOP("GMainWindow", "NO AA")) + : aa_text.toUpper()); } void GMainWindow::UpdateVolumeUI() {