diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index e9949d5ac..52519498a 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -4640,21 +4640,23 @@ void FullscreenUI::DrawGraphicsSettingsPage() MenuHeading(FSUI_CSTR("Texture Replacements")); - ActiveButton(FSUI_CSTR("The texture cache is currently experimental, and may cause rendering errors in some games."), - false, false, ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, UIStyle.LargeFont); - + const bool texture_cache_enabled = GetEffectiveBoolSetting(bsi, "GPU", "EnableTextureCache", false); DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_ID_BADGE, "Enable Texture Cache"), FSUI_CSTR("Enables caching of guest textures, required for texture replacement."), "GPU", "EnableTextureCache", false); - DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Use Old MDEC Routines"), - FSUI_CSTR("Enables the older, less accurate MDEC decoding routines. May be required for old " - "replacement backgrounds to match/load."), - "Hacks", "UseOldMDECRoutines", false); + DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TASKS, "Preload Replacement Textures"), + FSUI_CSTR("Loads all replacement texture to RAM, reducing stuttering at runtime."), + "TextureReplacements", "PreloadTextures", 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"), FSUI_CSTR("Enables loading of replacement textures. Not compatible with all games."), "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( 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."), @@ -4667,17 +4669,13 @@ void FullscreenUI::DrawGraphicsSettingsPage() DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_FILE_ALT, "Enable VRAM Write Replacement"), FSUI_CSTR("Enables the replacement of background textures in supported games."), "TextureReplacements", "EnableVRAMWriteReplacements", false); - 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", "DumpVRAMWrites", false); - - DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_TASKS, "Preload Replacement Textures"), - FSUI_CSTR("Loads all replacement texture to RAM, reducing stuttering at runtime."), - "TextureReplacements", "PreloadTextures", false, - ((texture_cache_enabled && - GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableTextureReplacements", false)) || - GetEffectiveBoolSetting(bsi, "TextureReplacements", "EnableVRAMWriteReplacements", false))); + DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Use Old MDEC Routines"), + FSUI_CSTR("Enables the older, less accurate MDEC decoding routines. May be required for old " + "replacement backgrounds to match/load."), + "Hacks", "UseOldMDECRoutines", false); DrawFolderSetting(bsi, FSUI_ICONSTR(ICON_FA_FOLDER, "Textures Directory"), "Folders", "Textures", EmuFolders::Textures); diff --git a/src/core/gpu_hw_texture_cache.cpp b/src/core/gpu_hw_texture_cache.cpp index fe703efbb..987c17fcf 100644 --- a/src/core/gpu_hw_texture_cache.cpp +++ b/src/core/gpu_hw_texture_cache.cpp @@ -564,6 +564,9 @@ bool GPUTextureCache::ShouldTrackVRAMWrites() if (!g_gpu_settings.gpu_texture_cache) return false; + if (g_gpu_settings.texture_replacements.always_track_uploads) + return true; + #ifdef ALWAYS_TRACK_VRAM_WRITES return true; #else @@ -592,20 +595,7 @@ bool GPUTextureCache::Initialize(GPU_HW* backend) void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings) { - if (use_texture_cache) - { - 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"); - } - } + const bool prev_tracking_state = s_state.track_vram_writes; // Reload textures if configuration changes. 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 (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]] 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); } + + UpdateVRAMTrackingState(); + + if (s_state.track_vram_writes != prev_tracking_state) + Invalidate(); } bool GPUTextureCache::GetStateSize(StateWrapper& sw, u32* size) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 976ea804e..14fb34a82 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -438,6 +438,7 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro si.GetBoolValue("TextureReplacements", "EnableTextureReplacements", false); texture_replacements.enable_vram_write_replacements = 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.dump_textures = si.GetBoolValue("TextureReplacements", "DumpTextures", false); 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", "EnableVRAMWriteReplacements", 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", "DumpVRAMWrites", texture_replacements.dump_vram_writes); 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 && enable_vram_write_replacements == rhs.enable_vram_write_replacements && - preload_textures == rhs.preload_textures && dump_textures == rhs.dump_textures && - dump_replaced_textures == rhs.dump_replaced_textures && dump_vram_writes == rhs.dump_vram_writes && - config == rhs.config); + always_track_uploads == rhs.always_track_uploads && preload_textures == rhs.preload_textures && + dump_textures == rhs.dump_textures && dump_replaced_textures == rhs.dump_replaced_textures && + dump_vram_writes == rhs.dump_vram_writes && config == rhs.config); } bool Settings::TextureReplacementSettings::operator!=(const TextureReplacementSettings& rhs) const diff --git a/src/core/settings.h b/src/core/settings.h index 273909a3d..92973c372 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -192,6 +192,7 @@ struct GPUSettings bool enable_texture_replacements : 1 = false; bool enable_vram_write_replacements : 1 = false; + bool always_track_uploads : 1 = false; bool preload_textures : 1 = false; bool dump_textures : 1 = false; diff --git a/src/core/system.cpp b/src/core/system.cpp index 1a76ed665..cbadab190 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -4431,6 +4431,8 @@ void System::CheckForSettingsChanges(const Settings& old_settings) old_settings.texture_replacements.enable_texture_replacements || g_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.config != old_settings.texture_replacements.config) { diff --git a/src/duckstation-qt/graphicssettingswidget.cpp b/src/duckstation-qt/graphicssettingswidget.cpp index 1fbbaa399..cb7375557 100644 --- a/src/duckstation-qt/graphicssettingswidget.cpp +++ b/src/duckstation-qt/graphicssettingswidget.cpp @@ -244,13 +244,13 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* // Texture Replacements Tab 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", "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", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.dumpReplacedTextures, "TextureReplacements", @@ -259,6 +259,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* "EnableVRAMWriteReplacements", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.vramWriteDumping, "TextureReplacements", "DumpVRAMWrites", false); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.useOldMDECRoutines, "Hacks", "UseOldMDECRoutines", false); if (!m_dialog->isPerGameSettings()) { @@ -587,16 +588,20 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* "separate two pairs from each other.
For example: \"compression_level = 4 : joint_stereo = 1\"")); // Texture Replacements Tab - dialog->registerWidgetHelp(m_ui.enableTextureCache, tr("Enable Texture Cache"), tr("Unchecked"), - tr("Enables caching of guest textures, required for texture replacement.")); - 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.")); + dialog->registerWidgetHelp( + m_ui.enableTextureCache, tr("Enable Texture Cache"), tr("Unchecked"), + tr("Enables caching of guest textures, required for texture replacement. The texture cache is currently " + "experimental, and may cause rendering errors in some games.")); + 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"), tr("Enables loading of replacement textures. Not compatible with all games.")); - 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.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. Not required for replacements to load, normally " + "tracking is automatically enabled when needed.")); dialog->registerWidgetHelp( 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.")); @@ -607,6 +612,9 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* tr("Enables the replacement of background textures in supported games.")); dialog->registerWidgetHelp(m_ui.vramWriteDumping, tr("Enable VRAM Write Dumping"), tr("Unchecked"), 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 @@ -1162,6 +1170,7 @@ void GraphicsSettingsWidget::onEnableTextureCacheChanged() const bool tc_enabled = m_dialog->getEffectiveBoolValue("GPU", "EnableTextureCache", false); m_ui.enableTextureReplacements->setEnabled(tc_enabled); m_ui.enableTextureDumping->setEnabled(tc_enabled); + m_ui.alwaysTrackUploads->setEnabled(tc_enabled); onEnableTextureDumpingChanged(); onEnableAnyTextureReplacementsChanged(); } diff --git a/src/duckstation-qt/graphicssettingswidget.ui b/src/duckstation-qt/graphicssettingswidget.ui index 120fb0870..ce1398c09 100644 --- a/src/duckstation-qt/graphicssettingswidget.ui +++ b/src/duckstation-qt/graphicssettingswidget.ui @@ -1089,27 +1089,17 @@ General Settings - + Enable Texture Cache - - + + - The texture cache is currently experimental, and may cause rendering errors in some games. - - - true - - - - - - - Use Old MDEC Routines + Preload Texture Replacements @@ -1123,22 +1113,8 @@ - - - - - Enable Texture Replacement - - - - - - - Preload Texture Replacements - - - - + + @@ -1159,6 +1135,13 @@ + + + + Enable Texture Replacement + + + @@ -1166,6 +1149,13 @@ + + + + Always Track Uploads + + + @@ -1186,6 +1176,13 @@ + + + + Use Old MDEC Routines + + +