diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp index e131b4ee1e..1bd288512c 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.cpp @@ -35,7 +35,10 @@ void PrintAction::OnProjectionAndTexture(GraphicsModActionData::Projection*) INFO_LOG_FMT(VIDEO, "OnProjectionAndTexture Called"); } -void PrintAction::OnTextureLoad() +void PrintAction::OnTextureLoad(GraphicsModActionData::TextureLoad* texture_load) { - INFO_LOG_FMT(VIDEO, "OnTextureLoad Called"); + if (!texture_load) [[unlikely]] + return; + + INFO_LOG_FMT(VIDEO, "OnTextureLoad Called. Texture: {}", texture_load->texture_name); } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h index 6474eeb5f0..73a8103ad4 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/Actions/PrintAction.h @@ -12,5 +12,5 @@ public: void OnEFB(GraphicsModActionData::EFB*) override; void OnProjection(GraphicsModActionData::Projection*) override; void OnProjectionAndTexture(GraphicsModActionData::Projection*) override; - void OnTextureLoad() override; + void OnTextureLoad(GraphicsModActionData::TextureLoad*) override; }; diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h index c8ef469190..a7b366122d 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h @@ -20,6 +20,6 @@ public: virtual void OnXFB() {} virtual void OnProjection(GraphicsModActionData::Projection*) {} virtual void OnProjectionAndTexture(GraphicsModActionData::Projection*) {} - virtual void OnTextureLoad() {} + virtual void OnTextureLoad(GraphicsModActionData::TextureLoad*) {} virtual void OnFrameEnd() {} }; diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h index c073adc445..14f2e3a9b3 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h @@ -3,6 +3,8 @@ #pragma once +#include + #include "Common/CommonTypes.h" #include "Common/Matrix.h" @@ -26,4 +28,8 @@ struct Projection { Common::Matrix44* matrix; }; +struct TextureLoad +{ + std::string_view texture_name; +}; } // namespace GraphicsModActionData diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp index db978646ae..7441f210fa 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp @@ -46,11 +46,11 @@ public: return; m_action_impl->OnProjectionAndTexture(projection); } - void OnTextureLoad() override + void OnTextureLoad(GraphicsModActionData::TextureLoad* texture_load) override { if (!m_mod.m_enabled) return; - m_action_impl->OnTextureLoad(); + m_action_impl->OnTextureLoad(texture_load); } void OnFrameEnd() override { @@ -105,8 +105,8 @@ GraphicsModManager::GetDrawStartedActions(const std::string& texture_name) const const std::vector& GraphicsModManager::GetTextureLoadActions(const std::string& texture_name) const { - if (const auto it = m_load_target_to_actions.find(texture_name); - it != m_load_target_to_actions.end()) + if (const auto it = m_load_texture_target_to_actions.find(texture_name); + it != m_load_texture_target_to_actions.end()) { return it->second; } @@ -196,7 +196,7 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config) m_actions.back().get()); }, [&](const LoadTextureTarget& the_target) { - m_load_target_to_actions[the_target.m_texture_info_string].push_back( + m_load_texture_target_to_actions[the_target.m_texture_info_string].push_back( m_actions.back().get()); }, [&](const EFBTarget& the_target) { @@ -272,7 +272,7 @@ void GraphicsModManager::Reset() m_projection_target_to_actions.clear(); m_projection_texture_target_to_actions.clear(); m_draw_started_target_to_actions.clear(); - m_load_target_to_actions.clear(); + m_load_texture_target_to_actions.clear(); m_efb_target_to_actions.clear(); m_xfb_target_to_actions.clear(); } diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h index 5151b85dbd..1775e3b0e3 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h @@ -46,7 +46,7 @@ private: std::unordered_map> m_projection_texture_target_to_actions; std::unordered_map> m_draw_started_target_to_actions; - std::unordered_map> m_load_target_to_actions; + std::unordered_map> m_load_texture_target_to_actions; std::unordered_map, FBInfoHasher> m_efb_target_to_actions; std::unordered_map, FBInfoHasher> m_xfb_target_to_actions; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index a90efd15be..29f972a67b 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1243,6 +1243,13 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture if (entry->texture_info_name.empty() && g_ActiveConfig.bGraphicMods) { entry->texture_info_name = texture_info.CalculateTextureName().GetFullName(); + + GraphicsModActionData::TextureLoad texture_load{entry->texture_info_name}; + for (const auto action : + g_renderer->GetGraphicsModManager().GetTextureLoadActions(entry->texture_info_name)) + { + action->OnTextureLoad(&texture_load); + } } bound_textures[texture_info.GetStage()] = entry;