diff options
| -rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 21 | ||||
| -rw-r--r-- | src/core/frontend/framebuffer_layout.h | 15 | ||||
| -rw-r--r-- | src/core/settings.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics.ui | 35 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu_cmd/default_ini.h | 4 | ||||
| -rw-r--r-- | src/yuzu_tester/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu_tester/default_ini.h | 4 |
10 files changed, 85 insertions, 3 deletions
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index d6d2cf3f0..2dc795d56 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp | |||
| @@ -27,9 +27,9 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { | |||
| 27 | // so just calculate them both even if the other isn't showing. | 27 | // so just calculate them both even if the other isn't showing. |
| 28 | FramebufferLayout res{width, height}; | 28 | FramebufferLayout res{width, height}; |
| 29 | 29 | ||
| 30 | const float emulation_aspect_ratio{static_cast<float>(ScreenUndocked::Height) / | 30 | const float window_aspect_ratio = static_cast<float>(height) / width; |
| 31 | ScreenUndocked::Width}; | 31 | const float emulation_aspect_ratio = EmulationAspectRatio( |
| 32 | const auto window_aspect_ratio = static_cast<float>(height) / width; | 32 | static_cast<AspectRatio>(Settings::values.aspect_ratio), window_aspect_ratio); |
| 33 | 33 | ||
| 34 | const Common::Rectangle<u32> screen_window_area{0, 0, width, height}; | 34 | const Common::Rectangle<u32> screen_window_area{0, 0, width, height}; |
| 35 | Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); | 35 | Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio); |
| @@ -58,4 +58,19 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale) { | |||
| 58 | return DefaultFrameLayout(width, height); | 58 | return DefaultFrameLayout(width, height); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio) { | ||
| 62 | switch (aspect) { | ||
| 63 | case AspectRatio::Default: | ||
| 64 | return static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width; | ||
| 65 | case AspectRatio::R4_3: | ||
| 66 | return 3.0f / 4.0f; | ||
| 67 | case AspectRatio::R21_9: | ||
| 68 | return 9.0f / 21.0f; | ||
| 69 | case AspectRatio::StretchToWindow: | ||
| 70 | return window_aspect_ratio; | ||
| 71 | default: | ||
| 72 | return static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 61 | } // namespace Layout | 76 | } // namespace Layout |
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index d2370adde..1d39c1faf 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h | |||
| @@ -18,6 +18,13 @@ enum ScreenDocked : u32 { | |||
| 18 | HeightDocked = 1080, | 18 | HeightDocked = 1080, |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | enum class AspectRatio { | ||
| 22 | Default, | ||
| 23 | R4_3, | ||
| 24 | R21_9, | ||
| 25 | StretchToWindow, | ||
| 26 | }; | ||
| 27 | |||
| 21 | /// Describes the layout of the window framebuffer | 28 | /// Describes the layout of the window framebuffer |
| 22 | struct FramebufferLayout { | 29 | struct FramebufferLayout { |
| 23 | u32 width{ScreenUndocked::Width}; | 30 | u32 width{ScreenUndocked::Width}; |
| @@ -48,4 +55,12 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height); | |||
| 48 | */ | 55 | */ |
| 49 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); | 56 | FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale); |
| 50 | 57 | ||
| 58 | /** | ||
| 59 | * Convenience method to determine emulation aspect ratio | ||
| 60 | * @param aspect Represents the index of aspect ratio stored in Settings::values.aspect_ratio | ||
| 61 | * @param window_aspect_ratio Current window aspect ratio | ||
| 62 | * @return Emulation render window aspect ratio | ||
| 63 | */ | ||
| 64 | float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio); | ||
| 65 | |||
| 51 | } // namespace Layout | 66 | } // namespace Layout |
diff --git a/src/core/settings.h b/src/core/settings.h index e1a9a0ffa..f837d3fbc 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -429,6 +429,7 @@ struct Values { | |||
| 429 | int vulkan_device; | 429 | int vulkan_device; |
| 430 | 430 | ||
| 431 | float resolution_factor; | 431 | float resolution_factor; |
| 432 | int aspect_ratio; | ||
| 432 | bool use_frame_limit; | 433 | bool use_frame_limit; |
| 433 | u16 frame_limit; | 434 | u16 frame_limit; |
| 434 | bool use_disk_shader_cache; | 435 | bool use_disk_shader_cache; |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index cd94693c1..6209fff75 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -630,6 +630,7 @@ void Config::ReadRendererValues() { | |||
| 630 | Settings::values.vulkan_device = ReadSetting(QStringLiteral("vulkan_device"), 0).toInt(); | 630 | Settings::values.vulkan_device = ReadSetting(QStringLiteral("vulkan_device"), 0).toInt(); |
| 631 | Settings::values.resolution_factor = | 631 | Settings::values.resolution_factor = |
| 632 | ReadSetting(QStringLiteral("resolution_factor"), 1.0).toFloat(); | 632 | ReadSetting(QStringLiteral("resolution_factor"), 1.0).toFloat(); |
| 633 | Settings::values.aspect_ratio = ReadSetting(QStringLiteral("aspect_ratio"), 0).toInt(); | ||
| 633 | Settings::values.use_frame_limit = | 634 | Settings::values.use_frame_limit = |
| 634 | ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); | 635 | ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); |
| 635 | Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); | 636 | Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); |
| @@ -1064,6 +1065,7 @@ void Config::SaveRendererValues() { | |||
| 1064 | WriteSetting(QStringLiteral("vulkan_device"), Settings::values.vulkan_device, 0); | 1065 | WriteSetting(QStringLiteral("vulkan_device"), Settings::values.vulkan_device, 0); |
| 1065 | WriteSetting(QStringLiteral("resolution_factor"), | 1066 | WriteSetting(QStringLiteral("resolution_factor"), |
| 1066 | static_cast<double>(Settings::values.resolution_factor), 1.0); | 1067 | static_cast<double>(Settings::values.resolution_factor), 1.0); |
| 1068 | WriteSetting(QStringLiteral("aspect_ratio"), Settings::values.aspect_ratio, 0); | ||
| 1067 | WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); | 1069 | WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); |
| 1068 | WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); | 1070 | WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); |
| 1069 | WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache, | 1071 | WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache, |
diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index f57a24e36..ea899c080 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp | |||
| @@ -97,6 +97,7 @@ void ConfigureGraphics::SetConfiguration() { | |||
| 97 | ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend)); | 97 | ui->api->setCurrentIndex(static_cast<int>(Settings::values.renderer_backend)); |
| 98 | ui->resolution_factor_combobox->setCurrentIndex( | 98 | ui->resolution_factor_combobox->setCurrentIndex( |
| 99 | static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor))); | 99 | static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor))); |
| 100 | ui->aspect_ratio_combobox->setCurrentIndex(Settings::values.aspect_ratio); | ||
| 100 | ui->use_disk_shader_cache->setEnabled(runtime_lock); | 101 | ui->use_disk_shader_cache->setEnabled(runtime_lock); |
| 101 | ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache); | 102 | ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache); |
| 102 | ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation); | 103 | ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation); |
| @@ -114,6 +115,7 @@ void ConfigureGraphics::ApplyConfiguration() { | |||
| 114 | Settings::values.vulkan_device = vulkan_device; | 115 | Settings::values.vulkan_device = vulkan_device; |
| 115 | Settings::values.resolution_factor = | 116 | Settings::values.resolution_factor = |
| 116 | ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex())); | 117 | ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex())); |
| 118 | Settings::values.aspect_ratio = ui->aspect_ratio_combobox->currentIndex(); | ||
| 117 | Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked(); | 119 | Settings::values.use_disk_shader_cache = ui->use_disk_shader_cache->isChecked(); |
| 118 | Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked(); | 120 | Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked(); |
| 119 | Settings::values.use_asynchronous_gpu_emulation = | 121 | Settings::values.use_asynchronous_gpu_emulation = |
diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index e24372204..db60426ab 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui | |||
| @@ -139,6 +139,41 @@ | |||
| 139 | </layout> | 139 | </layout> |
| 140 | </item> | 140 | </item> |
| 141 | <item> | 141 | <item> |
| 142 | <layout class="QHBoxLayout" name="horizontalLayout_6"> | ||
| 143 | <item> | ||
| 144 | <widget class="QLabel" name="ar_label"> | ||
| 145 | <property name="text"> | ||
| 146 | <string>Aspect Ratio:</string> | ||
| 147 | </property> | ||
| 148 | </widget> | ||
| 149 | </item> | ||
| 150 | <item> | ||
| 151 | <widget class="QComboBox" name="aspect_ratio_combobox"> | ||
| 152 | <item> | ||
| 153 | <property name="text"> | ||
| 154 | <string>Default (16:9)</string> | ||
| 155 | </property> | ||
| 156 | </item> | ||
| 157 | <item> | ||
| 158 | <property name="text"> | ||
| 159 | <string>Force 4:3</string> | ||
| 160 | </property> | ||
| 161 | </item> | ||
| 162 | <item> | ||
| 163 | <property name="text"> | ||
| 164 | <string>Force 21:9</string> | ||
| 165 | </property> | ||
| 166 | </item> | ||
| 167 | <item> | ||
| 168 | <property name="text"> | ||
| 169 | <string>Stretch to Window</string> | ||
| 170 | </property> | ||
| 171 | </item> | ||
| 172 | </widget> | ||
| 173 | </item> | ||
| 174 | </layout> | ||
| 175 | </item> | ||
| 176 | <item> | ||
| 142 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | 177 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
| 143 | <item> | 178 | <item> |
| 144 | <widget class="QLabel" name="bg_label"> | 179 | <widget class="QLabel" name="bg_label"> |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b01a36023..96f1ce3af 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -379,6 +379,8 @@ void Config::ReadValues() { | |||
| 379 | 379 | ||
| 380 | Settings::values.resolution_factor = | 380 | Settings::values.resolution_factor = |
| 381 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); | 381 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); |
| 382 | Settings::values.aspect_ratio = | ||
| 383 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); | ||
| 382 | Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); | 384 | Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); |
| 383 | Settings::values.frame_limit = | 385 | Settings::values.frame_limit = |
| 384 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); | 386 | static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 00fd88279..8a2b658cd 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -122,6 +122,10 @@ use_shader_jit = | |||
| 122 | # factor for the Switch resolution | 122 | # factor for the Switch resolution |
| 123 | resolution_factor = | 123 | resolution_factor = |
| 124 | 124 | ||
| 125 | # Aspect ratio | ||
| 126 | # 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window | ||
| 127 | aspect_ratio = | ||
| 128 | |||
| 125 | # Whether to enable V-Sync (caps the framerate at 60FPS) or not. | 129 | # Whether to enable V-Sync (caps the framerate at 60FPS) or not. |
| 126 | # 0 (default): Off, 1: On | 130 | # 0 (default): Off, 1: On |
| 127 | use_vsync = | 131 | use_vsync = |
diff --git a/src/yuzu_tester/config.cpp b/src/yuzu_tester/config.cpp index 84ab4d687..0ac93b62a 100644 --- a/src/yuzu_tester/config.cpp +++ b/src/yuzu_tester/config.cpp | |||
| @@ -118,6 +118,8 @@ void Config::ReadValues() { | |||
| 118 | // Renderer | 118 | // Renderer |
| 119 | Settings::values.resolution_factor = | 119 | Settings::values.resolution_factor = |
| 120 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); | 120 | static_cast<float>(sdl2_config->GetReal("Renderer", "resolution_factor", 1.0)); |
| 121 | Settings::values.aspect_ratio = | ||
| 122 | static_cast<int>(sdl2_config->GetInteger("Renderer", "aspect_ratio", 0)); | ||
| 121 | Settings::values.use_frame_limit = false; | 123 | Settings::values.use_frame_limit = false; |
| 122 | Settings::values.frame_limit = 100; | 124 | Settings::values.frame_limit = 100; |
| 123 | Settings::values.use_disk_shader_cache = | 125 | Settings::values.use_disk_shader_cache = |
diff --git a/src/yuzu_tester/default_ini.h b/src/yuzu_tester/default_ini.h index 9a3e86d68..8d93f7b88 100644 --- a/src/yuzu_tester/default_ini.h +++ b/src/yuzu_tester/default_ini.h | |||
| @@ -26,6 +26,10 @@ use_shader_jit = | |||
| 26 | # factor for the Switch resolution | 26 | # factor for the Switch resolution |
| 27 | resolution_factor = | 27 | resolution_factor = |
| 28 | 28 | ||
| 29 | # Aspect ratio | ||
| 30 | # 0: Default (16:9), 1: Force 4:3, 2: Force 21:9, 3: Stretch to Window | ||
| 31 | aspect_ratio = | ||
| 32 | |||
| 29 | # Whether to enable V-Sync (caps the framerate at 60FPS) or not. | 33 | # Whether to enable V-Sync (caps the framerate at 60FPS) or not. |
| 30 | # 0 (default): Off, 1: On | 34 | # 0 (default): Off, 1: On |
| 31 | use_vsync = | 35 | use_vsync = |