You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FrameGraphResource FrameGraph::Builder::write(FrameGraphResource id) {
assert(m_frameGraph.isValid(id));
if (m_frameGraph._getResourceEntry(id).isImported()) setSideEffect();
...
}
What is the m_hasSideEffect use for?
And the FrameGraph-Example just a little complex, I am just a fresh hand. Can you update an example about how to draw a box with index buffer? :D Thanks~
Oh! I have generally finished reading your project and it wrote very well and clearly, Thank you very much~ :D.
When I try to read FrameGraph in Filament. FrameGraph looks like rebuild every frame? If I have many many Node and Resource in one rendering frame, if some Node not change but I must rebuild it at next new frame? Is that will waste performance? Is that really necessary to rebuild FrameGraph every frame?
If I create a PassNode and create an TextureNode for read, there have assert code in FrameGraph::Builder::read(...):
It looks like FrameGraph not support PassNode to create ResourceNode for read.
If I want create an TextureNode for ColorDrawPass and it will sampled in fragment shader.
How I binding the shaders in PassNode
Resource are create and destroy by ResourceEntry::Concept or Model . How to initial the texture's color pixel? If I import this texture into FrameGraph how to do it? the test in TEST_CASE("Imported resource", "[FrameGraph]") the id for the import already existed
Is that really necessary to rebuild FrameGraph every frame?
Yes, you need to rebuild the FrameGraph every frame.
(...) Is that will waste performance?
Here I have a FrameGraph with 38 passes and 51 resources:
(measured with Tracy Profiler).
In my opinion, the cost is negligible.
It looks like FrameGraph not support PassNode to create ResourceNode for read.
Do you want to create a resource in a pass and read it immediately in the same pass? That will give you a garbage data.
Usually, a pass creates a resource (writes to it) and another pass reads from it.
How I binding the shaders in PassNode
It's up to you. Pass whatever you need to ctx in an execution callback.
structPassData {};
fg.addCallbackPass<PassData>("SimplePass",
[&](FrameGraph::Builder &builder, PassData &data) {
// ...
},
[=](const PassData &data, FrameGraphPassResources &resources, void *ctx) {
auto &rc = *static_cast<RenderContext *>(ctx);
rc.bindPipeline(/* whatever, could be a member variable */);
// ...
}
);
Don't use a FrameGraph to create a resource that is initialized once (like mesh vertex buffer or a material texture).
Don't import everyting into a FrameGraph.
Here, the SSAO pass is the owner of a noise texture and a kernel uniform buffer. Both are initialized by the constructor and then captured by the execution callback.
To create a resource, the FrameGraph class uses given allocator (transient resource manager/system).
the code compare the version between ResourceNode and ResourceRegistry. Why? Why to compare the version?
I know if different pass write to the same ResourceEntry ,the version of ResourceEntry will plus one for each clone and set the new ResourceEntry version into the ResourceNode version, that will let track resource very easy, but I don't understand why use the node.m_version == resource.m_version to judge whether it is valid?
It enforces a specific execution order of the render passes (prevents mistakes).
Imagine that you have a pass P0, that writes to a resource R.
Followed by a pass P1, that writes to R (version is bumped)
Then you want to read R in yet another pass P2
you could by mistake give the handle of the first write operation to P2 (you should use the most recent one)
I'm gonna convert this issue to a discussion (since it's not really an issue).
Repository owner locked and limited conversation to collaborators on Jun 5, 2022
Activity
skaarj1989 commentedon Jun 3, 2022
setSideEffectensures that a pass is not culled during the compilation phase. (writing to imported resource counts as side-effect).Moving to FrameGraph is a big paradigm shift. It might be overwhelming at first but once you understand it you won't look back ;)
I encourage you to watch/read:
FuXiii commentedon Jun 4, 2022
Oh! I have generally finished reading your project and it wrote very well and clearly, Thank you very much~ :D.
When I try to read
FrameGraphinFilament.FrameGraphlooks like rebuild every frame? If I have many manyNodeandResourcein one rendering frame, if someNodenot change but I must rebuild it at next new frame? Is that will waste performance? Is that really necessary to rebuildFrameGraphevery frame?If I create a
PassNodeand create anTextureNodefor read, there haveassertcode inFrameGraph::Builder::read(...):It looks like
FrameGraphnot supportPassNodeto createResourceNodefor read.If I want create an
TextureNodeforColorDrawPassand it will sampled in fragment shader.PassNodecreateanddestroybyResourceEntry::Concept or Model. How to initial the texture's color pixel? If Iimportthis texture intoFrameGraphhow to do it? thetestinTEST_CASE("Imported resource", "[FrameGraph]")theidfor the import already existedIn really case the code maybe looks like:
Is that right?
or just create an
HostWritePassfor host texture memory write? but I think this just a little odd.skaarj1989 commentedon Jun 4, 2022
Yes, you need to rebuild the FrameGraph every frame.
Here I have a FrameGraph with 38 passes and 51 resources:
(measured with Tracy Profiler).
In my opinion, the cost is negligible.
Do you want to create a resource in a pass and read it immediately in the same pass? That will give you a garbage data.
Usually, a pass creates a resource (writes to it) and another pass reads from it.
It's up to you. Pass whatever you need to
ctxin an execution callback.Here you have an example:
https://github.com/skaarj1989/FrameGraph-Example/blob/7867df8e3146acfffaf41173d5776b6ac265fd50/src/WorldRenderer.cpp#L415
Here, the SSAO pass is the owner of a noise texture and a kernel uniform buffer. Both are initialized by the constructor and then captured by the execution callback.
To create a resource, the FrameGraph class uses given
allocator(transient resource manager/system).Take a look at here, for an example of a transient resource system.
FuXiii commentedon Jun 4, 2022
Oh~ Thank you very very much~ :D
I think I need to read your
FrameGraph-Exampleproject .♪(^∇^*)FuXiii commentedon Jun 5, 2022
When to judge
ID Validthe code compare the
versionbetweenResourceNodeandResourceRegistry. Why? Why to compare theversion?I know if different
passwrite to the sameResourceEntry,theversionofResourceEntrywill plus one for eachcloneand set thenew ResourceEntry versioninto theResourceNode version, that will let track resource very easy, but I don't understand why use thenode.m_version == resource.m_versionto judge whether it is valid?skaarj1989 commentedon Jun 5, 2022
It enforces a specific execution order of the render passes (prevents mistakes).
Imagine that you have a pass P0, that writes to a resource R.
Followed by a pass P1, that writes to R (version is bumped)
Then you want to read R in yet another pass P2
you could by mistake give the handle of the first write operation to P2 (you should use the most recent one)
I'm gonna convert this issue to a discussion (since it's not really an issue).