From 7df189ced4382956b38eb6186289ced4114a8eba Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 3 Mar 2023 23:04:50 +1000 Subject: [PATCH] GameDB: Add PCRTC and blending HW fixes --- pcsx2/Config.h | 1 + pcsx2/Docs/gamedb-schema.json | 25 ++++++++++++ pcsx2/GameDatabase.cpp | 72 ++++++++++++++++++++++++++++++++++- pcsx2/GameDatabase.h | 5 +++ pcsx2/Pcsx2Config.cpp | 9 +++++ 5 files changed, 110 insertions(+), 2 deletions(-) diff --git a/pcsx2/Config.h b/pcsx2/Config.h index e34b34fe5b..8893e459c3 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -614,6 +614,7 @@ struct Pcsx2Config { static const char* AspectRatioNames[]; static const char* FMVAspectRatioSwitchNames[]; + static const char* BlendingLevelNames[]; static const char* CaptureContainers[]; static const char* GetRendererName(GSRendererType type); diff --git a/pcsx2/Docs/gamedb-schema.json b/pcsx2/Docs/gamedb-schema.json index c706834f0b..48a963a5f4 100644 --- a/pcsx2/Docs/gamedb-schema.json +++ b/pcsx2/Docs/gamedb-schema.json @@ -181,6 +181,16 @@ "minimum": 0, "maximum": 1 }, + "PCRTCOffsets": { + "type": "integer", + "minimum": 0, + "maximum": 1 + }, + "PCRTCOverscan": { + "type": "integer", + "minimum": 0, + "maximum": 1 + }, "mipmap": { "type": "integer", "minimum": 0, @@ -246,6 +256,21 @@ "minimum": 0, "maximum": 2 }, + "minimumBlendingLevel": { + "type": "integer", + "minimum": 0, + "maximum": 5 + }, + "maximumBlendingLevel": { + "type": "integer", + "minimum": 0, + "maximum": 5 + }, + "recommendedBlendingLevel": { + "type": "integer", + "minimum": 0, + "maximum": 5 + }, "getSkipCount": { "type": "string" }, diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp index 36dfeadaca..a08919aba3 100644 --- a/pcsx2/GameDatabase.cpp +++ b/pcsx2/GameDatabase.cpp @@ -18,6 +18,7 @@ #include "GameDatabase.h" #include "GS/GS.h" #include "Host.h" +#include "IconsFontAwesome5.h" #include "vtlb.h" #include "common/FileSystem.h" @@ -353,6 +354,8 @@ static const char* s_gs_hw_fix_names[] = { "mergeSprite", "wildArmsHack", "estimateTextureRegion", + "PCRTCOffsets", + "PCRTCOverscan", "mipmap", "trilinearFiltering", "skipDrawStart", @@ -366,8 +369,11 @@ static const char* s_gs_hw_fix_names[] = { "cpuCLUTRender", "gpuTargetCLUT", "gpuPaletteConversion", + "minimumBlendingLevel", + "maximumBlendingLevel", + "recommendedBlendingLevel", "getSkipCount", - "beforeDraw", + "beforeDraw" }; static_assert(std::size(s_gs_hw_fix_names) == static_cast(GameDatabaseSchema::GSHWFixId::Count), "HW fix name lookup is correct size"); @@ -395,6 +401,11 @@ bool GameDatabaseSchema::isUserHackHWFix(GSHWFixId id) case GSHWFixId::Mipmap: case GSHWFixId::TexturePreloading: case GSHWFixId::TrilinearFiltering: + case GSHWFixId::MinimumBlendingLevel: + case GSHWFixId::MaximumBlendingLevel: + case GSHWFixId::RecommendedBlendingLevel: + case GSHWFixId::PCRTCOffsets: + case GSHWFixId::PCRTCOverscan: case GSHWFixId::GetSkipCount: case GSHWFixId::BeforeDraw: return false; @@ -584,6 +595,12 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti case GSHWFixId::EstimateTextureRegion: return (static_cast(config.UserHacks_EstimateTextureRegion) == value); + case GSHWFixId::PCRTCOffsets: + return (static_cast(config.PCRTCOffsets) == value); + + case GSHWFixId::PCRTCOverscan: + return (static_cast(config.PCRTCOverscan) == value); + case GSHWFixId::Mipmap: return (config.HWMipmap == HWMipmapLevel::Automatic || static_cast(config.HWMipmap) == value); @@ -623,6 +640,15 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti case GSHWFixId::GPUPaletteConversion: return (config.GPUPaletteConversion == ((value > 1) ? (config.TexturePreloading == TexturePreloadingLevel::Full) : (value != 0))); + case GSHWFixId::MinimumBlendingLevel: + return (static_cast(config.AccurateBlendingUnit) >= value); + + case GSHWFixId::MaximumBlendingLevel: + return (static_cast(config.AccurateBlendingUnit) <= value); + + case GSHWFixId::RecommendedBlendingLevel: + return true; + case GSHWFixId::GetSkipCount: return (static_cast(config.GetSkipCountFunctionId) == value); @@ -713,6 +739,14 @@ u32 GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions& config.UserHacks_EstimateTextureRegion = (value > 0); break; + case GSHWFixId::PCRTCOffsets: + config.PCRTCOffsets = (value > 0); + break; + + case GSHWFixId::PCRTCOverscan: + config.PCRTCOverscan = (value > 0); + break; + case GSHWFixId::Mipmap: { if (value >= 0 && value <= static_cast(HWMipmapLevel::Full)) @@ -801,6 +835,40 @@ u32 GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions& } break; + case GSHWFixId::MinimumBlendingLevel: + { + if (value >= 0 && value <= static_cast(AccBlendLevel::Maximum)) + config.AccurateBlendingUnit = std::max(config.AccurateBlendingUnit, static_cast(value)); + } + break; + + case GSHWFixId::MaximumBlendingLevel: + { + if (value >= 0 && value <= static_cast(AccBlendLevel::Maximum)) + config.AccurateBlendingUnit = std::min(config.AccurateBlendingUnit, static_cast(value)); + } + break; + + case GSHWFixId::RecommendedBlendingLevel: + { + if (value >= 0 && value <= static_cast(AccBlendLevel::Maximum) && static_cast(GSConfig.AccurateBlendingUnit) < value) + { + Host::AddKeyedOSDMessage("HWBlendingWarning", + fmt::format(ICON_FA_PAINT_BRUSH " Current Blending Accuracy is {}.\n" + "Recommended Blending Accuracy for this game is {}.\n" + "You can adjust the blending level in Game Properties to improve\n" + "graphical quality, but this will increase system requirements.", + Pcsx2Config::GSOptions::BlendingLevelNames[static_cast(GSConfig.AccurateBlendingUnit)], + Pcsx2Config::GSOptions::BlendingLevelNames[value]), + Host::OSD_WARNING_DURATION); + } + else + { + Host::RemoveKeyedOSDMessage("HWBlendingWarning"); + } + } + break; + case GSHWFixId::GetSkipCount: config.GetSkipCountFunctionId = static_cast(value); break; @@ -823,7 +891,7 @@ u32 GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions& if (!disabled_fixes.empty()) { Host::AddKeyedOSDMessage("HWFixesWarning", - fmt::format("Manual GS hardware renderer fixes are enabled, automatic fixes were not applied:\n{}", + fmt::format(ICON_FA_MAGIC " Manual GS hardware renderer fixes are enabled, automatic fixes were not applied:\n{}", disabled_fixes), Host::OSD_ERROR_DURATION); } diff --git a/pcsx2/GameDatabase.h b/pcsx2/GameDatabase.h index 8f439d0ffc..0e10971947 100644 --- a/pcsx2/GameDatabase.h +++ b/pcsx2/GameDatabase.h @@ -73,6 +73,8 @@ namespace GameDatabaseSchema MergeSprite, WildArmsHack, EstimateTextureRegion, + PCRTCOffsets, + PCRTCOverscan, // integer settings Mipmap, @@ -88,6 +90,9 @@ namespace GameDatabaseSchema CPUCLUTRender, GPUTargetCLUT, GPUPaletteConversion, + MinimumBlendingLevel, + MaximumBlendingLevel, + RecommendedBlendingLevel, GetSkipCount, BeforeDraw, diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 25a7de6cb3..e3a23edb87 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -362,6 +362,15 @@ const char* Pcsx2Config::GSOptions::FMVAspectRatioSwitchNames[] = { "16:9", nullptr}; +const char* Pcsx2Config::GSOptions::BlendingLevelNames[] = { + "Minimum", + "Basic", + "Medium", + "High", + "Full", + "Maximum", + nullptr}; + const char* Pcsx2Config::GSOptions::CaptureContainers[] = { "mp4", "mkv",