Skip to content

Commit 75a6ae1

Browse files
committed
更新稳定等
1 parent 7f9959f commit 75a6ae1

5 files changed

Lines changed: 140 additions & 10 deletions

File tree

‎src/Base/Flags.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace FCT
5555
Flags<BitType> & operator&=(Flags<BitType> const & rhs) noexcept { m_mask &= rhs.m_mask; return *this; }
5656
Flags<BitType> & operator^=(Flags<BitType> const & rhs) noexcept { m_mask ^= rhs.m_mask; return *this; }
5757

58-
explicit constexpr operator bool() const noexcept { return !!m_mask; }
58+
constexpr operator bool() const noexcept { return !!m_mask; }
5959
explicit constexpr operator MaskType() const noexcept { return m_mask; }
6060

6161

‎src/Context/Format.h‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,100 @@ namespace FCT {
5656
D32_SFLOAT,
5757
D32_SFLOAT_S8_UINT
5858
};
59+
constexpr const char* FormatToString(Format format) noexcept {
60+
switch (format) {
61+
case Format::UNDEFINED:
62+
return "UNDEFINED";
63+
case Format::R8_UNORM:
64+
return "R8_UNORM";
65+
case Format::R8G8_UNORM:
66+
return "R8G8_UNORM";
67+
case Format::R8G8B8_UNORM:
68+
return "R8G8B8_UNORM";
69+
case Format::R8G8B8A8_UNORM:
70+
return "R8G8B8A8_UNORM";
71+
case Format::B8G8R8A8_UNORM:
72+
return "B8G8R8A8_UNORM";
73+
case Format::R8G8B8A8_SRGB:
74+
return "R8G8B8A8_SRGB";
75+
case Format::B8G8R8A8_SRGB:
76+
return "B8G8R8A8_SRGB";
77+
case Format::R16_SFLOAT:
78+
return "R16_SFLOAT";
79+
case Format::R16G16_SFLOAT:
80+
return "R16G16_SFLOAT";
81+
case Format::R16G16B16A16_SFLOAT:
82+
return "R16G16B16A16_SFLOAT";
83+
case Format::R8_SINT:
84+
return "R8_SINT";
85+
case Format::R8G8_SINT:
86+
return "R8G8_SINT";
87+
case Format::R8G8B8_SINT:
88+
return "R8G8B8_SINT";
89+
case Format::R8G8B8A8_SINT:
90+
return "R8G8B8A8_SINT";
91+
case Format::R16_SINT:
92+
return "R16_SINT";
93+
case Format::R16G16_SINT:
94+
return "R16G16_SINT";
95+
case Format::R16G16B16_SINT:
96+
return "R16G16B16_SINT";
97+
case Format::R16G16B16A16_SINT:
98+
return "R16G16B16A16_SINT";
99+
case Format::R32_SINT:
100+
return "R32_SINT";
101+
case Format::R32G32_SINT:
102+
return "R32G32_SINT";
103+
case Format::R32G32B32_SINT:
104+
return "R32G32B32_SINT";
105+
case Format::R32G32B32A32_SINT:
106+
return "R32G32B32A32_SINT";
107+
case Format::R8_UINT:
108+
return "R8_UINT";
109+
case Format::R8G8_UINT:
110+
return "R8G8_UINT";
111+
case Format::R8G8B8_UINT:
112+
return "R8G8B8_UINT";
113+
case Format::R8G8B8A8_UINT:
114+
return "R8G8B8A8_UINT";
115+
case Format::R16_UINT:
116+
return "R16_UINT";
117+
case Format::R16G16_UINT:
118+
return "R16G16_UINT";
119+
case Format::R16G16B16_UINT:
120+
return "R16G16B16_UINT";
121+
case Format::R16G16B16A16_UINT:
122+
return "R16G16B16A16_UINT";
123+
case Format::R32_UINT:
124+
return "R32_UINT";
125+
case Format::R32G32_UINT:
126+
return "R32G32_UINT";
127+
case Format::R32G32B32_UINT:
128+
return "R32G32B32_UINT";
129+
case Format::R32G32B32A32_UINT:
130+
return "R32G32B32A32_UINT";
131+
case Format::R32_SFLOAT:
132+
return "R32_SFLOAT";
133+
case Format::R32G32_SFLOAT:
134+
return "R32G32_SFLOAT";
135+
case Format::R32G32B32_SFLOAT:
136+
return "R32G32B32_SFLOAT";
137+
case Format::R32G32B32A32_SFLOAT:
138+
return "R32G32B32A32_SFLOAT";
139+
case Format::D16_UNORM:
140+
return "D16_UNORM";
141+
case Format::D24_UNORM_S8_UINT:
142+
return "D24_UNORM_S8_UINT";
143+
case Format::D32_SFLOAT:
144+
return "D32_SFLOAT";
145+
case Format::D32_SFLOAT_S8_UINT:
146+
return "D32_SFLOAT_S8_UINT";
147+
default:
148+
return "UNKNOWN";
149+
}
150+
}
151+
152+
59153
constexpr const char* FormatToShaderType(Format format) noexcept
60154
{
61155
switch (format) {

‎src/Context/RenderGraph.cpp‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ namespace FCT
8888
m_commandBufferGraph = commandBufferGraph;
8989
m_resourceManager = resourceManager;
9090
initForSubmit();
91+
auto& syncTickers = m_flowControl->syncTickers();
92+
syncTickers[RenderGraphTickers::CheckRecompiledSync] = {
93+
[this]()
94+
{
95+
if (m_needRecompiled)
96+
{
97+
cleanUpCompile();
98+
compile();
99+
m_needRecompiled = false;
100+
}
101+
},
102+
{},
103+
{}
104+
};
105+
syncTickers.update();
91106
}
92107

93108
RenderGraphImageNode* RenderGraph::getOrCreateImageNode(const std::string& name, const Texture& texture)
@@ -329,6 +344,16 @@ void RenderGraph::removeDepthStencilEdge(DepthStencilEdge* edgeToRemove) {
329344
}
330345
}
331346

347+
void RenderGraph::recompile()
348+
{
349+
m_needRecompiled = true;
350+
/*
351+
*
352+
cleanUpCompile();
353+
compile();
354+
*/
355+
}
356+
332357
void RenderGraph::resolveTextureSizes()
333358
{
334359

@@ -1030,6 +1055,11 @@ void RenderGraph::removeDepthStencilEdge(DepthStencilEdge* edgeToRemove) {
10301055

10311056
void RenderGraph::cleanUpCompile()
10321057
{
1058+
m_commandBufferGraph->removeBuffer(m_commandBufferToken);
1059+
for (auto& [name, pass] : m_allocatedPasses)
1060+
{
1061+
pipeHub.passPipe.remove<PassInfo>(name);
1062+
}
10331063
m_passGroupOrders.clear();
10341064
m_passGroupExecutionOrder.clear();
10351065
m_passGroupBarriers.clear();
@@ -1049,7 +1079,6 @@ void RenderGraph::removeDepthStencilEdge(DepthStencilEdge* edgeToRemove) {
10491079
{
10501080
passGroup->release();
10511081
}
1052-
m_originalPasses.clear();
10531082
}
10541083

10551084
PipelineStage RenderGraph::convertShaderStageToPipelineStage(ShaderStage stage) const {

‎src/Context/RenderGraph.h‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ namespace FCT
241241
namespace RenderGraphTickers
242242
{
243243
constexpr const char* RenderGraphSubmit = "RenderGraphSubmit";
244+
constexpr const char* CheckRecompiledSync = "RenderGraphCheckRecompiled";
244245
}
245246
class RenderGraph : private IEventSystem<EventSystemConfig::TriggerOnly>{
246247
struct ImageState {
@@ -261,6 +262,7 @@ namespace FCT
261262
ImageAspect aspect;
262263
};
263264
private:
265+
bool m_needRecompiled = false;
264266
Device* m_resourceDevice;
265267
FlowControl* m_flowControl;
266268
CommandBufferGraph* m_commandBufferGraph;
@@ -287,7 +289,7 @@ namespace FCT
287289
std::unordered_set<std::unique_ptr<Edge>> m_edges;
288290
std::unordered_map<std::string, Image*> m_allocatedImages;
289291
std::unordered_map<std::string, RHI::Pass*> m_allocatedPasses;
290-
std::vector<PassDesc> m_originalPasses; // 存储编译前的PassDesc
292+
std::vector<PassDesc> m_originalPasses;
291293
std::vector<std::string> m_topologicalSortPasses;
292294
std::unordered_map<std::string, RHI::PassGroup*> m_allocatedPassGroups; // 存储创建的PassGroup
293295
void cleanUpCompile();
@@ -297,6 +299,11 @@ namespace FCT
297299
public:
298300
RenderGraph(PipeHub& pipeHub, Device* device, FlowControl* flowControl, CommandBufferGraph* commandBufferGraph,
299301
ResourceManager* resourceManager);
302+
void recompile();
303+
std::vector<PassDesc> getOriginalPasses() const
304+
{
305+
return m_originalPasses;
306+
}
300307
private:
301308
RenderGraphImageNode* getOrCreateImageNode(const std::string& name, const Texture& texture);
302309
RenderGraphImageNode* getOrCreateImageNode(const std::string& name, const Target& target);
@@ -317,7 +324,6 @@ namespace FCT
317324
void removeTargetEdge(TargetEdge* edgeToRemove);
318325
void removeDepthStencilEdge(DepthStencilEdge* edgeToRemove);
319326
void addPass(const PassDesc& desc);
320-
321327
void cleanUp();
322328
/**
323329
* @cond CHINESE

‎src/Context/ResourceManager.cpp‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ namespace FCT {
107107
{
108108
if (m_dependencyGraph.containsNode(name))
109109
{
110-
111-
auto node = m_dependencyGraph[name];
112-
auto& imageSaved = node->value;
113-
114-
if (imageSaved.img)
115110
{
116-
imageSaved.img->release();
111+
auto node = m_dependencyGraph[name];
112+
auto& imageSaved = node->value;
113+
114+
if (imageSaved.img)
115+
{
116+
imageSaved.img->release();
117+
}
117118
}
118119

119120
m_dependencyGraph.removeNode(name);

0 commit comments

Comments
 (0)