Closed iByteSpace closed 1 year ago
The output_resource
is an output from the perspective of the node that is acting as an input to the current node. If the current node (node
) is "A" and one of its inputs (node->inputs [ r ]
) is "B", then the requested output_resource
is B's output. B precedes A in the graph and B can be thought of as a producer of this resource for A.
I suppose that the variable output_resource
could be renamed produced_resource
or producers_output_resource
which might better identify its use and could help with some of the subsequent code:
resource->producer = produced_resource->producer;
resource->resource_info = produced_resource->resource_info;
resource->output_handle = produced_resource->output_handle;
@karlrado Thanks for your reply! I appreciate this part of the implementation is not super clear and something we would like to revisit at some point. I also agree we could do with better naming :)
As Karl mentioned, each node defines inputs and outputs. Within the graph we had to distinguish when a given resource is used as an input or an output, so we create two FrameGraphResource
objects, one for the input and one for the output. Only the output however contains the Vulkan image or buffer details. This is because the output is produced by a node, while an input is basically just a reference to an output.
We connect this reference inside compute_edges
in frame_graph.cpp
.
Things are also made more confusing by the fact that when calling FrameGraph::access_resource
you get a resource by ID, so you get a different resource for an input or an output. However, when calling FrameGraph::get_resource
you always get the output resource, as it's the only one that we store in the resource cache and it's the one that contains the Vulkan object.
Again, I realise this is not an intuitive design but hopefully this clarifies things a bit :)
Let me know if you have any further questions!
Closing this. Feel free to re-open if you have more questions :)
Hello, I am a reader of the Master book and would like to ask a question that has nothing to do with bugs. I am very confused about the following writing or function naming.
FrameGraphResource* resource = frame_graph->access_resource( node->inputs[ r ] ); // Get an input resource
FrameGraphResource* output_resource = frame_graph->get_resource( resource->name ); // It looks like the resource is obtained again by its own name. Why does this represent an output resource?