Merge pull request #11225 from iwubcode/graphics-mod-textureload-callable

VideoCommon: call texture load graphics mod hook when textures are loaded
This commit is contained in:
Admiral H. Curtiss 2022-11-06 18:58:51 +01:00 committed by GitHub
commit c931529e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 11 deletions

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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() {}
};

View File

@ -3,6 +3,8 @@
#pragma once
#include <string_view>
#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

View File

@ -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<GraphicsModAction*>&
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();
}

View File

@ -46,7 +46,7 @@ private:
std::unordered_map<std::string, std::vector<GraphicsModAction*>>
m_projection_texture_target_to_actions;
std::unordered_map<std::string, std::vector<GraphicsModAction*>> m_draw_started_target_to_actions;
std::unordered_map<std::string, std::vector<GraphicsModAction*>> m_load_target_to_actions;
std::unordered_map<std::string, std::vector<GraphicsModAction*>> m_load_texture_target_to_actions;
std::unordered_map<FBInfo, std::vector<GraphicsModAction*>, FBInfoHasher> m_efb_target_to_actions;
std::unordered_map<FBInfo, std::vector<GraphicsModAction*>, FBInfoHasher> m_xfb_target_to_actions;

View File

@ -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;