Skip to content

Commit 2bfc962

Browse files
committed
some improvements
1 parent b48506b commit 2bfc962

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

sources/RenderSystem/FrameGraph/FrameGraph.Base.ixx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ public:
10291029
pass_ptr->flags = flags;
10301030
pass_ptr->pass_index = index;
10311031
pass_ptr->type_id = type_id;
1032+
pass_ptr->wait_pass = nullptr;
1033+
pass_ptr->prev_pass = nullptr;
10321034

10331035
builder.passes.push_back(pass_ptr);
10341036

sources/RenderSystem/FrameGraph/FrameGraph.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ namespace FrameGraph
3434
{
3535
max_passes = new_max_passes;
3636
states.reset_frame();
37+
38+
is_new = false;
39+
used_begin.reset();
40+
used_end.reset();
41+
enabled = false;
3742
}
3843

3944
void ResourceAllocInfo::remove_inactive()
@@ -112,7 +117,7 @@ namespace FrameGraph
112117
create(h, { ivec3(0,0,0), HAL::Format::UNKNOWN, 0 }, flags);
113118
auto& info = *h.info;
114119
info.passed = true;
115-
120+
info.enabled = true;
116121
info.resource = tex;
117122
info.fence = fence;
118123
info.d3ddesc = tex->get_desc();
@@ -141,7 +146,7 @@ namespace FrameGraph
141146

142147

143148
info.passed = true;
144-
149+
info.enabled = true;
145150
info.resource = tex;
146151
info.d3ddesc = tex->get_desc();
147152
info.fence = fence;
@@ -334,14 +339,7 @@ namespace FrameGraph
334339
{
335340

336341
PROFILE(L"enabled");
337-
for (auto& chain : builder.alloc_resources)
338-
for (auto& info : chain.active_span())
339-
{
340-
341-
if (info.passed) continue;
342-
info.enabled = false;
343-
}
344-
342+
345343
builder.enabled_resources.clear();
346344

347345
auto process_resource = [&](this auto&& self, ResourceAllocInfo& info, UINT pass_id) -> void {
@@ -372,12 +370,23 @@ namespace FrameGraph
372370
};
373371

374372
for (auto& chain : builder.alloc_resources)
375-
for (auto& info : chain.active_span())
373+
{
374+
// A later chain version being Required implies every earlier
375+
// version it was recreated from is Required too (they produce the
376+
// content the final version clones/depends on). Propagate the flag
377+
// backward through the chain before enabling creators.
378+
bool required = false;
379+
for (auto& info : chain.active_span() | std::ranges::views::reverse)
376380
{
381+
required = required || check(info.flags & ResourceFlags::Required);
382+
if (required)
383+
info.flags |= ResourceFlags::Required;
384+
}
377385

386+
for (auto& info : chain.active_span())
378387
if (check(info.flags & ResourceFlags::Required))
379388
process_resource(info, (int)builder.passes.size());
380-
}
389+
}
381390

382391

383392
for (auto& pass : builder.required_passes)
@@ -415,8 +424,7 @@ namespace FrameGraph
415424
for (auto pass : builder.enabled_passes)
416425
{
417426
pass->call_id = i++;
418-
pass->wait_pass = nullptr;
419-
pass->prev_pass = nullptr;
427+
420428
}
421429

422430
Pass* prev_compute = nullptr;
@@ -491,15 +499,10 @@ namespace FrameGraph
491499
for (auto& chain : builder.alloc_resources)
492500
for (auto& info : chain.active_span())
493501
{
494-
495502
if (!info.enabled) continue;
496503

497504
info.remove_inactive();
498505

499-
info.used_begin.reset();
500-
info.used_end.reset();
501-
502-
503506

504507
for (auto& state : info.states)
505508
{
@@ -742,7 +745,7 @@ namespace FrameGraph
742745
info.reset(passes.size());
743746
info.flags = flags;
744747
info.frame_id = current_frame->get_frame();
745-
info.is_new = false;
748+
746749
//info.valid_from = info.valid_to = info.valid_to_start = nullptr;
747750

748751
if (current_pass) {

0 commit comments

Comments
 (0)