summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h
blob: 98c121fc5ea4109db26d36e79195eb60f6af4dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2022 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <list>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include "Common/HookableEvent.h"

#include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h"
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
#include "VideoCommon/XFMemory.h"

class GraphicsModGroupConfig;
class GraphicsModManager
{
public:
  bool Initialize();

  const std::vector<GraphicsModAction*>& GetProjectionActions(ProjectionType projection_type) const;
  const std::vector<GraphicsModAction*>&
  GetProjectionTextureActions(ProjectionType projection_type,
                              const std::string& texture_name) const;
  const std::vector<GraphicsModAction*>&
  GetDrawStartedActions(const std::string& texture_name) const;
  const std::vector<GraphicsModAction*>&
  GetTextureLoadActions(const std::string& texture_name) const;
  const std::vector<GraphicsModAction*>&
  GetTextureCreateActions(const std::string& texture_name) const;
  const std::vector<GraphicsModAction*>& GetEFBActions(const FBInfo& efb) const;
  const std::vector<GraphicsModAction*>& GetXFBActions(const FBInfo& xfb) const;

  void Load(const GraphicsModGroupConfig& config);

private:
  void EndOfFrame();
  void Reset();

  class DecoratedAction;

  static inline const std::vector<GraphicsModAction*> m_default = {};
  std::list<std::unique_ptr<GraphicsModAction>> m_actions;
  std::unordered_map<ProjectionType, std::vector<GraphicsModAction*>>
      m_projection_target_to_actions;
  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_texture_target_to_actions;
  std::unordered_map<std::string, std::vector<GraphicsModAction*>>
      m_create_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;

  std::unordered_set<std::string> m_groups;

  Common::EventHook m_end_of_frame_event;
};

extern std::unique_ptr<GraphicsModManager> g_graphics_mod_manager;