mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:29:00 +01:00
Move GraphicsMod out of RenderBase
This commit is contained in:
parent
55d15bdd6e
commit
ca5ec13e13
@ -10,10 +10,15 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/VariantUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionFactory.h"
|
||||
#include "VideoCommon/TextureInfo.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
std::unique_ptr<GraphicsModManager> g_graphics_mod_manager;
|
||||
|
||||
class GraphicsModManager::DecoratedAction final : public GraphicsModAction
|
||||
{
|
||||
@ -64,6 +69,27 @@ private:
|
||||
GraphicsModConfig m_mod;
|
||||
};
|
||||
|
||||
bool GraphicsModManager::Initialize()
|
||||
{
|
||||
if (g_ActiveConfig.bGraphicMods)
|
||||
{
|
||||
// If a config change occurred in a previous session,
|
||||
// remember the old change count value. By setting
|
||||
// our current change count to the old value, we
|
||||
// avoid loading the stale data when we
|
||||
// check for config changes.
|
||||
const u32 old_game_mod_changes = g_ActiveConfig.graphics_mod_config ?
|
||||
g_ActiveConfig.graphics_mod_config->GetChangeCount() :
|
||||
0;
|
||||
g_ActiveConfig.graphics_mod_config = GraphicsModGroupConfig(SConfig::GetInstance().GetGameID());
|
||||
g_ActiveConfig.graphics_mod_config->Load();
|
||||
g_ActiveConfig.graphics_mod_config->SetChangeCount(old_game_mod_changes);
|
||||
g_graphics_mod_manager->Load(*g_ActiveConfig.graphics_mod_config);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<GraphicsModAction*>&
|
||||
GraphicsModManager::GetProjectionActions(ProjectionType projection_type) const
|
||||
{
|
||||
|
@ -19,6 +19,8 @@ class GraphicsModGroupConfig;
|
||||
class GraphicsModManager
|
||||
{
|
||||
public:
|
||||
bool Initialize();
|
||||
|
||||
const std::vector<GraphicsModAction*>& GetProjectionActions(ProjectionType projection_type) const;
|
||||
const std::vector<GraphicsModAction*>&
|
||||
GetProjectionTextureActions(ProjectionType projection_type,
|
||||
@ -52,3 +54,5 @@ private:
|
||||
|
||||
std::unordered_set<std::string> m_groups;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<GraphicsModManager> g_graphics_mod_manager;
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "VideoCommon/FrameDumper.h"
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/FreeLookCamera.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/PerformanceMetrics.h"
|
||||
#include "VideoCommon/PixelEngine.h"
|
||||
@ -74,27 +74,6 @@ Renderer::Renderer()
|
||||
|
||||
Renderer::~Renderer() = default;
|
||||
|
||||
bool Renderer::Initialize()
|
||||
{
|
||||
if (g_ActiveConfig.bGraphicMods)
|
||||
{
|
||||
// If a config change occurred in a previous session,
|
||||
// remember the old change count value. By setting
|
||||
// our current change count to the old value, we
|
||||
// avoid loading the stale data when we
|
||||
// check for config changes.
|
||||
const u32 old_game_mod_changes = g_ActiveConfig.graphics_mod_config ?
|
||||
g_ActiveConfig.graphics_mod_config->GetChangeCount() :
|
||||
0;
|
||||
g_ActiveConfig.graphics_mod_config = GraphicsModGroupConfig(SConfig::GetInstance().GetGameID());
|
||||
g_ActiveConfig.graphics_mod_config->Load();
|
||||
g_ActiveConfig.graphics_mod_config->SetChangeCount(old_game_mod_changes);
|
||||
m_graphics_mod_manager.Load(*g_ActiveConfig.graphics_mod_config);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Renderer::EFBHasAlphaChannel() const
|
||||
{
|
||||
return m_prev_efb_format == PixelFormat::RGBA6_Z24;
|
||||
@ -338,7 +317,7 @@ void Renderer::CheckForConfigChanges()
|
||||
if (g_ActiveConfig.graphics_mod_config &&
|
||||
(old_game_mod_changes != g_ActiveConfig.graphics_mod_config->GetChangeCount()))
|
||||
{
|
||||
m_graphics_mod_manager.Load(*g_ActiveConfig.graphics_mod_config);
|
||||
g_graphics_mod_manager->Load(*g_ActiveConfig.graphics_mod_config);
|
||||
}
|
||||
|
||||
// Update texture cache settings with any changed options.
|
||||
@ -541,7 +520,7 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6
|
||||
|
||||
if (g_ActiveConfig.bGraphicMods)
|
||||
{
|
||||
m_graphics_mod_manager.EndOfFrame();
|
||||
g_graphics_mod_manager->EndOfFrame();
|
||||
}
|
||||
|
||||
g_framebuffer_manager->EndOfFrame();
|
||||
@ -675,8 +654,3 @@ void Renderer::DoState(PointerWrap& p)
|
||||
g_frame_dumper->DoState(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
const GraphicsModManager& Renderer::GetGraphicsModManager() const
|
||||
{
|
||||
return m_graphics_mod_manager;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/RenderState.h"
|
||||
|
||||
class AbstractFramebuffer;
|
||||
@ -66,8 +65,6 @@ public:
|
||||
Renderer();
|
||||
virtual ~Renderer();
|
||||
|
||||
virtual bool Initialize();
|
||||
|
||||
// Ideal internal resolution - multiple of the native EFB resolution
|
||||
int GetTargetWidth() const { return m_target_width; }
|
||||
int GetTargetHeight() const { return m_target_height; }
|
||||
@ -111,8 +108,6 @@ public:
|
||||
// Will forcibly reload all textures on the next swap
|
||||
void ForceReloadTextures();
|
||||
|
||||
const GraphicsModManager& GetGraphicsModManager() const;
|
||||
|
||||
protected:
|
||||
std::tuple<int, int> CalculateTargetScale(int x, int y) const;
|
||||
bool CalculateTargetSize();
|
||||
@ -142,8 +137,6 @@ private:
|
||||
u32 m_last_xfb_height = 0;
|
||||
|
||||
Common::Flag m_force_reload_textures;
|
||||
|
||||
GraphicsModManager m_graphics_mod_manager;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<Renderer> g_renderer;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/HiresTextures.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
#include "VideoCommon/PixelShaderManager.h"
|
||||
@ -1291,7 +1292,7 @@ TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture_info)
|
||||
|
||||
GraphicsModActionData::TextureLoad texture_load{entry->texture_info_name};
|
||||
for (const auto action :
|
||||
g_renderer->GetGraphicsModManager().GetTextureLoadActions(entry->texture_info_name))
|
||||
g_graphics_mod_manager->GetTextureLoadActions(entry->texture_info_name))
|
||||
{
|
||||
action->OnTextureLoad(&texture_load);
|
||||
}
|
||||
@ -2210,7 +2211,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(
|
||||
info.m_texture_format = baseFormat;
|
||||
if (is_xfb_copy)
|
||||
{
|
||||
for (const auto action : g_renderer->GetGraphicsModManager().GetXFBActions(info))
|
||||
for (const auto action : g_graphics_mod_manager->GetXFBActions(info))
|
||||
{
|
||||
action->OnXFB();
|
||||
}
|
||||
@ -2219,7 +2220,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(
|
||||
{
|
||||
bool skip = false;
|
||||
GraphicsModActionData::EFB efb{tex_w, tex_h, &skip, &scaled_tex_w, &scaled_tex_h};
|
||||
for (const auto action : g_renderer->GetGraphicsModManager().GetEFBActions(info))
|
||||
for (const auto action : g_graphics_mod_manager->GetEFBActions(info))
|
||||
{
|
||||
action->OnEFB(&efb);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
@ -556,7 +557,7 @@ void VertexManagerBase::Flush()
|
||||
bool skip = false;
|
||||
GraphicsModActionData::DrawStarted draw_started{&skip};
|
||||
for (const auto action :
|
||||
g_renderer->GetGraphicsModManager().GetDrawStartedActions(texture_name))
|
||||
g_graphics_mod_manager->GetDrawStartedActions(texture_name))
|
||||
{
|
||||
action->OnDrawStarted(&draw_started);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "VideoCommon/CPMemory.h"
|
||||
#include "VideoCommon/FreeLookCamera.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModActionData.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
@ -387,14 +388,14 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
|
||||
if (g_ActiveConfig.bGraphicMods)
|
||||
{
|
||||
for (const auto action :
|
||||
g_renderer->GetGraphicsModManager().GetProjectionActions(xfmem.projection.type))
|
||||
g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type))
|
||||
{
|
||||
projection_actions.push_back(action);
|
||||
}
|
||||
|
||||
for (const auto& texture : textures)
|
||||
{
|
||||
for (const auto action : g_renderer->GetGraphicsModManager().GetProjectionTextureActions(
|
||||
for (const auto action : g_graphics_mod_manager->GetProjectionTextureActions(
|
||||
xfmem.projection.type, texture))
|
||||
{
|
||||
projection_actions.push_back(action);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "VideoCommon/FrameDumper.h"
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
#include "VideoCommon/PixelEngine.h"
|
||||
@ -357,6 +358,7 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
g_frame_dumper = std::make_unique<FrameDumper>();
|
||||
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
||||
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
|
||||
g_graphics_mod_manager = std::make_unique<GraphicsModManager>();
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& command_processor = system.GetCommandProcessor();
|
||||
@ -371,9 +373,9 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
TMEM::Init();
|
||||
|
||||
if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() ||
|
||||
!g_perf_query->Initialize() || !g_renderer->Initialize() ||
|
||||
!g_presenter->Initialize() || !g_framebuffer_manager->Initialize() ||
|
||||
!g_texture_cache->Initialize() || !g_bounding_box->Initialize())
|
||||
!g_perf_query->Initialize() || !g_presenter->Initialize() ||
|
||||
!g_framebuffer_manager->Initialize() || !g_texture_cache->Initialize() ||
|
||||
!g_bounding_box->Initialize() || !g_graphics_mod_manager->Initialize())
|
||||
{
|
||||
PanicAlertFmtT("Failed to initialize renderer classes");
|
||||
Shutdown();
|
||||
|
Loading…
x
Reference in New Issue
Block a user