summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2023-01-30 05:01:05 +1300
committerScott Mansell <phiren@gmail.com>2023-01-31 19:41:24 +1300
commitca5ec13e138d60d2fbac114450527c654caed702 (patch)
tree6451afd8815b451f31aa058ab3a5c1cd4078c19b /Source/Core
parent55d15bdd6ea04c0f0862a1a23dc4859b3e30ad64 (diff)
Move GraphicsMod out of RenderBase
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp26
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h4
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp32
-rw-r--r--Source/Core/VideoCommon/RenderBase.h7
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp7
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp3
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp5
-rw-r--r--Source/Core/VideoCommon/VideoBackendBase.cpp8
8 files changed, 47 insertions, 45 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp
index 7441f210fa..4b5f5dbd84 100644
--- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.cpp
@@ -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
{
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h
index 1775e3b0e3..035ee48a36 100644
--- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h
@@ -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;
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 89e84d2d6e..942006a07f 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -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;
-}
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index 2a154c4f30..c605177b00 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -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;
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index e991669950..21b58d931e 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -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);
}
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 71e766c000..959b080510 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -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);
}
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index deda07fd65..3779051b6b 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -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);
diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp
index 144c215ad9..31bacc804c 100644
--- a/Source/Core/VideoCommon/VideoBackendBase.cpp
+++ b/Source/Core/VideoCommon/VideoBackendBase.cpp
@@ -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();