GPU/TextureCache: Add 'Always Track Uploads' option

This commit is contained in:
Stenzek 2024-12-23 13:52:23 +10:00
parent a8361f985e
commit 9e04b0bf55
No known key found for this signature in database
7 changed files with 82 additions and 75 deletions

View File

@ -4640,21 +4640,23 @@ void FullscreenUI::DrawGraphicsSettingsPage()
MenuHeading(FSUI_CSTR("Texture Replacements")); MenuHeading(FSUI_CSTR("Texture Replacements"));
ActiveButton(FSUI_CSTR("The texture cache is currently experimental, and may cause rendering errors in some games."), const bool texture_cache_enabled = GetEffectiveBoolSetting(bsi, "GPU", "EnableTextureCache", false);
false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, UIStyle.LargeFont);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_ID_BADGE, "Enable Texture Cache"), DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_ID_BADGE, "Enable Texture Cache"),
FSUI_CSTR("Enables caching of guest textures, required for texture replacement."), "GPU", FSUI_CSTR("Enables caching of guest textures, required for texture replacement."), "GPU",
"EnableTextureCache", false); "EnableTextureCache", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Use Old MDEC Routines"), DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TASKS, "Preload Replacement Textures"),
FSUI_CSTR("Enables the older, less accurate MDEC decoding routines. May be required for old " FSUI_CSTR("Loads all replacement texture to RAM, reducing stuttering at runtime."),
"replacement backgrounds to match/load."), "TextureReplacements", "PreloadTextures", false,
"Hacks", "UseOldMDECRoutines", false); ((texture_cache_enabled &&
GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableTextureReplacements", false)) ||
GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableVRAMWriteReplacements", false)));
const bool texture_cache_enabled = GetEffectiveBoolSetting(bsi, "GPU", "EnableTextureCache", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_IMPORT, "Enable Texture Replacements"), DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_IMPORT, "Enable Texture Replacements"),
FSUI_CSTR("Enables loading of replacement textures. Not compatible with all games."), FSUI_CSTR("Enables loading of replacement textures. Not compatible with all games."),
"TextureReplacements", "EnableTextureReplacements", false, texture_cache_enabled); "TextureReplacements", "EnableTextureReplacements", false, texture_cache_enabled);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_LIST, "Always Track Uploads"),
FSUI_CSTR("Forces texture upload tracking to be enabled regardless of whether it is needed."),
"TextureReplacements", "AlwaysTrackUploads", false, texture_cache_enabled);
DrawToggleSetting( DrawToggleSetting(
bsi, FSUI_ICONSTR(ICON_FA_FILE_EXPORT, "Enable Texture Dumping"), bsi, FSUI_ICONSTR(ICON_FA_FILE_EXPORT, "Enable Texture Dumping"),
FSUI_CSTR("Enables dumping of textures to image files, which can be replaced. Not compatible with all games."), FSUI_CSTR("Enables dumping of textures to image files, which can be replaced. Not compatible with all games."),
@ -4667,17 +4669,13 @@ void FullscreenUI::DrawGraphicsSettingsPage()
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_ALT, "Enable VRAM Write Replacement"), DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_ALT, "Enable VRAM Write Replacement"),
FSUI_CSTR("Enables the replacement of background textures in supported games."), FSUI_CSTR("Enables the replacement of background textures in supported games."),
"TextureReplacements", "EnableVRAMWriteReplacements", false); "TextureReplacements", "EnableVRAMWriteReplacements", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_INVOICE, "Enable VRAM Write Dumping"), DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_INVOICE, "Enable VRAM Write Dumping"),
FSUI_CSTR("Writes backgrounds that can be replaced to the dump directory."), "TextureReplacements", FSUI_CSTR("Writes backgrounds that can be replaced to the dump directory."), "TextureReplacements",
"DumpVRAMWrites", false); "DumpVRAMWrites", false);
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Use Old MDEC Routines"),
DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TASKS, "Preload Replacement Textures"), FSUI_CSTR("Enables the older, less accurate MDEC decoding routines. May be required for old "
FSUI_CSTR("Loads all replacement texture to RAM, reducing stuttering at runtime."), "replacement backgrounds to match/load."),
"TextureReplacements", "PreloadTextures", false, "Hacks", "UseOldMDECRoutines", false);
((texture_cache_enabled &&
GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableTextureReplacements", false)) ||
GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableVRAMWriteReplacements", false)));
DrawFolderSetting(bsi, FSUI_ICONSTR(ICON_FA_FOLDER, "Textures Directory"), "Folders", "Textures", DrawFolderSetting(bsi, FSUI_ICONSTR(ICON_FA_FOLDER, "Textures Directory"), "Folders", "Textures",
EmuFolders::Textures); EmuFolders::Textures);

View File

@ -564,6 +564,9 @@ bool GPUTextureCache::ShouldTrackVRAMWrites()
if (!g_gpu_settings.gpu_texture_cache) if (!g_gpu_settings.gpu_texture_cache)
return false; return false;
if (g_gpu_settings.texture_replacements.always_track_uploads)
return true;
#ifdef ALWAYS_TRACK_VRAM_WRITES #ifdef ALWAYS_TRACK_VRAM_WRITES
return true; return true;
#else #else
@ -592,20 +595,7 @@ bool GPUTextureCache::Initialize(GPU_HW* backend)
void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings) void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings)
{ {
if (use_texture_cache) const bool prev_tracking_state = s_state.track_vram_writes;
{
UpdateVRAMTrackingState();
if (g_gpu_settings.texture_replacements.enable_texture_replacements !=
old_settings.texture_replacements.enable_texture_replacements)
{
Invalidate();
DestroyPipelines();
if (!CompilePipelines()) [[unlikely]]
Panic("Failed to compile pipelines on TC settings change");
}
}
// Reload textures if configuration changes. // Reload textures if configuration changes.
const bool old_replacement_scale_linear_filter = s_state.config.replacement_scale_linear_filter; const bool old_replacement_scale_linear_filter = s_state.config.replacement_scale_linear_filter;
@ -617,8 +607,11 @@ void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings&
{ {
if (use_texture_cache) if (use_texture_cache)
{ {
if (s_state.config.replacement_scale_linear_filter != old_replacement_scale_linear_filter) if (g_gpu_settings.texture_replacements.enable_texture_replacements !=
old_settings.texture_replacements.enable_texture_replacements ||
s_state.config.replacement_scale_linear_filter != old_replacement_scale_linear_filter)
{ {
DestroyPipelines();
if (!CompilePipelines()) [[unlikely]] if (!CompilePipelines()) [[unlikely]]
Panic("Failed to compile pipelines on TC replacement settings change"); Panic("Failed to compile pipelines on TC replacement settings change");
} }
@ -626,6 +619,11 @@ void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings&
ReloadTextureReplacements(false); ReloadTextureReplacements(false);
} }
UpdateVRAMTrackingState();
if (s_state.track_vram_writes != prev_tracking_state)
Invalidate();
} }
bool GPUTextureCache::GetStateSize(StateWrapper& sw, u32* size) bool GPUTextureCache::GetStateSize(StateWrapper& sw, u32* size)

View File

@ -438,6 +438,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
si.GetBoolValue("TextureReplacements", "EnableTextureReplacements", false); si.GetBoolValue("TextureReplacements", "EnableTextureReplacements", false);
texture_replacements.enable_vram_write_replacements = texture_replacements.enable_vram_write_replacements =
si.GetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements", false); si.GetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements", false);
texture_replacements.always_track_uploads = si.GetBoolValue("TextureReplacements", "AlwaysTrackUploads", false);
texture_replacements.preload_textures = si.GetBoolValue("TextureReplacements", "PreloadTextures", false); texture_replacements.preload_textures = si.GetBoolValue("TextureReplacements", "PreloadTextures", false);
texture_replacements.dump_textures = si.GetBoolValue("TextureReplacements", "DumpTextures", false); texture_replacements.dump_textures = si.GetBoolValue("TextureReplacements", "DumpTextures", false);
texture_replacements.dump_replaced_textures = si.GetBoolValue("TextureReplacements", "DumpReplacedTextures", true); texture_replacements.dump_replaced_textures = si.GetBoolValue("TextureReplacements", "DumpReplacedTextures", true);
@ -713,6 +714,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.SetBoolValue("TextureReplacements", "EnableTextureReplacements", texture_replacements.enable_texture_replacements); si.SetBoolValue("TextureReplacements", "EnableTextureReplacements", texture_replacements.enable_texture_replacements);
si.SetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements", si.SetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements",
texture_replacements.enable_vram_write_replacements); texture_replacements.enable_vram_write_replacements);
si.SetBoolValue("TextureReplacements", "AlwaysTrackUploads", texture_replacements.always_track_uploads);
si.SetBoolValue("TextureReplacements", "PreloadTextures", texture_replacements.preload_textures); si.SetBoolValue("TextureReplacements", "PreloadTextures", texture_replacements.preload_textures);
si.SetBoolValue("TextureReplacements", "DumpVRAMWrites", texture_replacements.dump_vram_writes); si.SetBoolValue("TextureReplacements", "DumpVRAMWrites", texture_replacements.dump_vram_writes);
si.SetBoolValue("TextureReplacements", "DumpTextures", texture_replacements.dump_textures); si.SetBoolValue("TextureReplacements", "DumpTextures", texture_replacements.dump_textures);
@ -819,9 +821,9 @@ bool Settings::TextureReplacementSettings::operator==(const TextureReplacementSe
{ {
return (enable_texture_replacements == rhs.enable_texture_replacements && return (enable_texture_replacements == rhs.enable_texture_replacements &&
enable_vram_write_replacements == rhs.enable_vram_write_replacements && enable_vram_write_replacements == rhs.enable_vram_write_replacements &&
preload_textures == rhs.preload_textures && dump_textures == rhs.dump_textures && always_track_uploads == rhs.always_track_uploads && preload_textures == rhs.preload_textures &&
dump_replaced_textures == rhs.dump_replaced_textures && dump_vram_writes == rhs.dump_vram_writes && dump_textures == rhs.dump_textures && dump_replaced_textures == rhs.dump_replaced_textures &&
config == rhs.config); dump_vram_writes == rhs.dump_vram_writes && config == rhs.config);
} }
bool Settings::TextureReplacementSettings::operator!=(const TextureReplacementSettings& rhs) const bool Settings::TextureReplacementSettings::operator!=(const TextureReplacementSettings& rhs) const

View File

@ -192,6 +192,7 @@ struct GPUSettings
bool enable_texture_replacements : 1 = false; bool enable_texture_replacements : 1 = false;
bool enable_vram_write_replacements : 1 = false; bool enable_vram_write_replacements : 1 = false;
bool always_track_uploads : 1 = false;
bool preload_textures : 1 = false; bool preload_textures : 1 = false;
bool dump_textures : 1 = false; bool dump_textures : 1 = false;

View File

@ -4431,6 +4431,8 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
old_settings.texture_replacements.enable_texture_replacements || old_settings.texture_replacements.enable_texture_replacements ||
g_settings.texture_replacements.enable_vram_write_replacements != g_settings.texture_replacements.enable_vram_write_replacements !=
old_settings.texture_replacements.enable_vram_write_replacements || old_settings.texture_replacements.enable_vram_write_replacements ||
g_settings.texture_replacements.always_track_uploads !=
old_settings.texture_replacements.always_track_uploads ||
g_settings.texture_replacements.dump_textures != old_settings.texture_replacements.dump_textures || g_settings.texture_replacements.dump_textures != old_settings.texture_replacements.dump_textures ||
g_settings.texture_replacements.config != old_settings.texture_replacements.config) g_settings.texture_replacements.config != old_settings.texture_replacements.config)
{ {

View File

@ -244,13 +244,13 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
// Texture Replacements Tab // Texture Replacements Tab
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureCache, "GPU", "EnableTextureCache", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureCache, "GPU", "EnableTextureCache", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.useOldMDECRoutines, "Hacks", "UseOldMDECRoutines", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureReplacements, "TextureReplacements",
"EnableTextureReplacements", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.preloadTextureReplacements, "TextureReplacements", SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.preloadTextureReplacements, "TextureReplacements",
"PreloadTextures", false); "PreloadTextures", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureReplacements, "TextureReplacements",
"EnableTextureReplacements", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.alwaysTrackUploads, "TextureReplacements",
"AlwaysTrackUploads", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureDumping, "TextureReplacements", "DumpTextures", SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.enableTextureDumping, "TextureReplacements", "DumpTextures",
false); false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.dumpReplacedTextures, "TextureReplacements", SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.dumpReplacedTextures, "TextureReplacements",
@ -259,6 +259,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
"EnableVRAMWriteReplacements", false); "EnableVRAMWriteReplacements", false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vramWriteDumping, "TextureReplacements", "DumpVRAMWrites", SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vramWriteDumping, "TextureReplacements", "DumpVRAMWrites",
false); false);
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.useOldMDECRoutines, "Hacks", "UseOldMDECRoutines", false);
if (!m_dialog->isPerGameSettings()) if (!m_dialog->isPerGameSettings())
{ {
@ -587,16 +588,20 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
"separate two pairs from each other.</b><br>For example: \"compression_level = 4 : joint_stereo = 1\"")); "separate two pairs from each other.</b><br>For example: \"compression_level = 4 : joint_stereo = 1\""));
// Texture Replacements Tab // Texture Replacements Tab
dialog->registerWidgetHelp(m_ui.enableTextureCache, tr("Enable Texture Cache"), tr("Unchecked"), dialog->registerWidgetHelp(
tr("Enables caching of guest textures, required for texture replacement.")); m_ui.enableTextureCache, tr("Enable Texture Cache"), tr("Unchecked"),
dialog->registerWidgetHelp(m_ui.useOldMDECRoutines, tr("Use Old MDEC Routines"), tr("Unchecked"), tr("Enables caching of guest textures, required for texture replacement. <strong>The texture cache is currently "
tr("Enables the older, less accurate MDEC decoding routines. May be required for old " "experimental, and may cause rendering errors in some games.</strong>"));
"replacement backgrounds to match/load.")); dialog->registerWidgetHelp(m_ui.preloadTextureReplacements, tr("Preload Texture Replacements"), tr("Unchecked"),
tr("Loads all replacement texture to RAM, reducing stuttering at runtime."));
dialog->registerWidgetHelp(m_ui.enableTextureReplacements, tr("Enable Texture Replacements"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.enableTextureReplacements, tr("Enable Texture Replacements"), tr("Unchecked"),
tr("Enables loading of replacement textures. Not compatible with all games.")); tr("Enables loading of replacement textures. Not compatible with all games."));
dialog->registerWidgetHelp(m_ui.preloadTextureReplacements, tr("Preload Texture Replacements"), tr("Unchecked"), dialog->registerWidgetHelp(
tr("Loads all replacement texture to RAM, reducing stuttering at runtime.")); m_ui.alwaysTrackUploads, tr("Always Track Uploads"), tr("Unchecked"),
tr("Forces texture upload tracking to be enabled regardless of whether it is needed. Reduces performance, but "
"allows toggling replacements on and off. <strong>Not required for replacements to load, </strong>normally "
"tracking is automatically enabled when needed."));
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.enableTextureDumping, tr("Enable Texture Dumping"), tr("Unchecked"), m_ui.enableTextureDumping, tr("Enable Texture Dumping"), tr("Unchecked"),
tr("Enables dumping of textures to image files, which can be replaced. Not compatible with all games.")); tr("Enables dumping of textures to image files, which can be replaced. Not compatible with all games."));
@ -607,6 +612,9 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
tr("Enables the replacement of background textures in supported games.")); tr("Enables the replacement of background textures in supported games."));
dialog->registerWidgetHelp(m_ui.vramWriteDumping, tr("Enable VRAM Write Dumping"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.vramWriteDumping, tr("Enable VRAM Write Dumping"), tr("Unchecked"),
tr("Writes backgrounds that can be replaced to the dump directory.")); tr("Writes backgrounds that can be replaced to the dump directory."));
dialog->registerWidgetHelp(m_ui.useOldMDECRoutines, tr("Use Old MDEC Routines"), tr("Unchecked"),
tr("Enables the older, less accurate MDEC decoding routines. May be required for old "
"replacement backgrounds to match/load."));
// Debugging Tab // Debugging Tab
@ -1162,6 +1170,7 @@ void GraphicsSettingsWidget::onEnableTextureCacheChanged()
const bool tc_enabled = m_dialog->getEffectiveBoolValue("GPU", "EnableTextureCache", false); const bool tc_enabled = m_dialog->getEffectiveBoolValue("GPU", "EnableTextureCache", false);
m_ui.enableTextureReplacements->setEnabled(tc_enabled); m_ui.enableTextureReplacements->setEnabled(tc_enabled);
m_ui.enableTextureDumping->setEnabled(tc_enabled); m_ui.enableTextureDumping->setEnabled(tc_enabled);
m_ui.alwaysTrackUploads->setEnabled(tc_enabled);
onEnableTextureDumpingChanged(); onEnableTextureDumpingChanged();
onEnableAnyTextureReplacementsChanged(); onEnableAnyTextureReplacementsChanged();
} }

View File

@ -1089,27 +1089,17 @@
<string>General Settings</string> <string>General Settings</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_9"> <layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="enableTextureCache"> <widget class="QCheckBox" name="enableTextureCache">
<property name="text"> <property name="text">
<string>Enable Texture Cache</string> <string>Enable Texture Cache</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item row="0" column="1">
<widget class="QLabel" name="label_4"> <widget class="QCheckBox" name="preloadTextureReplacements">
<property name="text"> <property name="text">
<string>The texture cache is currently experimental, and may cause rendering errors in some games.</string> <string>Preload Texture Replacements</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="useOldMDECRoutines">
<property name="text">
<string>Use Old MDEC Routines</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1123,22 +1113,8 @@
</property> </property>
<layout class="QFormLayout" name="formLayout_8"> <layout class="QFormLayout" name="formLayout_8">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_6" columnstretch="1,1"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0"> <item row="3" column="1">
<widget class="QCheckBox" name="enableTextureReplacements">
<property name="text">
<string>Enable Texture Replacement</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="preloadTextureReplacements">
<property name="text">
<string>Preload Texture Replacements</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4"/> <layout class="QHBoxLayout" name="horizontalLayout_4"/>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@ -1159,6 +1135,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="0">
<widget class="QCheckBox" name="enableTextureReplacements">
<property name="text">
<string>Enable Texture Replacement</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QCheckBox" name="dumpReplacedTextures"> <widget class="QCheckBox" name="dumpReplacedTextures">
<property name="text"> <property name="text">
@ -1166,6 +1149,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="alwaysTrackUploads">
<property name="text">
<string>Always Track Uploads</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -1186,6 +1176,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="useOldMDECRoutines">
<property name="text">
<string>Use Old MDEC Routines</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QCheckBox" name="vramWriteDumping"> <widget class="QCheckBox" name="vramWriteDumping">
<property name="text"> <property name="text">