a-day-old-bagel / DualityEngine

3D game stuff
0 stars 0 forks source link

Central Render Tree #23

Open a-day-old-bagel opened 8 years ago

a-day-old-bagel commented 8 years ago

Under the Render_Master system, a tree structure may be implemented on top of a linked list such that gl state changes are ordered in an optimal manner. For example, switching shader programs is expensive and so should happen infrequently, while changing uniform values is cheap and may happen often. So a tree to organize queued renders would work something like this:

             draw task insertion
             |             |               |
      shaders 1      2      and 3, etc...
      |          |              |            |      |
   buffers...                       ..................
 |     |          |      |         |       |     |       |

uniforms ... ... ... ... ... ...

And at the bottom exists some sort of array (probably linked list since we don't know beforehand what will need to be drawn), which describes an order for state changes and draw calls. Then on every tick the master render system will iterate through it and draw everything.