Closed RDambrosio016 closed 2 years ago
I'm going to look at and think about this more, but what's happening is that we have two kinds of render graph nodes - "render" and "callback". Callback is usually compute operations but there's no reason one couldn't do other GPU operations, so I use the more general naming of a "callback" node because it's literally just giving you a callback. The way the render graph code knows which type of node you want is based on if you called set_renderpass_callback
or set_callback
. If you don't call either, it defaults to just a callback (i.e. no renderpass is created.)
At a code level, we're checking image states as we progress through nodes to determine where barriers need to be placed. Most of the time, we visit a node and look at all the transitions needed to do the work before the node performs work. The exception is output images - their transition is after all nodes are visited. So that case is a different (older) codepath. Right now it only handles image attachments, which should only ever be placed on renderpasses. So the code is reasonably skipped for non-renderpasses.
So some things to resolve:
add_node
to be add_renderpass_node
and add_callback_node
add_node
to take an enum that specifies what kind of node to createbuild_pass_barriers
needs a proper implementation, and it probably needs to be done as a final pass on the graph as a whole rather than tacked onto the end of whatever node last touched the resource.A potential bandaid would be to fail loudly if no callback is provided, and probably also fail loudly if a color attachment is used with a node that's not a renderpass. This would make it more obvious that the graph in this repro is not legal (because under current API design it describes using a color attachment without a renderpass.)
Can be reproduced by just commenting out the entirety of the
graph_builder.set_renderpass_callback
in framework_triangle. This logs a vulkan validation error:I think the lack of actual attachment usage within the node triggers the resource allocator to try and use the color attachment directly for presentation and it forgets to transition the resource for some reason.