MQEngine
载入中...
搜索中...
未找到
PassGenerator.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
18namespace FCT
19{
20 class Context;
21}
22
23namespace MQEngine {
24
26 {
27 bool enabled = false;
28 bool useCustomFormat = false;
29 std::string format = "RGBA8";
30 bool useCustomSize = false;
31 int customWidth = 1920;
32 int customHeight = 1080;
33 template<class Archive>
34 void serialize(Archive & ar, const unsigned int version)
35 {
37 }
38 };
40 {
41 template<class Archive>
42 void serialize(Archive & ar, const unsigned int version)
43 {
44 }
45 };
47 {
48 bool enabled = false;
49 bool useCustomFormat = false;
50 std::string format = "D32_SFLOAT";
51 bool useCustomSize = false;
52 int customWidth = 1920;
53 int customHeight = 1080;
54 template<class Archive>
55 void serialize(Archive & ar, const unsigned int version)
56 {
58 }
59 };
60 struct PassNode
61 {
62 uint32_t id;
63 std::string name;
64 bool hasLinkTarget[9] = {};
65 bool hasLinkDepthStencil = false;
68 std::map<uint32_t, TextureDesc> texturesDesc;
69 bool enableClear = false;
70 bool enableClearTarget = false;
71 bool enableClearDepth = false;
72 bool enableClearStencil = false;
73 float clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
74 float clearDepth = 1.0f;
75 int clearStencil = 0;
76 std::vector<int> texturePins;
77 //std::set<int> texturePins;
78 size_t texturePinIndex = 0;
79 void removeTexturePin(int pinId) {
80 auto it = std::find(texturePins.begin(), texturePins.end(), pinId);
81 if (it != texturePins.end()) {
82 texturePins.erase(it);
83 }
84 }
85 template<class Archive>
92
93 };
94 struct ImageNode
95 {
96 uint32_t id;
97 std::string name;
98 template<class Archive>
99 void serialize(Archive & ar, const unsigned int version)
100 {
101 ar & id & name;
102 }
103 };
104 struct PinInfo
105 {
106 uint32_t nodeId;
107 std::string pinType;
108 int index;
109 template<class Archive>
110 void serialize(Archive & ar, const unsigned int version)
111 {
112 ar & nodeId & pinType & index;
113 }
114 };
115 struct LinkInfo
116 {
117 int id;
120 template<class Archive>
121 void serialize(Archive & ar, const unsigned int version)
122 {
123 ar & id & startPinId & endPinId;
124 }
125 };
126
128 public:
129 PassGenerator(FCT::Context* ctx);
130 void removePassPin(int pinHash);
131 void removeImagePin(int pinHash);
132 void render();
137 void newTexturePin(PassNode& pass);
142 void saveToFile(const std::string& filename);
147 std::string generatorCode();
153 std::string generatePassCode(const PassNode& pass);
154 private:
160 void addLink(int startHash,int endHash);
165 void addPassNode(const std::string& name = "Pass");
170 void newImageNode(const std::string& name = "Image");
179 void deleteNode(int contextMenuNodeId);
180 void deletePass(int contextMenuNodeId);
181 void deleteImage(int contextMenuNodeId);
182 size_t m_nextNodeId = 0;
183 size_t m_linkId = 0;
184
185 std::map<int,LinkInfo> m_passOutputlinks;
186 std::map<int,LinkInfo> m_passInputLinks;
187 std::map<int,PassNode> m_passes;
188 std::map<int,ImageNode> m_images;
189 std::unordered_map<int,PinInfo> m_pinInfoMap;
190 void loadFromFile(const std::string& filename);
191 void renderPassNode(PassNode& pass);
192 void renderImageNode(ImageNode& image);
193 int generatePinId(int nodeId, const std::string& pinType, int index = 0);
194 int getNextNodeId() { return ++m_nextNodeId; }
195 int getNextLinkId() { return ++m_linkId; }
197 template<class Archive>
198 void serialize(Archive & ar, const unsigned int version)
199 {
200 ar & m_nextNodeId & m_linkId;
203 }
205 std::string m_generatedCode;
206 FCT::Context* m_ctx;
207 };
208
209}
int m_contextMenuNodeId
定义 PassGenerator.h:196
void saveToFile(const std::string &filename)
定义 PassGenerator.cpp:413
int generatePinId(int nodeId, const std::string &pinType, int index=0)
定义 PassGenerator.cpp:902
void addLink(int startHash, int endHash)
添加一个 链接,从指定的pin hash 到指定的 pin hash
定义 PassGenerator.cpp:355
std::string m_generatedCode
定义 PassGenerator.h:205
void deletePass(int contextMenuNodeId)
定义 PassGenerator.cpp:94
void addPassNode(const std::string &name="Pass")
创建一下新的Pass 节点
定义 PassGenerator.cpp:387
int getNextLinkId()
定义 PassGenerator.h:195
std::unordered_map< int, PinInfo > m_pinInfoMap
定义 PassGenerator.h:189
void renderImageNode(ImageNode &image)
定义 PassGenerator.cpp:850
void newTexturePin(PassNode &pass)
定义 PassGenerator.cpp:400
void deleteImage(int contextMenuNodeId)
定义 PassGenerator.cpp:146
void removePassPin(int pinHash)
不会从pass里删除自己
定义 PassGenerator.cpp:82
std::map< int, PassNode > m_passes
定义 PassGenerator.h:187
std::map< int, LinkInfo > m_passInputLinks
定义 PassGenerator.h:186
void loadFromFile(const std::string &filename)
定义 PassGenerator.cpp:619
std::string generatorCode()
定义 PassGenerator.cpp:607
std::string generatePassCode(const PassNode &pass)
生成指定pass的代码
定义 PassGenerator.cpp:452
void newImageNode(const std::string &name="Image")
创建一个新的Image节点
定义 PassGenerator.cpp:405
void render()
定义 PassGenerator.cpp:172
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:198
void removeImagePin(int pinHash)
定义 PassGenerator.cpp:110
void deleteNode(int contextMenuNodeId)
将图表保存到文件中
定义 PassGenerator.cpp:159
size_t m_linkId
定义 PassGenerator.h:183
friend class boost::serialization::access
定义 PassGenerator.h:204
std::map< int, ImageNode > m_images
定义 PassGenerator.h:188
int getNextNodeId()
定义 PassGenerator.h:194
size_t m_nextNodeId
定义 PassGenerator.h:182
std::map< int, LinkInfo > m_passOutputlinks
定义 PassGenerator.h:185
PassGenerator(FCT::Context *ctx)
定义 PassGenerator.cpp:73
void renderPassNode(PassNode &pass)
定义 PassGenerator.cpp:663
FCT::Context * m_ctx
定义 PassGenerator.h:206
定义 engine.h:12
定义 application.h:3
定义 PassGenerator.h:47
bool useCustomSize
定义 PassGenerator.h:51
int customWidth
定义 PassGenerator.h:52
bool useCustomFormat
定义 PassGenerator.h:49
std::string format
定义 PassGenerator.h:50
bool enabled
定义 PassGenerator.h:48
int customHeight
定义 PassGenerator.h:53
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:55
定义 PassGenerator.h:95
std::string name
定义 PassGenerator.h:97
uint32_t id
定义 PassGenerator.h:96
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:99
定义 PassGenerator.h:61
bool hasLinkDepthStencil
定义 PassGenerator.h:65
bool enableClearStencil
定义 PassGenerator.h:72
bool enableClearTarget
定义 PassGenerator.h:70
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:86
bool enableClear
定义 PassGenerator.h:69
float clearColor[4]
定义 PassGenerator.h:73
PassTargetDesc targetDesc[9]
定义 PassGenerator.h:66
size_t texturePinIndex
定义 PassGenerator.h:78
void removeTexturePin(int pinId)
定义 PassGenerator.h:79
bool hasLinkTarget[9]
定义 PassGenerator.h:64
bool enableClearDepth
定义 PassGenerator.h:71
float clearDepth
定义 PassGenerator.h:74
DepthStencilDesc depthStencilDesc
定义 PassGenerator.h:67
std::vector< int > texturePins
定义 PassGenerator.h:76
std::string name
定义 PassGenerator.h:63
uint32_t id
定义 PassGenerator.h:62
std::map< uint32_t, TextureDesc > texturesDesc
定义 PassGenerator.h:68
int clearStencil
定义 PassGenerator.h:75
定义 PassGenerator.h:26
int customHeight
定义 PassGenerator.h:32
bool enabled
定义 PassGenerator.h:27
int customWidth
定义 PassGenerator.h:31
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:34
std::string format
定义 PassGenerator.h:29
bool useCustomSize
定义 PassGenerator.h:30
bool useCustomFormat
定义 PassGenerator.h:28
定义 PassGenerator.h:105
int index
定义 PassGenerator.h:108
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:110
std::string pinType
定义 PassGenerator.h:107
uint32_t nodeId
定义 PassGenerator.h:106
定义 PassGenerator.h:40
void serialize(Archive &ar, const unsigned int version)
定义 PassGenerator.h:42