mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
VideoCommon: call texture load graphics mod hook when Dolphin loads a texture
This commit is contained in:
parent
8efd7833e5
commit
ea3e133200
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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() {}
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user