Skip to content

Commit a5a8a46

Browse files
OSD: Add warning for hash cache setting overriding texture replace/dump
1 parent b003ead commit a5a8a46

File tree

6 files changed

+83
-12
lines changed

6 files changed

+83
-12
lines changed

pcsx2-qt/Settings/GraphicsSettingsWidget.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* settings_dialog,
263263
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_advanced.spinGPUDuringReadbacks, "EmuCore/GS", "HWSpinGPUForReadbacks", false);
264264
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_advanced.texturePreloading, "EmuCore/GS", "texture_preloading", static_cast<int>(TexturePreloadingLevel::Off));
265265

266+
connect(m_advanced.texturePreloading, &QComboBox::currentIndexChanged, this, &GraphicsSettingsWidget::onTexturePreloadingChanged);
266267
setTabVisible(m_advanced_tab, QtHost::ShouldShowAdvancedSettings());
267268

268269
//////////////////////////////////////////////////////////////////////////
@@ -1080,6 +1081,22 @@ void GraphicsSettingsWidget::onCPUSpriteRenderBWChanged()
10801081
m_fixes.cpuSpriteRenderLevel->setEnabled(value != 0);
10811082
}
10821083

1084+
void GraphicsSettingsWidget::onTexturePreloadingChanged()
1085+
{
1086+
// Loading and dumping textures only works with full hash cache.
1087+
const bool texture_preloading_full = dialog()->getEffectiveIntValue("EmuCore/GS", "texture_preloading", 2) == 2;
1088+
const bool texture_replacements_enabled = m_texture.loadTextureReplacements->isChecked();
1089+
const bool texture_dumping_enabled = m_texture.dumpReplaceableTextures->isChecked();
1090+
1091+
m_texture.loadTextureReplacements->setEnabled(texture_preloading_full);
1092+
m_texture.loadTextureReplacementsAsync->setEnabled(texture_preloading_full && texture_replacements_enabled);
1093+
m_texture.precacheTextureReplacements->setEnabled(texture_preloading_full && texture_replacements_enabled);
1094+
1095+
m_texture.dumpReplaceableTextures->setEnabled(texture_preloading_full);
1096+
m_texture.dumpReplaceableMipmaps->setEnabled(texture_preloading_full && texture_dumping_enabled);
1097+
m_texture.dumpTexturesWithFMVActive->setEnabled(texture_preloading_full && texture_dumping_enabled);
1098+
}
1099+
10831100
GSRendererType GraphicsSettingsWidget::getEffectiveRenderer() const
10841101
{
10851102
const GSRendererType type =

pcsx2-qt/Settings/GraphicsSettingsWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private Q_SLOTS:
5555
void onEnableAudioCaptureChanged();
5656
void onEnableAudioCaptureArgumentsChanged();
5757
void onOsdShowSettingsToggled();
58+
void onTexturePreloadingChanged();
5859

5960
private:
6061
GSRendererType getEffectiveRenderer() const;

pcsx2/GameDatabase.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,26 @@ void GameDatabaseSchema::GameEntry::applyGSHardwareFixes(Pcsx2Config::GSOptions&
939939
}
940940
}
941941

942+
std::optional<s32> GameDatabaseSchema::GameEntry::getSpeedHackValue(const SpeedHack queried_speed_hack) const
943+
{
944+
for (const auto& speed_hack : speedHacks)
945+
{
946+
if (speed_hack.first == queried_speed_hack)
947+
return speed_hack.second;
948+
}
949+
return std::nullopt;
950+
}
951+
952+
std::optional<s32> GameDatabaseSchema::GameEntry::getGSHWFixValue(const GSHWFixId queried_hardware_fix) const
953+
{
954+
for (const auto& hardware_fix : gsHWFixes)
955+
{
956+
if (hardware_fix.first == queried_hardware_fix)
957+
return hardware_fix.second;
958+
}
959+
return std::nullopt;
960+
}
961+
942962
void GameDatabase::initDatabase()
943963
{
944964
const std::string path(Path::Combine(EmuFolders::Resources, GAMEDB_YAML_FILE_NAME));

pcsx2/GameDatabase.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace GameDatabaseSchema
101101
ClampMode vu0ClampMode = ClampMode::Undefined;
102102
ClampMode vu1ClampMode = ClampMode::Undefined;
103103
std::vector<GamefixId> gameFixes;
104-
std::vector<std::pair<SpeedHack, int>> speedHacks;
104+
std::vector<std::pair<SpeedHack, s32>> speedHacks;
105105
std::vector<std::pair<GSHWFixId, s32>> gsHWFixes;
106106
std::vector<std::string> memcardFilters;
107107
std::unordered_map<u32, std::string> patches;
@@ -120,6 +120,12 @@ namespace GameDatabaseSchema
120120

121121
/// Returns true if the current config value for the specified hw fix id matches the value.
122122
static bool configMatchesHWFix(const Pcsx2Config::GSOptions& config, GSHWFixId id, int value);
123+
124+
/// Returns the value for a speed hack in a DB entry if it exists.
125+
std::optional<s32> getSpeedHackValue(const SpeedHack queried_speed_hack) const;
126+
127+
/// Returns the value for a speed hack in a DB entry if it exists.
128+
std::optional<s32> getGSHWFixValue(const GSHWFixId queried_hardware_fix) const;
123129
};
124130
}; // namespace GameDatabaseSchema
125131

pcsx2/ImGui/FullscreenUI.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,12 +4679,13 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
46794679

46804680
if (is_hardware)
46814681
{
4682-
const bool dumping_active = GetEffectiveBoolSetting(bsi, "EmuCore/GS", "DumpReplaceableTextures", false);
4683-
const bool replacement_active = GetEffectiveBoolSetting(bsi, "EmuCore/GS", "LoadTextureReplacements", false);
4682+
const bool texture_preloading_full = GetEffectiveIntSetting(bsi, "EmuCore/GS", "texture_preloading", 2) == 2;
4683+
const bool dumping_active = GetEffectiveBoolSetting(bsi, "EmuCore/GS", "DumpReplaceableTextures", false) && texture_preloading_full;
4684+
const bool replacement_active = GetEffectiveBoolSetting(bsi, "EmuCore/GS", "LoadTextureReplacements", false) && texture_preloading_full;
46844685

46854686
MenuHeading(FSUI_CSTR("Texture Replacement"));
46864687
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_IMAGES, "Load Textures"), FSUI_CSTR("Loads replacement textures where available and user-provided."),
4687-
"EmuCore/GS", "LoadTextureReplacements", false);
4688+
"EmuCore/GS", "LoadTextureReplacements", false, texture_preloading_full);
46884689
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_SPINNER, "Asynchronous Texture Loading"),
46894690
FSUI_CSTR("Loads replacement textures on a worker thread, reducing microstutter when replacements are enabled."), "EmuCore/GS",
46904691
"LoadTextureReplacementsAsync", true, replacement_active);
@@ -4699,7 +4700,7 @@ void FullscreenUI::DrawGraphicsSettingsPage(SettingsInterface* bsi, bool show_ad
46994700

47004701
MenuHeading(FSUI_CSTR("Texture Dumping"));
47014702
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_DOWNLOAD, "Dump Textures"), FSUI_CSTR("Dumps replaceable textures to disk. Will reduce performance."),
4702-
"EmuCore/GS", "DumpReplaceableTextures", false);
4703+
"EmuCore/GS", "DumpReplaceableTextures", false, texture_preloading_full);
47034704
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_IMAGES, "Dump Mipmaps"), FSUI_CSTR("Includes mipmaps when dumping textures."), "EmuCore/GS",
47044705
"DumpReplaceableMipmaps", false, dumping_active);
47054706
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Dump FMV Textures"),

pcsx2/VMManager.cpp

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3166,20 +3166,46 @@ void VMManager::WarnAboutUnsafeSettings()
31663166
append(ICON_FA_CIRCLE_EXCLAMATION,
31673167
TRANSLATE_SV("VMManager", "GPU Palette Conversion is enabled, this may reduce performance."));
31683168
}
3169-
if (EmuConfig.GS.TexturePreloading != TexturePreloadingLevel::Full)
3169+
3170+
// Try to find if texturePreloading specified as None or Partial; assume Full if unspecified.
3171+
s32 texture_preloading_DB_value = 2;
3172+
if (const GameDatabaseSchema::GameEntry* game = GameDatabase::findGame(s_disc_serial))
3173+
texture_preloading_DB_value = game->getGSHWFixValue(GameDatabaseSchema::GSHWFixId::TexturePreloading).value_or(2);
3174+
3175+
if (EmuConfig.GS.TexturePreloading != TexturePreloadingLevel::Full || texture_preloading_DB_value != 2)
31703176
{
3171-
append(ICON_FA_CIRCLE_EXCLAMATION,
3172-
TRANSLATE_SV("VMManager", "Texture Preloading is not Full, this may reduce performance."));
3177+
std::string preloading_warning = "";
3178+
3179+
// No need to warn the user about a setting we're enforcing.
3180+
if (texture_preloading_DB_value == 2)
3181+
preloading_warning = TRANSLATE_SV("VMManager", "Texture Preloading is not set to Full. This may reduce performance.");
3182+
else if (EmuConfig.GS.LoadTextureReplacements || EmuConfig.GS.DumpReplaceableTextures)
3183+
preloading_warning = fmt::format(TRANSLATE_FS("VMManager", "Texture Preloading is set to {} by the GameDB."),
3184+
texture_preloading_DB_value == 0 ? "None" : "Partial");
3185+
3186+
if (EmuConfig.GS.LoadTextureReplacements && EmuConfig.GS.DumpReplaceableTextures)
3187+
preloading_warning += fmt::format(TRANSLATE_FS("VMManager", "{}Texture replacement and dumping will not work unless texture preloading is set to Full."),
3188+
preloading_warning.empty() ? "" : "\n");
3189+
else if (EmuConfig.GS.LoadTextureReplacements)
3190+
preloading_warning += fmt::format(TRANSLATE_FS("VMManager", "{}Texture replacement will not work unless texture preloading is set to Full."),
3191+
preloading_warning.empty() ? "" : "\n");
3192+
else if (EmuConfig.GS.DumpReplaceableTextures)
3193+
preloading_warning += fmt::format(TRANSLATE_FS("VMManager", "{}Texture dumping will not work unless texture preloading is set to Full."),
3194+
preloading_warning.empty() ? "" : "\n");
3195+
3196+
if (!preloading_warning.empty())
3197+
append(ICON_FA_CIRCLE_EXCLAMATION, preloading_warning);
31733198
}
3174-
if (EmuConfig.GS.UserHacks_EstimateTextureRegion)
3199+
// No textures dumped while texture preloading isn't set to Full.
3200+
else if (EmuConfig.GS.DumpReplaceableTextures)
31753201
{
31763202
append(ICON_FA_CIRCLE_EXCLAMATION,
3177-
TRANSLATE_SV("VMManager", "Estimate texture region is enabled, this may reduce performance."));
3203+
TRANSLATE_SV("VMManager", "Texture dumping is enabled, this will continually dump textures to disk."));
31783204
}
3179-
if (EmuConfig.GS.DumpReplaceableTextures)
3205+
if (EmuConfig.GS.UserHacks_EstimateTextureRegion)
31803206
{
31813207
append(ICON_FA_CIRCLE_EXCLAMATION,
3182-
TRANSLATE_SV("VMManager", "Texture dumping is enabled, this will continually dump textures to disk."));
3208+
TRANSLATE_SV("VMManager", "Estimate texture region is enabled, this may reduce performance."));
31833209
}
31843210
if (!EmuConfig.GS.HWMipmap)
31853211
{

0 commit comments

Comments
 (0)