From e2044eba6639930c44b2e423dcecab3731528c6e Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Mon, 11 Apr 2022 14:00:18 +0100 Subject: [PATCH] GS/Window: Add Automatic 4:3/3:2 mode, keep 4:3 separate --- pcsx2-qt/Settings/GraphicsSettingsWidget.cpp | 2 +- pcsx2-qt/Settings/GraphicsSettingsWidget.ui | 12 ++++++++- pcsx2/Config.h | 6 +++-- pcsx2/Counters.cpp | 3 +++ pcsx2/GS/GS.cpp | 7 ++++++ pcsx2/GS/GS.h | 1 + pcsx2/GS/Renderers/Common/GSRenderer.cpp | 12 ++++++--- pcsx2/Pcsx2Config.cpp | 6 +++-- pcsx2/VMManager.cpp | 26 ++++++++++++-------- pcsx2/gui/AppConfig.cpp | 6 +++-- pcsx2/gui/GlobalCommands.cpp | 4 +++ pcsx2/gui/Panels/GSWindowPanel.cpp | 9 ++++--- 12 files changed, 69 insertions(+), 25 deletions(-) diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp index c31dad2d89..43e9918e4b 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp @@ -89,7 +89,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsDialog* dialog, QWidget* // Game Display Settings ////////////////////////////////////////////////////////////////////////// SettingWidgetBinder::BindWidgetToEnumSetting( - sif, m_ui.aspectRatio, "EmuCore/GS", "AspectRatio", Pcsx2Config::GSOptions::AspectRatioNames, AspectRatioType::R4_3); + sif, m_ui.aspectRatio, "EmuCore/GS", "AspectRatio", Pcsx2Config::GSOptions::AspectRatioNames, AspectRatioType::RAuto4_3_3_2); SettingWidgetBinder::BindWidgetToEnumSetting(sif, m_ui.fmvAspectRatio, "EmuCore/GS", "FMVAspectRatioSwitch", Pcsx2Config::GSOptions::FMVAspectRatioSwitchNames, FMVAspectRatioSwitchType::Off); SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.interlacing, "EmuCore/GS", "deinterlace", DEFAULT_INTERLACE_MODE); diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui index 7fa1c8b610..5aee794559 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui @@ -94,7 +94,12 @@ - Standard (4:3/3:2 Progressive) + Auto Standard (4:3/3:2 Progressive) + + + + + Standard (4:3) @@ -117,6 +122,11 @@ Off (Default) + + + + Auto Standard (4:3/3:2 Progressive) + diff --git a/pcsx2/Config.h b/pcsx2/Config.h index fb27ceb360..cbb7658c51 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -73,6 +73,7 @@ enum class VsyncMode enum class AspectRatioType : u8 { Stretch, + RAuto4_3_3_2, R4_3, R16_9, MaxCount @@ -81,6 +82,7 @@ enum class AspectRatioType : u8 enum class FMVAspectRatioSwitchType : u8 { Off, + RAuto4_3_3_2, R4_3, R16_9, MaxCount @@ -495,7 +497,7 @@ struct Pcsx2Config double FramerateNTSC{59.94}; double FrameratePAL{50.00}; - AspectRatioType AspectRatio{AspectRatioType::R4_3}; + AspectRatioType AspectRatio{AspectRatioType::RAuto4_3_3_2}; FMVAspectRatioSwitchType FMVAspectRatioSwitch{FMVAspectRatioSwitchType::Off}; GSInterlaceMode InterlaceMode{GSInterlaceMode::Automatic}; @@ -983,7 +985,7 @@ struct Pcsx2Config std::string CurrentBlockdump; std::string CurrentIRX; std::string CurrentGameArgs; - AspectRatioType CurrentAspectRatio = AspectRatioType::R4_3; + AspectRatioType CurrentAspectRatio = AspectRatioType::RAuto4_3_3_2; LimiterModeType LimiterMode = LimiterModeType::Nominal; Pcsx2Config(); diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index 366166e05a..673b310f1f 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -464,6 +464,9 @@ static __fi void DoFMVSwitch() { case FMVAspectRatioSwitchType::Off: break; + case FMVAspectRatioSwitchType::RAuto4_3_3_2: + EmuConfig.CurrentAspectRatio = new_fmv_state ? AspectRatioType::RAuto4_3_3_2 : EmuConfig.GS.AspectRatio; + break; case FMVAspectRatioSwitchType::R4_3: EmuConfig.CurrentAspectRatio = new_fmv_state ? AspectRatioType::R4_3 : EmuConfig.GS.AspectRatio; break; diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 89567aec87..15e3aca9a4 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -671,6 +671,13 @@ void GSsetFrameSkip(int frameskip) s_gs->SetFrameSkip(frameskip); } +GSVideoMode GSgetDisplayMode() +{ + GSRenderer* gs = s_gs.get(); + + return gs->GetVideoMode(); +} + void GSgetInternalResolution(int* width, int* height) { GSRenderer* gs = s_gs.get(); diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index f4d01d1afa..94864e1220 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -81,6 +81,7 @@ void GSendRecording(); void GSsetGameCRC(u32 crc, int options); void GSsetFrameSkip(int frameskip); +GSVideoMode GSgetDisplayMode(); void GSgetInternalResolution(int* width, int* height); void GSgetStats(std::string& info); void GSgetTitleStats(std::string& info); diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.cpp b/pcsx2/GS/Renderers/Common/GSRenderer.cpp index 22f0a915a7..efb85a7790 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.cpp +++ b/pcsx2/GS/Renderers/Common/GSRenderer.cpp @@ -367,7 +367,7 @@ bool GSRenderer::Merge(int field) } if (tex[0] || tex[1]) { - if (tex[0] == tex[1] && !slbg && (src[0] == src[1] & dst[0] == dst[1]).alltrue() && !feedback_merge) + if ((tex[0] == tex[1]) && (src[0] == src[1]).alltrue() && (dst[0] == dst[1]).alltrue() && !feedback_merge && !slbg) { // the two outputs are identical, skip drawing one of them (the one that is alpha blended) @@ -424,8 +424,8 @@ GSVector2i GSRenderer::GetInternalResolution() static float GetCurrentAspectRatioFloat(bool is_progressive) { - static constexpr std::array(AspectRatioType::MaxCount) + 1> ars = { {4.0f / 3.0f, 4.0f / 3.0f, 16.0f / 9.0f, 3.0f / 2.0f} }; - return ars[static_cast(GSConfig.AspectRatio) + (3u * is_progressive)]; + static constexpr std::array(AspectRatioType::MaxCount) + 1> ars = { {4.0f / 3.0f, 4.0f / 3.0f, 4.0f / 3.0f, 16.0f / 9.0f, 3.0f / 2.0f} }; + return ars[static_cast(GSConfig.AspectRatio) + (3u * (is_progressive && GSConfig.AspectRatio == AspectRatioType::RAuto4_3_3_2))]; } static GSVector4 CalculateDrawRect(s32 window_width, s32 window_height, s32 texture_width, s32 texture_height, HostDisplay::Alignment alignment, bool flip_y, bool is_progressive) @@ -435,13 +435,17 @@ static GSVector4 CalculateDrawRect(s32 window_width, s32 window_height, s32 text const float clientAr = f_width / f_height; float targetAr = clientAr; - if (EmuConfig.CurrentAspectRatio == AspectRatioType::R4_3) + if (EmuConfig.CurrentAspectRatio == AspectRatioType::RAuto4_3_3_2) { if (is_progressive) targetAr = 3.0f / 2.0f; else targetAr = 4.0f / 3.0f; } + else if (EmuConfig.CurrentAspectRatio == AspectRatioType::R4_3) + { + targetAr = 4.0f / 3.0f; + } else if (EmuConfig.CurrentAspectRatio == AspectRatioType::R16_9) targetAr = 16.0f / 9.0f; diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index c8ace8b9cb..09b22615c2 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -263,13 +263,15 @@ void Pcsx2Config::CpuOptions::LoadSave(SettingsWrapper& wrap) const char* Pcsx2Config::GSOptions::AspectRatioNames[] = { "Stretch", - "4:3/3:2 (Progressive)", + "Auto 4:3/3:2", + "4:3", "16:9", nullptr}; const char* Pcsx2Config::GSOptions::FMVAspectRatioSwitchNames[] = { "Off", - "4:3/3:2 (Progressive)", + "Auto 4:3/3:2", + "4:3", "16:9", nullptr}; diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index a3d5f7c9fd..2b45a8fd99 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -270,16 +270,22 @@ void VMManager::RequestDisplaySize(float scale /*= 0.0f*/) float x_scale; switch (GSConfig.AspectRatio) { - case AspectRatioType::R4_3: - x_scale = (4.0f / 3.0f) / (static_cast(iwidth) / static_cast(iheight)); - break; - case AspectRatioType::R16_9: - x_scale = (16.0f / 9.0f) / (static_cast(iwidth) / static_cast(iheight)); - break; - case AspectRatioType::Stretch: - default: - x_scale = 1.0f; - break; + case AspectRatioType::RAuto4_3_3_2: + if (GSgetDisplayMode() == GSVideoMode::SDTV_480P) + x_scale = (3.0f / 2.0f) / (static_cast(iwidth) / static_cast(iheight)); + else + x_scale = (4.0f / 3.0f) / (static_cast(iwidth) / static_cast(iheight)); + break; + case AspectRatioType::R4_3: + x_scale = (4.0f / 3.0f) / (static_cast(iwidth) / static_cast(iheight)); + break; + case AspectRatioType::R16_9: + x_scale = (16.0f / 9.0f) / (static_cast(iwidth) / static_cast(iheight)); + break; + case AspectRatioType::Stretch: + default: + x_scale = 1.0f; + break; } float width = static_cast(iwidth) * x_scale; diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 9a14c779e0..8afdb51740 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -874,7 +874,8 @@ void AppConfig::GSWindowOptions::LoadSave(IniInterface& ini) static const wxChar* AspectRatioNames[] = { L"Stretch", - L"4:3/3:2 (Progressive)", + L"Auto 4:3/3:2 (Progressive)", + L"4:3", L"16:9", // WARNING: array must be NULL terminated to compute it size NULL}; @@ -886,7 +887,8 @@ void AppConfig::GSWindowOptions::LoadSave(IniInterface& ini) static const wxChar* FMVAspectRatioSwitchNames[] = { L"Off", - L"4:3/3:2 (Progressive)", + L"Auto 4:3/3:2 (Progressive)", + L"4:3", L"16:9", // WARNING: array must be NULL terminated to compute it size NULL}; diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index 2fd7e6d7e9..7804f235f4 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -172,6 +172,10 @@ namespace Implementations switch (art) { case AspectRatioType::Stretch: + art = AspectRatioType::RAuto4_3_3_2; + arts = "Auto 4:3/3:2"; + break; + case AspectRatioType::RAuto4_3_3_2: art = AspectRatioType::R4_3; arts = "4:3"; break; diff --git a/pcsx2/gui/Panels/GSWindowPanel.cpp b/pcsx2/gui/Panels/GSWindowPanel.cpp index 4b2943cfd9..0929447ef4 100644 --- a/pcsx2/gui/Panels/GSWindowPanel.cpp +++ b/pcsx2/gui/Panels/GSWindowPanel.cpp @@ -32,13 +32,15 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel(wxWindow* parent) const wxString aspect_ratio_labels[] = { _("Fit to Window/Screen"), - _("Standard (4:3/3:2 Progressive)"), + _("Auto Standard (4:3/3:2 Progressive)"), + _("Standard (4:3)"), _("Widescreen (16:9)")}; const wxString fmv_aspect_ratio_switch_labels[] = { _("Off (Default)"), - _("Standard (4:3/3:2 Progressive)"), + _("Auto Standard (4:3/3:2 Progressive)"), + _("Standard (4:3)"), _("Widescreen (16:9)")}; // Warning must match the order of the VsyncMode Enum @@ -74,7 +76,8 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel(wxWindow* parent) m_check_DclickFullscreen = new pxCheckBox(this, _("Double-click toggles fullscreen mode")); m_combo_FMVAspectRatioSwitch->SetToolTip(pxEt(L"Off: Disables temporary aspect ratio switch. (It will use the above setting from Aspect Ratio instead of FMV Aspect Ratio Override.)\n\n" - L"4:3: Temporarily switch to a 4:3 aspect ratio while an FMV plays to correctly display an 4:3 FMV. Will use 3:2 is the resolution is 480P\n\n" + L"Auto 4:3/3:2: Temporarily switch to a 4:3 aspect ratio while an FMV plays to correctly display a 4:3 FMV. Will use 3:2 is the resolution is 480P\n\n" + L"4:3: Temporarily switch to a 4:3 aspect ratio while an FMV plays to correctly display a 4:3 FMV. \n\n" L"16:9: Temporarily switch to a 16:9 aspect ratio while an FMV plays to correctly display a widescreen 16:9 FMV.")); m_text_Zoom->SetToolTip(pxEt(L"Zoom = 100: Fit the entire image to the window without any cropping.\n"