Skip to content

Commit

Permalink
UI: Add new UI upscaling fix for Native Scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
refractionpcsx2 committed Jun 6, 2024
1 parent 8ea9f0c commit c7bf8b3
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 8 deletions.
6 changes: 6 additions & 0 deletions bin/resources/GameIndex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,7 @@ SCAJ-20161:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
SCAJ-20162:
name: "Rogue Galaxy"
region: "NTSC-Unk"
Expand Down Expand Up @@ -1907,6 +1908,7 @@ SCAJ-20167:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
SCAJ-20168:
name: "Rule of Rose"
region: "NTSC-Unk"
Expand Down Expand Up @@ -5523,6 +5525,7 @@ SCES-53851:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
patches:
default:
content: |-
Expand Down Expand Up @@ -6823,6 +6826,7 @@ SCKA-20069:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
SCKA-20070:
name: "Ace Combat Zero - The Belkan War"
region: "NTSC-K"
Expand Down Expand Up @@ -8336,6 +8340,7 @@ SCPS-15106:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
patches:
626552EB:
content: |-
Expand Down Expand Up @@ -9035,6 +9040,7 @@ SCPS-19326:
gsHWFixes:
mergeSprite: 1 # Fixes vertical lines in-game.
preloadFrameData: 1 # Fixes some missing effects.
nativeScaling: 2 # Fixes post processing.
SCPS-19327:
name: サルゲッチュ3 PlayStation 2 the Best
name-sort: さるげっちゅ3 PlayStation 2 the Best
Expand Down
2 changes: 2 additions & 0 deletions pcsx2-qt/Settings/GraphicsSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
// HW Upscaling Fixes
//////////////////////////////////////////////////////////////////////////
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.halfPixelOffset, "EmuCore/GS", "UserHacks_HalfPixelOffset", 0);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.nativeScaling, "EmuCore/GS", "UserHacks_native_scaling", 0);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.roundSprite, "EmuCore/GS", "UserHacks_round_sprite_offset", 0);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.bilinearHack, "EmuCore/GS", "UserHacks_BilinearHack", 0);
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.textureOffsetX, "EmuCore/GS", "UserHacks_TCOffsetX", 0);
Expand Down Expand Up @@ -1116,6 +1117,7 @@ void GraphicsSettingsWidget::resetManualHardwareFixes()
check_bool("EmuCore/GS", "UserHacks_EstimateTextureRegion", false);
check_bool("EmuCore/GS", "paltex", false);
check_int("EmuCore/GS", "UserHacks_HalfPixelOffset", 0);
check_int("EmuCore/GS", "UserHacks_native_scaling", static_cast<int>(GSNativeScaling::Normal));
check_int("EmuCore/GS", "UserHacks_round_sprite_offset", 0);
check_int("EmuCore/GS", "UserHacks_TCOffsetX", 0);
check_int("EmuCore/GS", "UserHacks_TCOffsetY", 0);
Expand Down
40 changes: 33 additions & 7 deletions pcsx2-qt/Settings/GraphicsSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1090,14 +1090,14 @@
</item>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Round Sprite:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="roundSprite">
<item>
<property name="text">
Expand All @@ -1116,14 +1116,14 @@
</item>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="textureOffsetLabel">
<property name="text">
<string>Texture Offsets:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<layout class="QHBoxLayout" name="textureOffsetLayout" stretch="0,1,0,1">
<item>
<widget class="QLabel" name="textureOffsetXLabel">
Expand Down Expand Up @@ -1155,7 +1155,7 @@
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="alignSprite">
Expand Down Expand Up @@ -1187,14 +1187,14 @@
</item>
</layout>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Bilinear Dirty Upscale:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="bilinearHack">
<item>
<property name="text">
Expand All @@ -1213,6 +1213,32 @@
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="nativeScaling">
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Aggressive</string>
</property>
</item>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Native Scaling</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
Expand Down
9 changes: 9 additions & 0 deletions pcsx2/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ enum class GSHalfPixelOffset : u8
MaxCount
};

enum class GSNativeScaling : u8
{
Normal,
Aggressive,
Off,
MaxCount
};

// --------------------------------------------------------------------------------------
// TraceFiltersEE
// --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -692,6 +700,7 @@ struct Pcsx2Config
GSHWAutoFlushLevel UserHacks_AutoFlush = GSHWAutoFlushLevel::Disabled;
GSHalfPixelOffset UserHacks_HalfPixelOffset = GSHalfPixelOffset::Off;
s8 UserHacks_RoundSprite = 0;
GSNativeScaling UserHacks_NativeScaling = GSNativeScaling::Normal;
s32 UserHacks_TCOffsetX = 0;
s32 UserHacks_TCOffsetY = 0;
u8 UserHacks_CPUSpriteRenderBW = 0;
Expand Down
1 change: 1 addition & 0 deletions pcsx2/Docs/GameIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ The clamp modes are also numerically based.
* skipDrawStart [Value between `0` to `10000`] {0-10000} Default: Off (`0`)
* skipDrawEnd [Value between `0` to `10000`] {0-10000} Default: Off (`0`)
* halfPixelOffset [`0` or `1` or `2` or `3` or `4`] {Off, Normal Vertex, Special (Texture), Special (Texture Aggressive), Align to Native} Default: Off (`0`)
* nativeScaling [`0` or `1` or `2`] {Normal, Aggressive or Off} Default: Normal (`0`)
* nativePaletteDraw [`0` or `1`] {Off, On} Default: Off (`0`)
* roundSprite [`0` or `1` or `2`] {Off, Half or Full} Default: Off (`0`)

Expand Down
5 changes: 5 additions & 0 deletions pcsx2/Docs/gamedb-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@
"minimum": 0,
"maximum": 4
},
"nativeScaling": {
"type": "integer",
"minimum": 0,
"maximum": 2
},
"roundSprite": {
"type": "integer",
"minimum": 0,
Expand Down
5 changes: 4 additions & 1 deletion pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2622,7 +2622,7 @@ void GSRendererHW::Draw()
m_downscale_source = src->m_from_target->GetScale() > 1.0f;
}
else
m_downscale_source = false; //src->m_from_target->GetScale() > 1.0f; // Bad for GTA + Full Spectrum Warrior, good for Sacred Blaze + Parappa.
m_downscale_source = GSConfig.UserHacks_NativeScaling != GSNativeScaling::Aggressive ? false : src->m_from_target->GetScale() > 1.0f; // Bad for GTA + Full Spectrum Warrior, good for Sacred Blaze + Parappa.
}
else
m_downscale_source = false;
Expand Down Expand Up @@ -7145,6 +7145,9 @@ int GSRendererHW::IsScalingDraw(GSTextureCache::Source* src, bool no_gaps)
if (is_downscale && draw_size.x >= PCRTCDisplays.GetResolution().x)
return 0;

if (GSConfig.UserHacks_NativeScaling == GSNativeScaling::Off)
return 0;

// Check if we're already downscaled and drawing in current size, try not to rescale it.
if (src && src->m_from_target && src->m_from_target->m_downscaled && std::abs(draw_size.x - tex_size.x) <= 1 && std::abs(draw_size.y - tex_size.y) <= 1)
return 1;
Expand Down
8 changes: 8 additions & 0 deletions pcsx2/GameDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static const char* s_gs_hw_fix_names[] = {
"halfBottomOverride",
"halfPixelOffset",
"roundSprite",
"nativeScaling",
"texturePreloading",
"deinterlace",
"cpuSpriteRenderBW",
Expand Down Expand Up @@ -638,6 +639,9 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti
case GSHWFixId::RoundSprite:
return (config.UpscaleMultiplier <= 1.0f || config.UserHacks_RoundSprite == value);

case GSHWFixId::NativeScaling:
return (static_cast<int>(config.UserHacks_NativeScaling) == value);

case GSHWFixId::TexturePreloading:
return (static_cast<int>(config.TexturePreloading) <= value);

Expand Down Expand Up @@ -809,6 +813,10 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
config.UserHacks_RoundSprite = value;
break;

case GSHWFixId::NativeScaling:
config.UserHacks_NativeScaling = static_cast<GSNativeScaling>(value);
break;

case GSHWFixId::TexturePreloading:
{
if (value >= 0 && value <= static_cast<int>(TexturePreloadingLevel::Full))
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GameDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace GameDatabaseSchema
HalfBottomOverride,
HalfPixelOffset,
RoundSprite,
NativeScaling,
TexturePreloading,
Deinterlace,
CPUSpriteRenderBW,
Expand Down
7 changes: 7 additions & 0 deletions pcsx2/ImGui/FullscreenUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3739,6 +3739,11 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
FSUI_NSTR("Special (Texture - Aggressive)"),
FSUI_NSTR("Align To Native"),
};
static constexpr const char* s_native_scaling_options[] = {
FSUI_NSTR("Normal (Default)"),
FSUI_NSTR("Aggressive"),
FSUI_NSTR("Off"),
};
static constexpr const char* s_round_sprite_options[] = {
FSUI_NSTR("Off (Default)"),
FSUI_NSTR("Half"),
Expand Down Expand Up @@ -3804,6 +3809,8 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
MenuHeading(FSUI_CSTR("Upscaling Fixes"));
DrawIntListSetting(bsi, FSUI_CSTR("Half Pixel Offset"), FSUI_CSTR("Adjusts vertices relative to upscaling."), "EmuCore/GS",
"UserHacks_HalfPixelOffset", 0, s_half_pixel_offset_options, std::size(s_half_pixel_offset_options), true);
DrawIntListSetting(bsi, FSUI_CSTR("Native Scaling"), FSUI_CSTR("Attempt to do rescaling at native resolution."), "EmuCore/GS",
"UserHacks_native_scaling", 0, s_native_scaling_options, std::size(s_native_scaling_options), true);
DrawIntListSetting(bsi, FSUI_CSTR("Round Sprite"), FSUI_CSTR("Adjusts sprite coordinates."), "EmuCore/GS",
"UserHacks_round_sprite_offset", 0, s_round_sprite_options, std::size(s_round_sprite_options), true);
DrawIntListSetting(bsi, FSUI_CSTR("Bilinear Upscale"),
Expand Down
2 changes: 2 additions & 0 deletions pcsx2/ImGui/ImGuiOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ __ri void ImGuiManager::DrawSettingsOverlay(float scale, float margin, float spa
APPEND("HPO={} ", static_cast<u32>(GSConfig.UserHacks_HalfPixelOffset));
if (GSConfig.UserHacks_RoundSprite > 0)
APPEND("RS={} ", GSConfig.UserHacks_RoundSprite);
if (GSConfig.UserHacks_NativeScaling > GSNativeScaling::Normal)
APPEND("NS={} ", static_cast<unsigned>(GSConfig.UserHacks_NativeScaling));
if (GSConfig.UserHacks_TCOffsetX != 0 || GSConfig.UserHacks_TCOffsetY != 0)
APPEND("TCO={}/{} ", GSConfig.UserHacks_TCOffsetX, GSConfig.UserHacks_TCOffsetY);
if (GSConfig.UserHacks_CPUSpriteRenderBW != 0)
Expand Down
4 changes: 4 additions & 0 deletions pcsx2/Pcsx2Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ bool Pcsx2Config::GSOptions::OptionsAreEqual(const GSOptions& right) const
OpEqu(UserHacks_AutoFlush) &&
OpEqu(UserHacks_HalfPixelOffset) &&
OpEqu(UserHacks_RoundSprite) &&
OpEqu(UserHacks_NativeScaling) &&
OpEqu(UserHacks_TCOffsetX) &&
OpEqu(UserHacks_TCOffsetY) &&
OpEqu(UserHacks_CPUSpriteRenderBW) &&
Expand Down Expand Up @@ -908,6 +909,7 @@ void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap)

SettingsWrapIntEnumEx(UserHacks_HalfPixelOffset, "UserHacks_HalfPixelOffset");
SettingsWrapBitfieldEx(UserHacks_RoundSprite, "UserHacks_round_sprite_offset");
SettingsWrapIntEnumEx(UserHacks_NativeScaling, "UserHacks_native_scaling");
SettingsWrapBitfieldEx(UserHacks_TCOffsetX, "UserHacks_TCOffsetX");
SettingsWrapBitfieldEx(UserHacks_TCOffsetY, "UserHacks_TCOffsetY");
SettingsWrapBitfieldEx(UserHacks_CPUSpriteRenderBW, "UserHacks_CPUSpriteRenderBW");
Expand Down Expand Up @@ -964,6 +966,7 @@ void Pcsx2Config::GSOptions::MaskUserHacks()
UserHacks_DisableRenderFixes = false;
UserHacks_HalfPixelOffset = GSHalfPixelOffset::Off;
UserHacks_RoundSprite = 0;
UserHacks_NativeScaling = GSNativeScaling::Normal;
UserHacks_AutoFlush = GSHWAutoFlushLevel::Disabled;
GPUPaletteConversion = false;
PreloadFrameWithGSData = false;
Expand Down Expand Up @@ -996,6 +999,7 @@ void Pcsx2Config::GSOptions::MaskUpscalingHacks()
UserHacks_NativePaletteDraw = false;
UserHacks_HalfPixelOffset = GSHalfPixelOffset::Off;
UserHacks_RoundSprite = 0;
UserHacks_NativeScaling = GSNativeScaling::Normal;
UserHacks_TCOffsetX = 0;
UserHacks_TCOffsetY = 0;
}
Expand Down

0 comments on commit c7bf8b3

Please sign in to comment.