Render graph slots revival: a render graph runner overhaul proposal #8644
Replies: 2 comments 1 reply
-
I'm not sure I'd want to go in that direction. Slots add a lot of boilerplate and in most situations simply aren't needed. We almost considered removing them entirely because they simply aren't used in practice. We decided to keep them optional instead of entirely removing them for people that prefer using them. In practice, you can simply use the ECS to store everything and just use the graph to order everything correctly. Using the graph to also pass the data introduces a lot of boilerplate and new concepts. Using the ECS for everything means you don't need to learn as many apis just to pass data around. Your idea of recycling textures is interesting, but I'm not entirely sure using slots is the only way to achieve this. I disagree with the idea that using slots would lead to simpler code. We've had slots for a while and they were much harder to follow than the current approach used in bevy main. Of course, if you can make a render graph using slots with a simple api then it would be interesting, but as it currently is slots are very boilerplate heavy and forces the users to learn a bigger api surface just to do some simple things. I'm not sure why you think the current render graph is not sufficient for any serious use. Could you expand on this a bit.
Because the render graph can be used for more than just textures. Until very recently, the view target of the current graph being executed was passed as an entity slot. We've now made this view entity a first party of the render graph, but I'm sure there would be other similar use cases. Not sure about samplers though.
I wouldn't be against that change, I've been confused way too many times by this, but I feel like switching it would also end up confusing people. |
Beta Was this translation helpful? Give feedback.
-
Rather than revive render graph slots, I'm playing around with a
It's basically just an automated wrapper around all the duplicate boilerplate I've been writing as I've developed TAA/SSAO/Bloom/EnvMaps/Solari/etc. WIP is here: https://github.com/JMS55/bevy/blob/render_task/crates/bevy_render/src/render_task |
Beta Was this translation helpful? Give feedback.
-
I've been experimenting with Bevy for a while and I have some concerns about the direction of the renderer's development. It can be a bit challenging to work with and there are some areas where things are tightly coupled. This means that making even a simple change or addition to the render graph requires copying and modifying a lot of components that I feel should be more composable.
This proposal is designed to address some of the issues I have with the render graph execution engine. It is supposed to make writing and composing render nodes easier by reintroducing slots as the primary method of passing buffers and textures between nodes in a render graph.
The problem
The current render graph runner delegates texture/buffer management to the nodes. This pretty much defeats the purpose of a render graph because all built-in nodes make use of hard-coded source and destination textures. In general, I don't like the idea of nodes relying on components such as
ViewTarget
for communication.The solution
Slots should be brought back from the dead and the render graph runner should be modified to allocate, assign and recycle buffers and textures used by nodes. All existing rendering nodes should be refactored to request the required resources before being executed, instead of accessing resources and components like the
TextureCache
andViewTarget
directly.A rough specification
When executing a subgraph, the graph runner should:
For example, let's say nodes A, B, and C all have a single input and a single output texture, and that all the texture descriptors are the same. If we execute them sequentially, only two textures will be allocated, because once node A has been executed, we can reuse its input texture as the output of B, and after B has been executed, we can use its input texture as the output of C.
A similar algorithm is described in the MXNet whitepaper, but in our case, we don't have to deal with inplace operations.
Implementation status
I've started writing a draft implementation of the graph runner, but it might take me a while to make a working prototype because I don't have much free time.
Impact
These changes will break pretty much every 3rd party implementation of Node. However, I don't believe the current render graph API is sufficient for any serious use anyway, so I think breaking compatibility will be worth it in this case.
Additionally, texture labels will be meaningless since textures will be reused between nodes.
Questions
Entity
andSampler
valid variants ofSlot
?I apologize for any mistakes or unclear descriptions here, I'll read over and correct anything I notice when I am less tired, I just wanted to post it here and get some feedback before I decide to put it into my backlog again...
Beta Was this translation helpful? Give feedback.
All reactions