exellian / rui

Rust framework for building modern ui
3 stars 0 forks source link

[draft] node tree #12

Open exellian opened 2 years ago

exellian commented 2 years ago

Currently the node tree is a top down structure where every node knows its child nodes but child nodes doesn't know their parent node. We have to discuss how we can work around this, if its an restriction, if we have to choose a different tree structure (linked tree)

exellian commented 2 years ago

The node tree is the core data structure behind a scene of a window/surface. It stores all necessary nodes that need to be rendered on screen. Therefore the node tree is also crucial for performance. In this issue I want to sketch my current thoughts about the node tree structure:

The enum Node rui::node::Node represents the current node tree structure. It defines some basic nodes which should cover primitive- and composition- nodes. With these basic nodes you should be able to build any ui you want. Therefore the enum will be extended to some point where everybody is satisfied. Currently the enum contains following base nodes:

Nodes that should be implemented:

IMPORTANT: Every node is contained in a bounding rectangle and therefore we can optimize the rendering process as follows:

exellian commented 2 years ago

Currently wgpu doesn't has support for rendering only to certain areas of a render target (See Vulkan: renderArea property on the render pass struct) and it is also not efficient to create a own render pass for every node that needs to be updated. Therefore we probably have to overthink the design of the node tree and move to something more "gpu compatible":

We should not think of a tree but rather a simple list of layers in the ui. Then every group of layers which doesnt't has overlapping nodes that use background filter effects (like convolution filters) can be rendered in one render pass. So essentially if we have such a node tree than we first have to somehow flatten this tree in a list of primitives and then split it on such overlapping filter layers, that we can create the corresponding render passes. So we need somehow a hybrid data structure which is easy to build, easy to render and fast to build because we expect changes every frame.