GS/HW: Add NativePaletteDraw upscaling fix

This commit is contained in:
Stenzek 2023-03-31 23:19:07 +10:00 committed by refractionpcsx2
parent f332d4f880
commit 4cbdbaabdb
10 changed files with 50 additions and 7 deletions

View File

@ -235,6 +235,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsDialog* dialog, QWidget*
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.mergeSprite, "EmuCore/GS", "UserHacks_merge_pp_sprite", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.wildHack, "EmuCore/GS", "UserHacks_WildHack", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.bilinearHack, "EmuCore/GS", "UserHacks_BilinearHack", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.nativePaletteDraw, "EmuCore/GS", "UserHacks_NativePaletteDraw", false);
//////////////////////////////////////////////////////////////////////////
// Texture Replacements
//////////////////////////////////////////////////////////////////////////

View File

@ -1224,13 +1224,6 @@
</item>
<item row="3" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QCheckBox" name="mergeSprite">
<property name="text">
<string>Merge Sprite</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="alignSprite">
<property name="text">
@ -1252,6 +1245,20 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="mergeSprite">
<property name="text">
<string>Merge Sprite</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="nativePaletteDraw">
<property name="text">
<string>Unscaled Palette Texture Draws</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -678,6 +678,7 @@ struct Pcsx2Config
UserHacks_MergePPSprite : 1,
UserHacks_WildHack : 1,
UserHacks_BilinearHack : 1,
UserHacks_NativePaletteDraw : 1,
UserHacks_TargetPartialInvalidation : 1,
UserHacks_EstimateTextureRegion : 1,
FXAA : 1,

View File

@ -176,6 +176,11 @@
"minimum": 0,
"maximum": 1
},
"nativePaletteDraw": {
"type": "integer",
"minimum": 0,
"maximum": 1
},
"estimateTextureRegion": {
"type": "integer",
"minimum": 0,

View File

@ -3241,6 +3241,8 @@ void FullscreenUI::DrawGraphicsSettingsPage()
DrawToggleSetting(bsi, "Bilinear Upscale",
"Can smooth out textures due to be bilinear filtered when upscaling. E.g. Brave sun glare.", "EmuCore/GS",
"UserHacks_BilinearHack", false, manual_hw_fixes);
DrawToggleSetting(bsi, "Unscaled Palette Texture Draws", "Can fix some broken effects which rely on pixel perfect precision.",
"EmuCore/GS", "UserHacks_NativePaletteDraw", false, manual_hw_fixes);
}
}

View File

@ -417,6 +417,8 @@ void ImGuiManager::DrawSettingsOverlay()
APPEND("WA ");
if (GSConfig.UserHacks_BilinearHack)
APPEND("BLU ");
if (GSConfig.UserHacks_NativePaletteDraw)
APPEND("NPD ");
if (GSConfig.UserHacks_MergePPSprite)
APPEND("MS ");
if (GSConfig.UserHacks_AlignSpriteX)

View File

@ -1793,6 +1793,18 @@ void GSRendererHW::Draw()
// Ensure draw rect is clamped to framebuffer size. Necessary for updating valid area.
m_r = m_r.rintersect(GSVector4i::loadh(t_size));
float target_scale = GetTextureScaleFactor();
// This upscaling hack is for games which construct P8 textures by drawing a bunch of small sprites in C32,
// then reinterpreting it as P8. We need to keep the off-screen intermediate textures at native resolution,
// but not propagate that through to the normal render targets. Test Case: Crash Wrath of Cortex.
if (no_ds && src && !m_channel_shuffle && GSConfig.UserHacks_NativePaletteDraw && src->m_from_target &&
src->m_scale == 1.0f && (src->m_TEX0.PSM == PSM_PSMT8 || src->m_TEX0.TBP0 == m_context->FRAME.Block()))
{
GL_CACHE("Using native resolution for target based on texture source");
target_scale = 1.0f;
}
GSTextureCache::Target* rt = nullptr;
GIFRegTEX0 FRAME_TEX0;
if (!no_rt)

View File

@ -353,6 +353,7 @@ static const char* s_gs_hw_fix_names[] = {
"mergeSprite",
"wildArmsHack",
"bilinearUpscale",
"nativePaletteDraw",
"estimateTextureRegion",
"PCRTCOffsets",
"PCRTCOverscan",
@ -593,6 +594,9 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti
case GSHWFixId::BilinearUpscale:
return (config.UpscaleMultiplier <= 1.0f || static_cast<int>(config.UserHacks_BilinearHack) == value);
case GSHWFixId::NativePaletteDraw:
return (config.UpscaleMultiplier <= 1.0f || static_cast<int>(config.UserHacks_NativePaletteDraw) == value);
case GSHWFixId::EstimateTextureRegion:
return (static_cast<int>(config.UserHacks_EstimateTextureRegion) == value);
@ -739,6 +743,10 @@ u32 GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
config.UserHacks_BilinearHack = (value > 0);
break;
case GSHWFixId::NativePaletteDraw:
config.UserHacks_NativePaletteDraw = (value > 0);
break;
case GSHWFixId::EstimateTextureRegion:
config.UserHacks_EstimateTextureRegion = (value > 0);
break;

View File

@ -72,6 +72,7 @@ namespace GameDatabaseSchema
MergeSprite,
WildArmsHack,
BilinearUpscale,
NativePaletteDraw,
EstimateTextureRegion,
PCRTCOffsets,
PCRTCOverscan,

View File

@ -444,6 +444,7 @@ Pcsx2Config::GSOptions::GSOptions()
UserHacks_MergePPSprite = false;
UserHacks_WildHack = false;
UserHacks_BilinearHack = false;
UserHacks_NativePaletteDraw = false;
DumpReplaceableTextures = false;
DumpReplaceableMipmaps = false;
@ -659,6 +660,7 @@ void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap)
GSSettingBoolEx(UserHacks_MergePPSprite, "UserHacks_merge_pp_sprite");
GSSettingBoolEx(UserHacks_WildHack, "UserHacks_WildHack");
GSSettingBoolEx(UserHacks_BilinearHack, "UserHacks_BilinearHack");
GSSettingBoolEx(UserHacks_NativePaletteDraw, "UserHacks_NativePaletteDraw");
GSSettingIntEnumEx(UserHacks_TextureInsideRt, "UserHacks_TextureInsideRt");
GSSettingBoolEx(UserHacks_TargetPartialInvalidation, "UserHacks_TargetPartialInvalidation");
GSSettingBoolEx(UserHacks_EstimateTextureRegion, "UserHacks_EstimateTextureRegion");
@ -778,6 +780,7 @@ void Pcsx2Config::GSOptions::MaskUserHacks()
UserHacks_MergePPSprite = false;
UserHacks_WildHack = false;
UserHacks_BilinearHack = false;
UserHacks_NativePaletteDraw = false;
UserHacks_DisableSafeFeatures = false;
UserHacks_HalfBottomOverride = -1;
UserHacks_HalfPixelOffset = 0;
@ -810,6 +813,7 @@ void Pcsx2Config::GSOptions::MaskUpscalingHacks()
UserHacks_MergePPSprite = false;
UserHacks_WildHack = false;
UserHacks_BilinearHack = false;
UserHacks_NativePaletteDraw = false;
UserHacks_HalfPixelOffset = 0;
UserHacks_RoundSprite = 0;
UserHacks_TCOffsetX = 0;