From 9966e20bc9f549848c6e231710d43152f0fbc5b9 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sat, 8 Feb 2020 23:43:52 +0800 Subject: [PATCH] Add option stretch to full screen --- src/common/assert.h | 23 ++++++++----------- src/core/frontend/framebuffer_layout.cpp | 7 ++++-- src/core/settings.cpp | 1 + src/core/settings.h | 1 + src/core/telemetry_session.cpp | 1 + src/yuzu/configuration/config.cpp | 3 +++ src/yuzu/configuration/configure_graphics.cpp | 3 +++ src/yuzu/configuration/configure_graphics.ui | 7 ++++++ src/yuzu_cmd/config.cpp | 3 ++- src/yuzu_cmd/default_ini.h | 4 ++++ 10 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/common/assert.h b/src/common/assert.h index 5b67c5c527..f9a96fff1c 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -28,22 +28,19 @@ __declspec(noinline, noreturn) } #define ASSERT(_a_) \ - do \ - if (!(_a_)) { \ - assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \ - } \ - while (0) + if (!(_a_)) { \ + LOG_CRITICAL(Debug, "Assertion Failed!"); \ + } #define ASSERT_MSG(_a_, ...) \ - do \ - if (!(_a_)) { \ - assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \ - } \ - while (0) + if (!(_a_)) { \ + LOG_CRITICAL(Debug, "Assertion Failed! " __VA_ARGS__); \ + } -#define UNREACHABLE() assert_noinline_call([] { LOG_CRITICAL(Debug, "Unreachable code!"); }) +#define UNREACHABLE() \ + { LOG_CRITICAL(Debug, "Unreachable code!"); } #define UNREACHABLE_MSG(...) \ - assert_noinline_call([&] { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); }) + { LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); } #ifdef _DEBUG #define DEBUG_ASSERT(_a_) ASSERT(_a_) @@ -75,4 +72,4 @@ __declspec(noinline, noreturn) if (!(_a_)) { \ _b_ \ } \ - } while (0) + } while (0) \ No newline at end of file diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index d6d2cf3f00..e19323c6ce 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -27,8 +27,11 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) { // so just calculate them both even if the other isn't showing. FramebufferLayout res{width, height}; - const float emulation_aspect_ratio{static_cast(ScreenUndocked::Height) / - ScreenUndocked::Width}; + const float emulation_aspect_ratio = + Settings::values.stretch_to_full + ? static_cast(height) / width + : static_cast(ScreenUndocked::Height) / ScreenUndocked::Width; + const auto window_aspect_ratio = static_cast(height) / width; const Common::Rectangle screen_window_area{0, 0, width, height}; diff --git a/src/core/settings.cpp b/src/core/settings.cpp index d1fc940605..74ded9b2ac 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -94,6 +94,7 @@ void LogSettings() { LogSetting("Renderer_UseAccurateGpuEmulation", Settings::values.use_accurate_gpu_emulation); LogSetting("Renderer_UseAsynchronousGpuEmulation", Settings::values.use_asynchronous_gpu_emulation); + LogSetting("Renderer_StretchToFull", Settings::values.stretch_to_full); LogSetting("Audio_OutputEngine", Settings::values.sink_id); LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching); LogSetting("Audio_OutputDevice", Settings::values.audio_device_id); diff --git a/src/core/settings.h b/src/core/settings.h index e1a9a0ffaa..2ad961bc9c 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -434,6 +434,7 @@ struct Values { bool use_disk_shader_cache; bool use_accurate_gpu_emulation; bool use_asynchronous_gpu_emulation; + bool stretch_to_full; bool force_30fps_mode; float bg_red; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 0e72d31cd6..dddf87cb89 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -188,6 +188,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) { Settings::values.use_accurate_gpu_emulation); AddField(field_type, "Renderer_UseAsynchronousGpuEmulation", Settings::values.use_asynchronous_gpu_emulation); + AddField(field_type, "Renderer_StretchToFull", Settings::values.stretch_to_full); AddField(field_type, "System_UseDockedMode", Settings::values.use_docked_mode); } diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 280d81ba96..dbd902bb63 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -639,6 +639,8 @@ void Config::ReadRendererValues() { ReadSetting(QStringLiteral("use_accurate_gpu_emulation"), false).toBool(); Settings::values.use_asynchronous_gpu_emulation = ReadSetting(QStringLiteral("use_asynchronous_gpu_emulation"), false).toBool(); + Settings::values.stretch_to_full = + ReadSetting(QStringLiteral("stretch_to_full"), false).toBool(); Settings::values.force_30fps_mode = ReadSetting(QStringLiteral("force_30fps_mode"), false).toBool(); @@ -1073,6 +1075,7 @@ void Config::SaveRendererValues() { Settings::values.use_accurate_gpu_emulation, false); WriteSetting(QStringLiteral("use_asynchronous_gpu_emulation"), Settings::values.use_asynchronous_gpu_emulation, false); + WriteSetting(QStringLiteral("stretch_to_full"), Settings::values.stretch_to_full, false); WriteSetting(QStringLiteral("force_30fps_mode"), Settings::values.force_30fps_mode, false); // Cast to double because Qt's written float values are not human-readable diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index f57a24e36d..4ffcdd66fa 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -102,6 +102,8 @@ void ConfigureGraphics::SetConfiguration() { ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation); ui->use_asynchronous_gpu_emulation->setEnabled(runtime_lock); ui->use_asynchronous_gpu_emulation->setChecked(Settings::values.use_asynchronous_gpu_emulation); + ui->stretch_to_full->setEnabled(runtime_lock); + ui->stretch_to_full->setChecked(Settings::values.stretch_to_full); ui->force_30fps_mode->setEnabled(runtime_lock); ui->force_30fps_mode->setChecked(Settings::values.force_30fps_mode); UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green, @@ -118,6 +120,7 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.use_accurate_gpu_emulation = ui->use_accurate_gpu_emulation->isChecked(); Settings::values.use_asynchronous_gpu_emulation = ui->use_asynchronous_gpu_emulation->isChecked(); + Settings::values.stretch_to_full = ui->stretch_to_full->isChecked(); Settings::values.force_30fps_mode = ui->force_30fps_mode->isChecked(); Settings::values.bg_red = static_cast(bg_color.redF()); Settings::values.bg_green = static_cast(bg_color.greenF()); diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index e24372204b..8f375648b1 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -91,6 +91,13 @@ + + + + Stretch to full screen + + + diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b01a360237..afdb3c8899 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -388,7 +388,8 @@ void Config::ReadValues() { sdl2_config->GetBoolean("Renderer", "use_accurate_gpu_emulation", false); Settings::values.use_asynchronous_gpu_emulation = sdl2_config->GetBoolean("Renderer", "use_asynchronous_gpu_emulation", false); - + Settings::values.stretch_to_full = + sdl2_config->GetBoolean("Renderer", "stretch_to_full", false); Settings::values.bg_red = static_cast(sdl2_config->GetReal("Renderer", "bg_red", 0.0)); Settings::values.bg_green = static_cast(sdl2_config->GetReal("Renderer", "bg_green", 0.0)); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 00fd88279c..74ca603d38 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -146,6 +146,10 @@ use_accurate_gpu_emulation = # 0 : Off (slow), 1 (default): On (fast) use_asynchronous_gpu_emulation = +# Whether to stretch to full screen +# 0 (default): Off, 1 : On +stretch_to_full = + # The clear color for the renderer. What shows up on the sides of the bottom screen. # Must be in range of 0.0-1.0. Defaults to 1.0 for all. bg_red =