MQEngine
载入中...
搜索中...
未找到
RenderGraphViewer.h
浏览该文件的文档.
1#pragma once
2#include <boost/archive/text_oarchive.hpp>
3#include <boost/archive/text_iarchive.hpp>
4#include <boost/serialization/map.hpp>
5#include <boost/serialization/unordered_map.hpp>
6#include <boost/serialization/vector.hpp>
7#include <boost/serialization/string.hpp>
8#include <boost/serialization/array.hpp>
9#include <imgui.h>
10#include <imnodes.h>
11#include <vector>
12#include <string>
13#include <cstring>
14#include <functional>
15#include <map>
16#include <set>
17#include "../Thirdparty/thirdparty.h"
18namespace FCT
19{
20 struct PassDesc;
21 class Context;
22}
23
24namespace MQEngine {
26 {
27 bool enabled = false;
28 bool isWindow = false;
29 bool useCustomFormat = false;
30 std::string format = "RGBA8";
31 bool useCustomSize = false;
32 int customWidth = 1920;
33 int customHeight = 1080;
34 template<class Archive>
35 void serialize(Archive & ar, const unsigned int version)
36 {
38 ar & isWindow;
39 }
40 };
42 {
43 template<class Archive>
44 void serialize(Archive & ar, const unsigned int version)
45 {
46 }
47 };
49 {
50 bool enabled = false;
51 bool isWindow = false;
52 bool useCustomFormat = false;
53 std::string format = "D32_SFLOAT";
54 bool useCustomSize = false;
55 int customWidth = 1920;
56 int customHeight = 1080;
57 template<class Archive>
58 void serialize(Archive & ar, const unsigned int version)
59 {
61 ar & isWindow;
62 }
63 };
64 struct PassNode
65 {
66 uint32_t id;
67 std::string name;
68 bool hasLinkTarget[9] = {};
69 bool hasLinkDepthStencil = false;
72 std::map<uint32_t, TextureDesc> texturesDesc;
73 bool enableClear = false;
74 bool enableClearTarget = false;
75 bool enableClearDepth = false;
76 bool enableClearStencil = false;
77 float clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
78 float clearDepth = 1.0f;
79 int clearStencil = 0;
80 std::vector<int> texturePins;
81 //std::set<int> texturePins;
82 size_t texturePinIndex = 0;
83 void removeTexturePin(int pinId) {
84 auto it = std::find(texturePins.begin(), texturePins.end(), pinId);
85 if (it != texturePins.end()) {
86 texturePins.erase(it);
87 }
88 }
89 template<class Archive>
97 int lastTexturePinId() const
98 {
99 return texturePins.back();
100 }
101 int targetPinId(int index) const;
102 int depthStencilPinId();
103 };
104
106 {
107 uint32_t id;
108 std::string name;
109 template<class Archive>
110 void serialize(Archive & ar, const unsigned int version)
111 {
112 ar & id & name;
113 }
114 int texturePinId();
115 int targetPinId();
116 int depthStencilPinId();
117 };
118 struct PinInfo
119 {
120 uint32_t nodeId;
121 std::string pinType;
122 int index;
123 template<class Archive>
124 void serialize(Archive & ar, const unsigned int version)
125 {
126 ar & nodeId & pinType & index;
127 }
128 };
129 struct LinkInfo
130 {
131 int id;
134 template<class Archive>
135 void serialize(Archive & ar, const unsigned int version)
136 {
137 ar & id & startPinId & endPinId;
138 }
139 };
140
142 public:
147 void addTextureLink(int imageId, int passId);
148 void addTargetLink(int passId, int index,int imageId);
149 void addDepthStencilLink(int passId,int imageId);
155 int newPassNode(const std::string& name = "Pass");
161 int newImageNode(const std::string& name = "Image");
166 void createGraphFromPassDescs(const std::vector<FCT::PassDesc>& passDescs);
167
172 std::vector<FCT::PassDesc> convertCurrentGraphToPassDescs();
173
184 int findImageNode(const std::string& name);
185 int findPassNode(const std::string& name);
187 public:
188 RenderGraphViewer(FCT::Context* ctx,FCT::Window* wnd);
189 void removePassPin(int pinHash);
190 void removeImagePin(int pinHash);
191 void render();
196 void newTexturePin(PassNode& pass);
201 void saveToFile(const std::string& filename);
206 std::string generatorCode();
212 std::string generatePassCode(const PassNode& pass);
213 private:
214 void autoLayoutGraph();
215
221 void addLink(int startHash,int endHash);
222 void addPassNode(const PassNode& passNode);
231 void deleteNode(int contextMenuNodeId);
232 void deletePass(int contextMenuNodeId);
233 void deleteImage(int contextMenuNodeId);
234 size_t m_nextNodeId = 0;
235 size_t m_linkId = 0;
236
237 std::map<int,LinkInfo> m_passOutputlinks;
238 std::map<int,LinkInfo> m_passInputLinks;
239 std::map<int,PassNode> m_passes;
240 std::map<int,ImageNode> m_images;
241 std::unordered_map<int,PinInfo> m_pinInfoMap;
242 void loadFromFile(const std::string& filename);
243 void renderPassNode(PassNode& pass);
244 void renderImageNode(ImageNode& image);
245 int generatePinId(int nodeId, const std::string& pinType, int index = 0);
246 int getNextNodeId() { return ++m_nextNodeId; }
247 int getNextLinkId() { return ++m_linkId; }
249 template<class Archive>
250 void serialize(Archive & ar, const unsigned int version)
251 {
252 ar & m_nextNodeId & m_linkId;
255 }
257 std::string m_generatedCode;
258 FCT::Context* m_ctx;
259 FCT::Window* m_wnd;
260 };
261
262}
std::vector< FCT::PassDesc > convertCurrentGraphToPassDescs()
将当前图表转换为PassDesc数组
定义 RenderGraphViewer.cpp:1388
void render()
定义 RenderGraphViewer.cpp:166
void loadFromFile(const std::string &filename)
定义 RenderGraphViewer.cpp:901
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:250
int findPassNode(const std::string &name)
定义 RenderGraphViewer.cpp:489
void renderPassNode(PassNode &pass)
定义 RenderGraphViewer.cpp:945
RenderGraphViewer(FCT::Context *ctx, FCT::Window *wnd)
定义 RenderGraphViewer.cpp:497
void autoLayoutGraph()
定义 RenderGraphViewer.cpp:1239
std::unordered_map< int, PinInfo > m_pinInfoMap
定义 RenderGraphViewer.h:241
void addTargetLink(int passId, int index, int imageId)
定义 RenderGraphViewer.cpp:514
int newImageNode(const std::string &name="Image")
创建一个新的Image节点
定义 RenderGraphViewer.cpp:465
void addDepthStencilLink(int passId, int imageId)
定义 RenderGraphViewer.cpp:524
void addPassNode(const PassNode &passNode)
std::string generatorCode()
定义 RenderGraphViewer.cpp:889
FCT::Context * m_ctx
定义 RenderGraphViewer.h:258
int generatePinId(int nodeId, const std::string &pinType, int index=0)
定义 RenderGraphViewer.cpp:1222
void removeImagePin(int pinHash)
定义 RenderGraphViewer.cpp:104
int newPassNode(const std::string &name="Pass")
创建一个新的Pass
定义 RenderGraphViewer.cpp:440
void deletePass(int contextMenuNodeId)
定义 RenderGraphViewer.cpp:88
std::string generatePassCode(const PassNode &pass)
生成指定pass的代码
定义 RenderGraphViewer.cpp:734
void deleteNode(int contextMenuNodeId)
将图表保存到文件中
定义 RenderGraphViewer.cpp:153
std::string m_generatedCode
定义 RenderGraphViewer.h:257
void removePassPin(int pinHash)
不会从pass里删除自己
定义 RenderGraphViewer.cpp:76
void createGraphFromPassDescs(const std::vector< FCT::PassDesc > &passDescs)
从PassDesc创建图表
定义 RenderGraphViewer.cpp:532
FCT::Window * m_wnd
定义 RenderGraphViewer.h:259
std::map< int, LinkInfo > m_passInputLinks
定义 RenderGraphViewer.h:238
void addTextureLink(int imageId, int passId)
定义 RenderGraphViewer.cpp:504
void saveToFile(const std::string &filename)
定义 RenderGraphViewer.cpp:695
std::map< int, ImageNode > m_images
定义 RenderGraphViewer.h:240
int m_contextMenuNodeId
定义 RenderGraphViewer.h:248
void addLink(int startHash, int endHash)
添加一个 链接,从指定的pin hash 到指定的 pin hash
定义 RenderGraphViewer.cpp:408
void deleteImage(int contextMenuNodeId)
定义 RenderGraphViewer.cpp:140
int getNextLinkId()
定义 RenderGraphViewer.h:247
std::map< int, LinkInfo > m_passOutputlinks
定义 RenderGraphViewer.h:237
size_t m_linkId
定义 RenderGraphViewer.h:235
std::map< int, PassNode > m_passes
定义 RenderGraphViewer.h:239
friend class boost::serialization::access
定义 RenderGraphViewer.h:256
int findImageNode(const std::string &name)
找一个Image节点
定义 RenderGraphViewer.cpp:479
void renderImageNode(ImageNode &image)
定义 RenderGraphViewer.cpp:1170
size_t m_nextNodeId
定义 RenderGraphViewer.h:234
void newTexturePin(PassNode &pass)
定义 RenderGraphViewer.cpp:459
int getNextNodeId()
定义 RenderGraphViewer.h:246
定义 engine.cpp:11
定义 application.h:5
FCT::Context Context
定义 EngineGlobal.h:14
定义 RenderGraphViewer.h:49
bool useCustomSize
定义 RenderGraphViewer.h:54
int customWidth
定义 RenderGraphViewer.h:55
bool useCustomFormat
定义 RenderGraphViewer.h:52
bool isWindow
定义 RenderGraphViewer.h:51
std::string format
定义 RenderGraphViewer.h:53
bool enabled
定义 RenderGraphViewer.h:50
int customHeight
定义 RenderGraphViewer.h:56
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:58
定义 RenderGraphViewer.h:106
int depthStencilPinId()
定义 NodeTutorials.cpp:41
std::string name
定义 RenderGraphViewer.h:108
uint32_t id
定义 RenderGraphViewer.h:107
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:110
int texturePinId()
定义 NodeTutorials.cpp:31
int targetPinId()
定义 NodeTutorials.cpp:36
定义 RenderGraphViewer.h:65
int targetPinId(int index) const
定义 NodeTutorials.cpp:21
bool hasLinkDepthStencil
定义 RenderGraphViewer.h:69
bool enableClearStencil
定义 RenderGraphViewer.h:76
bool enableClearTarget
定义 RenderGraphViewer.h:74
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:90
bool enableClear
定义 RenderGraphViewer.h:73
float clearColor[4]
定义 RenderGraphViewer.h:77
PassTargetDesc targetDesc[9]
定义 RenderGraphViewer.h:70
size_t texturePinIndex
定义 RenderGraphViewer.h:82
void removeTexturePin(int pinId)
定义 RenderGraphViewer.h:83
bool hasLinkTarget[9]
定义 RenderGraphViewer.h:68
bool enableClearDepth
定义 RenderGraphViewer.h:75
float clearDepth
定义 RenderGraphViewer.h:78
int lastTexturePinId() const
定义 RenderGraphViewer.h:97
DepthStencilDesc depthStencilDesc
定义 RenderGraphViewer.h:71
std::vector< int > texturePins
定义 RenderGraphViewer.h:80
std::string name
定义 RenderGraphViewer.h:67
uint32_t id
定义 RenderGraphViewer.h:66
std::map< uint32_t, TextureDesc > texturesDesc
定义 RenderGraphViewer.h:72
int depthStencilPinId()
定义 NodeTutorials.cpp:26
int clearStencil
定义 RenderGraphViewer.h:79
定义 RenderGraphViewer.h:26
int customHeight
定义 RenderGraphViewer.h:33
bool enabled
定义 RenderGraphViewer.h:27
int customWidth
定义 RenderGraphViewer.h:32
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:35
std::string format
定义 RenderGraphViewer.h:30
bool useCustomSize
定义 RenderGraphViewer.h:31
bool useCustomFormat
定义 RenderGraphViewer.h:29
bool isWindow
定义 RenderGraphViewer.h:28
定义 RenderGraphViewer.h:119
int index
定义 RenderGraphViewer.h:122
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:124
std::string pinType
定义 RenderGraphViewer.h:121
uint32_t nodeId
定义 RenderGraphViewer.h:120
定义 RenderGraphViewer.h:42
void serialize(Archive &ar, const unsigned int version)
定义 RenderGraphViewer.h:44