From f6ab317374e597e8e6d60e4d5cf5ce5518f5e7e5 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 26 Jan 2022 15:48:12 -0800 Subject: [PATCH 1/3] Fix typo (GFX_HACK_VERTEX_ROUDING -> GFX_HACK_VERTEX_ROUNDING) --- .../dolphinemu/features/settings/model/BooleanSetting.java | 2 +- .../features/settings/ui/SettingsFragmentPresenter.java | 2 +- Source/Core/Core/Config/GraphicsSettings.cpp | 2 +- Source/Core/Core/Config/GraphicsSettings.h | 2 +- Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp | 2 +- Source/Core/Core/NetPlayServer.cpp | 2 +- Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp | 2 +- Source/Core/VideoCommon/VideoConfig.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java index 83fccc95d1..b6e63895a3 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/BooleanSetting.java @@ -227,7 +227,7 @@ public enum BooleanSetting implements AbstractBooleanSetting GFX_HACK_COPY_EFB_SCALED(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBScaledCopy", true), GFX_HACK_EFB_EMULATE_FORMAT_CHANGES(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "EFBEmulateFormatChanges", false), - GFX_HACK_VERTEX_ROUDING(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "VertexRounding", false), + GFX_HACK_VERTEX_ROUNDING(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "VertexRounding", false), GFX_HACK_FAST_TEXTURE_SAMPLING(Settings.FILE_GFX, Settings.SECTION_GFX_HACKS, "FastTextureSampling", true), diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java index 6991891bcd..61f3098f0a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java @@ -696,7 +696,7 @@ public final class SettingsFragmentPresenter R.string.fast_depth_calculation, R.string.fast_depth_calculation_description)); sl.add(new InvertedCheckBoxSetting(mContext, BooleanSetting.GFX_HACK_BBOX_ENABLE, R.string.disable_bbox, R.string.disable_bbox_description)); - sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_HACK_VERTEX_ROUDING, + sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_HACK_VERTEX_ROUNDING, R.string.vertex_rounding, R.string.vertex_rounding_description)); sl.add(new CheckBoxSetting(mContext, BooleanSetting.GFX_SAVE_TEXTURE_CACHE_TO_STATE, R.string.texture_cache_to_state, R.string.texture_cache_to_state_description)); diff --git a/Source/Core/Core/Config/GraphicsSettings.cpp b/Source/Core/Core/Config/GraphicsSettings.cpp index 1015bd47aa..18a9e693ff 100644 --- a/Source/Core/Core/Config/GraphicsSettings.cpp +++ b/Source/Core/Core/Config/GraphicsSettings.cpp @@ -148,7 +148,7 @@ const Info GFX_HACK_EARLY_XFB_OUTPUT{{System::GFX, "Hacks", "EarlyXFBOutpu const Info GFX_HACK_COPY_EFB_SCALED{{System::GFX, "Hacks", "EFBScaledCopy"}, true}; const Info GFX_HACK_EFB_EMULATE_FORMAT_CHANGES{ {System::GFX, "Hacks", "EFBEmulateFormatChanges"}, false}; -const Info GFX_HACK_VERTEX_ROUDING{{System::GFX, "Hacks", "VertexRounding"}, false}; +const Info GFX_HACK_VERTEX_ROUNDING{{System::GFX, "Hacks", "VertexRounding"}, false}; const Info GFX_HACK_MISSING_COLOR_VALUE{{System::GFX, "Hacks", "MissingColorValue"}, 0xFFFFFFFF}; const Info GFX_HACK_FAST_TEXTURE_SAMPLING{{System::GFX, "Hacks", "FastTextureSampling"}, diff --git a/Source/Core/Core/Config/GraphicsSettings.h b/Source/Core/Core/Config/GraphicsSettings.h index e5289a36de..710b6ca220 100644 --- a/Source/Core/Core/Config/GraphicsSettings.h +++ b/Source/Core/Core/Config/GraphicsSettings.h @@ -122,7 +122,7 @@ extern const Info GFX_HACK_SKIP_DUPLICATE_XFBS; extern const Info GFX_HACK_EARLY_XFB_OUTPUT; extern const Info GFX_HACK_COPY_EFB_SCALED; extern const Info GFX_HACK_EFB_EMULATE_FORMAT_CHANGES; -extern const Info GFX_HACK_VERTEX_ROUDING; +extern const Info GFX_HACK_VERTEX_ROUNDING; extern const Info GFX_HACK_MISSING_COLOR_VALUE; extern const Info GFX_HACK_FAST_TEXTURE_SAMPLING; diff --git a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp index b4a41baab9..f52a828719 100644 --- a/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp @@ -98,7 +98,7 @@ public: if (m_settings.m_StrictSettingsSync) { - layer->Set(Config::GFX_HACK_VERTEX_ROUDING, m_settings.m_VertexRounding); + layer->Set(Config::GFX_HACK_VERTEX_ROUNDING, m_settings.m_VertexRounding); layer->Set(Config::GFX_EFB_SCALE, m_settings.m_InternalResolution); layer->Set(Config::GFX_HACK_COPY_EFB_SCALED, m_settings.m_EFBScaledCopy); layer->Set(Config::GFX_FAST_DEPTH_CALC, m_settings.m_FastDepthCalc); diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index a8b5a77032..30a0311910 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -1363,7 +1363,7 @@ bool NetPlayServer::SetupNetSettings() settings.m_Fastmem = Config::Get(Config::MAIN_FASTMEM); settings.m_SkipIPL = Config::Get(Config::MAIN_SKIP_IPL) || !DoAllPlayersHaveIPLDump(); settings.m_LoadIPLDump = Config::Get(Config::SESSION_LOAD_IPL_DUMP) && DoAllPlayersHaveIPLDump(); - settings.m_VertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUDING); + settings.m_VertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUNDING); settings.m_InternalResolution = Config::Get(Config::GFX_EFB_SCALE); settings.m_EFBScaledCopy = Config::Get(Config::GFX_HACK_COPY_EFB_SCALED); settings.m_FastDepthCalc = Config::Get(Config::GFX_FAST_DEPTH_CALC); diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp index 12ca003eac..b7da070edb 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp @@ -103,7 +103,7 @@ void HacksWidget::CreateWidgets() new GraphicsBool(tr("Fast Depth Calculation"), Config::GFX_FAST_DEPTH_CALC); m_disable_bounding_box = new GraphicsBool(tr("Disable Bounding Box"), Config::GFX_HACK_BBOX_ENABLE, true); - m_vertex_rounding = new GraphicsBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUDING); + m_vertex_rounding = new GraphicsBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUNDING); m_save_texture_cache_state = new GraphicsBool(tr("Save Texture Cache to State"), Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE); diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index a4aa9bda55..861cd7281c 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -134,7 +134,7 @@ void VideoConfig::Refresh() bSkipPresentingDuplicateXFBs = Config::Get(Config::GFX_HACK_SKIP_DUPLICATE_XFBS); bCopyEFBScaled = Config::Get(Config::GFX_HACK_COPY_EFB_SCALED); bEFBEmulateFormatChanges = Config::Get(Config::GFX_HACK_EFB_EMULATE_FORMAT_CHANGES); - bVertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUDING); + bVertexRounding = Config::Get(Config::GFX_HACK_VERTEX_ROUNDING); iEFBAccessTileSize = Config::Get(Config::GFX_HACK_EFB_ACCESS_TILE_SIZE); iMissingColorValue = Config::Get(Config::GFX_HACK_MISSING_COLOR_VALUE); bFastTextureSampling = Config::Get(Config::GFX_HACK_FAST_TEXTURE_SAMPLING); From dbb857b175c6687740b337147ce9f4d0e3fc52aa Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 26 Jan 2022 19:11:11 -0800 Subject: [PATCH 2/3] VertexShaderManager: Use g_ActiveConfig.UseVertexRounding() --- Source/Core/VideoCommon/VertexShaderManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 25c7f79b30..23e94776be 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -303,7 +303,7 @@ void VertexShaderManager::SetConstants() // NOTE: If we ever emulate antialiasing, the sample locations set by // BP registers 0x01-0x04 need to be considered here. const float pixel_center_correction = 7.0f / 12.0f - 0.5f; - const bool bUseVertexRounding = g_ActiveConfig.bVertexRounding && g_ActiveConfig.iEFBScale != 1; + const bool bUseVertexRounding = g_ActiveConfig.UseVertexRounding(); const float viewport_width = bUseVertexRounding ? (2.f * xfmem.viewport.wd) : g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd); From 4e9a3147763ce742718092cf0d05ed7d9a6b19ad Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 26 Jan 2022 12:09:00 -0800 Subject: [PATCH 3/3] Round viewport coordinates when vertex rounding is enabled This should fix https://bugs.dolphin-emu.org/issues/9105 --- .../app/src/main/res/values/strings.xml | 2 +- .../DolphinQt/Config/Graphics/HacksWidget.cpp | 8 +++--- Source/Core/VideoCommon/BPFunctions.cpp | 26 ++++++++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 6561b3389c..765310156f 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -287,7 +287,7 @@ Disable Bounding Box Disables bounding box emulation. This may improve GPU performance significantly, but some games will break. If unsure, leave this checked. Vertex Rounding - Rounds 2D vertices to whole pixels. Fixes graphical problems in some games at higher internal resolutions. This setting has no effect when native internal resolution is used. If unsure, leave this unchecked. + Rounds 2D vertices to whole pixels and rounds the viewport size to a whole number. Fixes graphical problems in some games at higher internal resolutions. This setting has no effect when native internal resolution is used. If unsure, leave this unchecked. Save Texture Cache to State Includes the contents of the embedded frame buffer (EFB) and upscaled EFB copies in save states. Fixes missing and/or non-upscaled textures/objects when loading states at the cost of additional save/load time. Aspect Ratio diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp index b7da070edb..9d7380f8cc 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp @@ -275,10 +275,10 @@ void HacksWidget::AddDescriptions() "states at the cost of additional save/load time.

If " "unsure, leave this checked."); static const char TR_VERTEX_ROUNDING_DESCRIPTION[] = QT_TR_NOOP( - "Rounds 2D vertices to whole pixels.

Fixes graphical problems in some games at " - "higher internal resolutions. This setting has no effect when native internal " - "resolution is used.

If unsure, leave this " - "unchecked."); + "Rounds 2D vertices to whole pixels and rounds the viewport size to a whole number.

" + "Fixes graphical problems in some games at higher internal resolutions. This setting has no " + "effect when native internal resolution is used.

" + "If unsure, leave this unchecked."); m_skip_efb_cpu->SetDescription(tr(TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION)); m_ignore_format_changes->SetDescription(tr(TR_IGNORE_FORMAT_CHANGE_DESCRIPTION)); diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp index ba2bf6e0d3..fe3867c29c 100644 --- a/Source/Core/VideoCommon/BPFunctions.cpp +++ b/Source/Core/VideoCommon/BPFunctions.cpp @@ -4,6 +4,7 @@ #include "VideoCommon/BPFunctions.h" #include +#include #include #include "Common/CommonTypes.h" @@ -74,13 +75,26 @@ void SetScissor() void SetViewport() { - s32 xoff = bpmem.scissorOffset.x * 2; - s32 yoff = bpmem.scissorOffset.y * 2; - float x = g_renderer->EFBToScaledXf(xfmem.viewport.xOrig - xfmem.viewport.wd - xoff); - float y = g_renderer->EFBToScaledYf(xfmem.viewport.yOrig + xfmem.viewport.ht - yoff); + const s32 xoff = bpmem.scissorOffset.x * 2; + const s32 yoff = bpmem.scissorOffset.y * 2; + float raw_x = xfmem.viewport.xOrig - xfmem.viewport.wd - xoff; + float raw_y = xfmem.viewport.yOrig + xfmem.viewport.ht - yoff; + float raw_width = 2.0f * xfmem.viewport.wd; + float raw_height = -2.0f * xfmem.viewport.ht; + if (g_ActiveConfig.UseVertexRounding()) + { + // Round the viewport to match full 1x IR pixels as well. + // This eliminates a line in the archery mode in Wii Sports Resort at 3x IR and higher. + raw_x = std::round(raw_x); + raw_y = std::round(raw_y); + raw_width = std::round(raw_width); + raw_height = std::round(raw_height); + } - float width = g_renderer->EFBToScaledXf(2.0f * xfmem.viewport.wd); - float height = g_renderer->EFBToScaledYf(-2.0f * xfmem.viewport.ht); + float x = g_renderer->EFBToScaledXf(raw_x); + float y = g_renderer->EFBToScaledYf(raw_y); + float width = g_renderer->EFBToScaledXf(raw_width); + float height = g_renderer->EFBToScaledYf(raw_height); float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f; float max_depth = xfmem.viewport.farZ / 16777216.0f; if (width < 0.f)