diff --git a/src/android/app/src/main/jni/config.cpp b/src/android/app/src/main/jni/config.cpp index 7a2746224..7411f1e62 100644 --- a/src/android/app/src/main/jni/config.cpp +++ b/src/android/app/src/main/jni/config.cpp @@ -150,6 +150,7 @@ void Config::ReadValues() { ReadSetting("Renderer", Settings::values.use_hw_shader); ReadSetting("Renderer", Settings::values.use_shader_jit); ReadSetting("Renderer", Settings::values.resolution_factor); + ReadSetting("Renderer", Settings::values.sample_count); ReadSetting("Renderer", Settings::values.use_disk_shader_cache); ReadSetting("Renderer", Settings::values.use_vsync); ReadSetting("Renderer", Settings::values.texture_filter); diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 9091d734b..b545f0424 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -716,6 +716,7 @@ void QtConfig::ReadRendererValues() { ReadGlobalSetting(Settings::values.use_vsync); ReadGlobalSetting(Settings::values.use_display_refresh_rate_detection); ReadGlobalSetting(Settings::values.resolution_factor); + ReadGlobalSetting(Settings::values.sample_count); ReadGlobalSetting(Settings::values.use_integer_scaling); ReadGlobalSetting(Settings::values.frame_limit); ReadGlobalSetting(Settings::values.turbo_limit); @@ -1265,6 +1266,7 @@ void QtConfig::SaveRendererValues() { WriteGlobalSetting(Settings::values.use_vsync); WriteGlobalSetting(Settings::values.use_display_refresh_rate_detection); WriteGlobalSetting(Settings::values.resolution_factor); + WriteGlobalSetting(Settings::values.sample_count); WriteGlobalSetting(Settings::values.use_integer_scaling); WriteGlobalSetting(Settings::values.frame_limit); WriteGlobalSetting(Settings::values.turbo_limit); diff --git a/src/citra_qt/configuration/configure_enhancements.cpp b/src/citra_qt/configuration/configure_enhancements.cpp index 62afcbb77..01bd0cb8a 100644 --- a/src/citra_qt/configuration/configure_enhancements.cpp +++ b/src/citra_qt/configuration/configure_enhancements.cpp @@ -21,6 +21,8 @@ ConfigureEnhancements::ConfigureEnhancements(QWidget* parent) const auto graphics_api = Settings::values.graphics_api.GetValue(); const bool res_scale_enabled = graphics_api != Settings::GraphicsAPI::Software; ui->resolution_factor_combobox->setEnabled(res_scale_enabled); + const bool msaa_enabled = graphics_api == Settings::GraphicsAPI::Vulkan; + ui->sample_count_combobox->setEnabled(msaa_enabled); connect(ui->render_3d_combobox, qOverload(&QComboBox::currentIndexChanged), this, [this](int currentIndex) { @@ -44,6 +46,8 @@ void ConfigureEnhancements::SetConfiguration() { if (!Settings::IsConfiguringGlobal()) { ConfigurationShared::SetPerGameSetting(ui->resolution_factor_combobox, &Settings::values.resolution_factor); + ConfigurationShared::SetPerGameSetting(ui->sample_count_combobox, + &Settings::values.sample_count); ConfigurationShared::SetPerGameSetting(ui->texture_filter_combobox, &Settings::values.texture_filter); ConfigurationShared::SetHighlight(ui->widget_texture_filter, @@ -51,6 +55,8 @@ void ConfigureEnhancements::SetConfiguration() { } else { ui->resolution_factor_combobox->setCurrentIndex( Settings::values.resolution_factor.GetValue()); + ui->sample_count_combobox->setCurrentIndex( + static_cast(Settings::values.sample_count.GetValue())); ui->texture_filter_combobox->setCurrentIndex( static_cast(Settings::values.texture_filter.GetValue())); } @@ -111,6 +117,8 @@ void ConfigureEnhancements::RetranslateUI() { void ConfigureEnhancements::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.resolution_factor, ui->resolution_factor_combobox); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.sample_count, + ui->sample_count_combobox); Settings::values.render_3d = static_cast(ui->render_3d_combobox->currentIndex()); Settings::values.swap_eyes_3d = ui->swap_eyes_3d->isChecked(); @@ -149,6 +157,7 @@ void ConfigureEnhancements::SetupPerGameUI() { // Block the global settings if a game is currently running that overrides them if (Settings::IsConfiguringGlobal()) { ui->widget_resolution->setEnabled(Settings::values.resolution_factor.UsingGlobal()); + ui->widget_sample_count->setEnabled(Settings::values.sample_count.UsingGlobal()); ui->widget_texture_filter->setEnabled(Settings::values.texture_filter.UsingGlobal()); ui->toggle_linear_filter->setEnabled(Settings::values.filter_mode.UsingGlobal()); ui->use_integer_scaling->setEnabled(Settings::values.use_integer_scaling.UsingGlobal()); @@ -189,6 +198,10 @@ void ConfigureEnhancements::SetupPerGameUI() { ui->resolution_factor_combobox, ui->widget_resolution, static_cast(Settings::values.resolution_factor.GetValue(true))); + ConfigurationShared::SetColoredComboBox( + ui->sample_count_combobox, ui->widget_sample_count, + static_cast(Settings::values.sample_count.GetValue(true))); + ConfigurationShared::SetColoredComboBox( ui->texture_filter_combobox, ui->widget_texture_filter, static_cast(Settings::values.texture_filter.GetValue(true))); diff --git a/src/citra_qt/configuration/configure_enhancements.ui b/src/citra_qt/configuration/configure_enhancements.ui index dc3c3deaf..f040fb7ce 100644 --- a/src/citra_qt/configuration/configure_enhancements.ui +++ b/src/citra_qt/configuration/configure_enhancements.ui @@ -111,15 +111,64 @@ - - - Use Integer Scaling - - - <html><head/><body><p>Use Integer Scaling</p><p>Enforces that the larger screen in all layouts is an integer scale of the 240px height of the original 3DS screen.</p></body></html> - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Sample count + + + + + + + + Native (x1) + + + + + x2 + + + + + x4 + + + + + x8 + + + + + + + + + Use Integer Scaling + + + <html><head/><body><p>Use Integer Scaling</p><p>Enforces that the larger screen in all layouts is an integer scale of the 240px height of the original 3DS screen.</p></body></html> + + + diff --git a/src/common/settings.cpp b/src/common/settings.cpp index df8451e28..56a6200c9 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -97,6 +97,7 @@ void LogSettings() { log_setting("Renderer_ShadersAccurateMul", values.shaders_accurate_mul.GetValue()); log_setting("Renderer_UseShaderJit", values.use_shader_jit.GetValue()); log_setting("Renderer_UseResolutionFactor", values.resolution_factor.GetValue()); + log_setting("Renderer_SampleCount", values.sample_count.GetValue()); log_setting("Renderer_UseIntegerScaling", values.use_integer_scaling.GetValue()); log_setting("Renderer_FrameLimit", values.frame_limit.GetValue()); log_setting("Renderer_VSyncNew", values.use_vsync.GetValue()); @@ -213,6 +214,7 @@ void RestoreGlobalState(bool is_powered_on) { values.shaders_accurate_mul.SetGlobal(true); values.use_vsync.SetGlobal(true); values.resolution_factor.SetGlobal(true); + values.sample_count.SetGlobal(true); values.use_integer_scaling.SetGlobal(true); values.frame_limit.SetGlobal(true); values.texture_filter.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index 4196557d1..b0d0ccb9e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -535,6 +535,7 @@ struct Values { true, Keys::use_display_refresh_rate_detection}; Setting use_shader_jit{true, Keys::use_shader_jit}; SwitchableSetting resolution_factor{1, 0, 10, Keys::resolution_factor}; + SwitchableSetting sample_count{0, 0, 3, "sample_count"}; SwitchableSetting use_integer_scaling{false, Keys::use_integer_scaling}; SwitchableSetting frame_limit{100, 0, 1000, Keys::frame_limit}; SwitchableSetting turbo_limit{200, 0, 1000, Keys::turbo_limit}; diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index e78ab9c91..8331664da 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -29,6 +29,17 @@ u32 RendererBase::GetResolutionScaleFactor() { : render_window.GetFramebufferLayout().GetScalingRatio(); } +u8 RendererBase::GetSampleCount() const { + const auto graphics_api = Settings::values.graphics_api.GetValue(); + + // Enabled for vulkan only for now + if (graphics_api != Settings::GraphicsAPI::Vulkan) { + return 1; + } + + return static_cast(1u << Settings::values.sample_count.GetValue()); +} + void RendererBase::UpdateCurrentFramebufferLayout(bool is_portrait_mode) { const auto update_layout = [is_portrait_mode](Frontend::EmuWindow& window) { const Layout::FramebufferLayout& layout = window.GetFramebufferLayout(); diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 5a737a37f..fa647faa4 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -67,6 +67,9 @@ public: /// Returns the resolution scale factor relative to the native 3DS screen resolution u32 GetResolutionScaleFactor(); + /// Returns the MSAA sample count + u8 GetSampleCount() const; + /// Updates the framebuffer layout of the contained render window handle. void UpdateCurrentFramebufferLayout(bool is_portrait_mode = {});