Skip to content

Commit 3b0a83c

Browse files
Qt/Fullscreenui/GS: Add Automatic blending option.
Automatic blending option will behave like basic level with the exception of gamedb if it forces a blend level then it will take that in to consideration, any other option will override the gamedb.
1 parent 9864cd9 commit 3b0a83c

File tree

8 files changed

+34
-19
lines changed

8 files changed

+34
-19
lines changed

pcsx2-qt/Settings/GraphicsHardwareRenderingSettingsTab.ui

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,19 @@
116116
</item>
117117
<item row="5" column="1">
118118
<widget class="QComboBox" name="blending">
119+
<item>
120+
<property name="text">
121+
<string>Automatic (Default)</string>
122+
</property>
123+
</item>
119124
<item>
120125
<property name="text">
121126
<string>Minimum</string>
122127
</property>
123128
</item>
124129
<item>
125130
<property name="text">
126-
<string>Basic (Recommended)</string>
131+
<string>Basic</string>
127132
</property>
128133
</item>
129134
<item>

pcsx2-qt/Settings/GraphicsSettingsWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* settings_dialog,
121121
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_hw.dithering, "EmuCore/GS", "dithering_ps2", 2);
122122
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_hw.mipmapping, "EmuCore/GS", "hw_mipmap", true);
123123
SettingWidgetBinder::BindWidgetToIntSetting(
124-
sif, m_hw.blending, "EmuCore/GS", "accurate_blending_unit", static_cast<int>(AccBlendLevel::Basic));
124+
sif, m_hw.blending, "EmuCore/GS", "accurate_blending_unit", static_cast<int>(AccBlendLevel::Automatic), -1);
125125
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_hw.enableHWFixes, "EmuCore/GS", "UserHacks", false);
126126
connect(m_hw.upscaleMultiplier, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
127127
&GraphicsSettingsWidget::onUpscaleMultiplierChanged);

pcsx2/Config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ enum class TriFiltering : s8
327327
Forced,
328328
};
329329

330-
enum class AccBlendLevel : u8
330+
enum class AccBlendLevel : s8
331331
{
332+
Automatic = -1,
332333
Minimum,
333334
Basic,
334335
Medium,
@@ -811,7 +812,7 @@ struct Pcsx2Config
811812
GSRendererType Renderer = GSRendererType::Auto;
812813
float UpscaleMultiplier = 1.0f;
813814

814-
AccBlendLevel AccurateBlendingUnit = AccBlendLevel::Basic;
815+
AccBlendLevel AccurateBlendingUnit = AccBlendLevel::Automatic;
815816
BiFiltering TextureFiltering = BiFiltering::PS2;
816817
TexturePreloadingLevel TexturePreloading = TexturePreloadingLevel::Full;
817818
GSDumpCompressionMethod GSDumpCompression = GSDumpCompressionMethod::Zstandard;

pcsx2/GS/Renderers/HW/GSRendererHW.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5180,6 +5180,8 @@ void GSRendererHW::EmulateTextureShuffleAndFbmask(GSTextureCache::Target* rt, GS
51805180
enable_fbmask_emulation = true;
51815181
break;
51825182
case AccBlendLevel::Basic:
5183+
case AccBlendLevel::Automatic:
5184+
default:
51835185
// Enable Fbmask emulation excluding triangle class because it is quite slow.
51845186
enable_fbmask_emulation = (m_vt.m_primclass != GS_TRIANGLE_CLASS);
51855187
break;
@@ -5784,7 +5786,7 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
57845786
const bool blend_ad = m_conf.ps.blend_c == 1;
57855787
const bool alpha_mask = (m_cached_ctx.FRAME.FBMSK & 0xFF000000) == 0xFF000000;
57865788
bool blend_ad_alpha_masked = blend_ad && alpha_mask;
5787-
const bool is_basic_blend = GSConfig.AccurateBlendingUnit >= AccBlendLevel::Basic;
5789+
const bool is_basic_blend = GSConfig.AccurateBlendingUnit != AccBlendLevel::Minimum;
57885790
if (blend_ad_alpha_masked && (((is_basic_blend || (COLCLAMP.CLAMP == 0)) && (features.texture_barrier || features.multidraw_fb_copy))
57895791
|| ((GSConfig.AccurateBlendingUnit >= AccBlendLevel::Medium) || m_conf.require_one_barrier)))
57905792
{
@@ -5894,6 +5896,8 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
58945896
sw_blending |= m_vt.m_primclass == GS_SPRITE_CLASS && m_drawlist.size() < 100;
58955897
[[fallthrough]];
58965898
case AccBlendLevel::Basic:
5899+
case AccBlendLevel::Automatic:
5900+
default:
58975901
// Prefer sw blend if possible.
58985902
color_dest_blend &= !prefer_sw_blend;
58995903
color_dest_blend2 &= !prefer_sw_blend;
@@ -5935,6 +5939,8 @@ void GSRendererHW::EmulateBlending(int rt_alpha_min, int rt_alpha_max, const boo
59355939
sw_blending |= !(blend_ad_alpha_masked || ad_second_pass) && (alpha_c1_high_max_one || alpha_c1_high_no_rta_correct) && no_prim_overlap;
59365940
[[fallthrough]];
59375941
case AccBlendLevel::Basic:
5942+
case AccBlendLevel::Automatic:
5943+
default:
59385944
// Prefer sw blend if possible.
59395945
color_dest_blend &= !prefer_sw_blend;
59405946
color_dest_blend2 &= !prefer_sw_blend;

pcsx2/GameDatabase.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ bool GameDatabaseSchema::GameEntry::configMatchesHWFix(const Pcsx2Config::GSOpti
664664
return (config.GPUPaletteConversion == ((value > 1) ? (config.TexturePreloading == TexturePreloadingLevel::Full) : (value != 0)));
665665

666666
case GSHWFixId::MinimumBlendingLevel:
667-
return (static_cast<int>(config.AccurateBlendingUnit) >= value);
667+
return (config.AccurateBlendingUnit == AccBlendLevel::Automatic || static_cast<int>(config.AccurateBlendingUnit) >= value);
668668

669669
case GSHWFixId::MaximumBlendingLevel:
670-
return (static_cast<int>(config.AccurateBlendingUnit) <= value);
670+
return (config.AccurateBlendingUnit == AccBlendLevel::Automatic || static_cast<int>(config.AccurateBlendingUnit) <= value);
671671

672672
case GSHWFixId::RecommendedBlendingLevel:
673673
return true;
@@ -868,21 +868,23 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
868868

869869
case GSHWFixId::MinimumBlendingLevel:
870870
{
871-
if (value >= 0 && value <= static_cast<int>(AccBlendLevel::Maximum))
872-
config.AccurateBlendingUnit = std::max(config.AccurateBlendingUnit, static_cast<AccBlendLevel>(value));
871+
if (value >= 0 && value <= static_cast<int>(AccBlendLevel::Maximum) && config.AccurateBlendingUnit == AccBlendLevel::Automatic)
872+
config.AccurateBlendingUnit = static_cast<AccBlendLevel>(value);
873873
}
874874
break;
875875

876876
case GSHWFixId::MaximumBlendingLevel:
877877
{
878-
if (value >= 0 && value <= static_cast<int>(AccBlendLevel::Maximum))
879-
config.AccurateBlendingUnit = std::min(config.AccurateBlendingUnit, static_cast<AccBlendLevel>(value));
878+
if (value >= 0 && value <= static_cast<int>(AccBlendLevel::Maximum) && config.AccurateBlendingUnit == AccBlendLevel::Automatic)
879+
config.AccurateBlendingUnit = static_cast<AccBlendLevel>(value);
880880
}
881881
break;
882882

883883
case GSHWFixId::RecommendedBlendingLevel:
884884
{
885-
if (!is_sw_renderer && value >= 0 && value <= static_cast<int>(AccBlendLevel::Maximum) && static_cast<int>(EmuConfig.GS.AccurateBlendingUnit) < value)
885+
// Need to increment by 1 because Automatic is -1.
886+
const int blend_level = static_cast<int>(config.AccurateBlendingUnit) + 1;
887+
if (!is_sw_renderer && value >= static_cast<int>(AccBlendLevel::Automatic) && value <= static_cast<int>(AccBlendLevel::Maximum) && blend_level < value)
886888
{
887889
Host::AddKeyedOSDMessage("HWBlendingWarning",
888890
fmt::format(TRANSLATE_FS("GameDatabase",
@@ -891,8 +893,7 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
891893
"You can adjust the blending level in Game Properties to improve\n"
892894
"graphical quality, but this will increase system requirements."),
893895
ICON_FA_PAINTBRUSH,
894-
Pcsx2Config::GSOptions::BlendingLevelNames[static_cast<int>(
895-
EmuConfig.GS.AccurateBlendingUnit)],
896+
Pcsx2Config::GSOptions::BlendingLevelNames[blend_level],
896897
Pcsx2Config::GSOptions::BlendingLevelNames[value]),
897898
Host::OSD_WARNING_DURATION);
898899
}

pcsx2/ImGui/FullscreenUI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,8 +4066,9 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
40664066
FSUI_NSTR("Force 32bit"),
40674067
};
40684068
static constexpr const char* s_blending_options[] = {
4069+
FSUI_NSTR("Automatic (Default)"),
40694070
FSUI_NSTR("Minimum"),
4070-
FSUI_NSTR("Basic (Recommended)"),
4071+
FSUI_NSTR("Basic"),
40714072
FSUI_NSTR("Medium"),
40724073
FSUI_NSTR("High"),
40734074
FSUI_NSTR("Full (Slow)"),
@@ -4199,7 +4200,7 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
41994200
"EmuCore/GS", "dithering_ps2", 2, s_dithering_options, std::size(s_dithering_options), true);
42004201
DrawIntListSetting(bsi, FSUI_ICONSTR(ICON_FA_SPLOTCH, "Blending Accuracy"),
42014202
FSUI_CSTR("Determines the level of accuracy when emulating blend modes not supported by the host graphics API."), "EmuCore/GS",
4202-
"accurate_blending_unit", static_cast<int>(AccBlendLevel::Basic), s_blending_options, std::size(s_blending_options), true);
4203+
"accurate_blending_unit", static_cast<int>(AccBlendLevel::Automatic), s_blending_options, std::size(s_blending_options), true);
42034204
DrawToggleSetting(
42044205
bsi, FSUI_ICONSTR(ICON_FA_BULLSEYE, "Mipmapping"), FSUI_CSTR("Enables emulation of the GS's texture mipmapping."), "EmuCore/GS", "hw_mipmap", true);
42054206
}

pcsx2/Pcsx2Config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ const char* Pcsx2Config::GSOptions::FMVAspectRatioSwitchNames[(size_t)FMVAspectR
653653
nullptr};
654654

655655
const char* Pcsx2Config::GSOptions::BlendingLevelNames[] = {
656+
"Automatic",
656657
"Minimum",
657658
"Basic",
658659
"Medium",

pcsx2/VMManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,12 +3150,12 @@ void VMManager::WarnAboutUnsafeSettings()
31503150
if (EmuConfig.GS.TriFilter != TriFiltering::Automatic)
31513151
{
31523152
append(ICON_FA_PAGER,
3153-
TRANSLATE_SV("VMManager", "Trilinear filtering is not set to automatic. This may break rendering in some games."));
3153+
TRANSLATE_SV("VMManager", "Trilinear filtering is not set to Automatic. This may break rendering in some games."));
31543154
}
3155-
if (EmuConfig.GS.AccurateBlendingUnit <= AccBlendLevel::Minimum)
3155+
if (EmuConfig.GS.AccurateBlendingUnit == AccBlendLevel::Minimum)
31563156
{
31573157
append(ICON_FA_PAINTBRUSH,
3158-
TRANSLATE_SV("VMManager", "Blending Accuracy is below Basic, this may break effects in some games."));
3158+
TRANSLATE_SV("VMManager", "Blending Accuracy is set to Minimum. This may break rendering in some games."));
31593159
}
31603160
if (EmuConfig.GS.HWDownloadMode != GSHardwareDownloadMode::Enabled)
31613161
{

0 commit comments

Comments
 (0)