<p>A few more options:</p>

<ol start="4">
<li><p>don't use a scenegraph. They don't map well to the data a gpu needs for rendering. A flat array of object tends to work much better for the cache as well</p></li>
<li><p>separate the scenegraph into render-related data and non-render-related data. Then only double buffer the render-related data. </p>

<p>The render related data would end up in a flat array containing per rendered object: reference to the mesh, the final model matrix, a reference to the texture</p></li>
</ol>

<p>Flat arrays are much easier to double buffer than node-based data structures.</p>

CC BY-SA 4.0
2019-06-12T04:24:11.607Z
Is batching outdated? It uses a queue after all. I was thinking about abusing the batching queue for state updates?
user1095108
CC BY-SA 4.0
2019-06-12T09:54:35.053Z
Batching is still recommended, however a scenegraph hinders efficient batching more than it helps. With a flat array of objects you can sort it so similar render commands end up next to each other.
ratchet freak
CC BY-SA 4.0
2019-06-11T15:56:25.933Z
2019-06-11T15:56:25.933Z
ratchet freak
<p>I am updating my scene graph in response to user input and the network. What is the best way to do this? The updating threads are separate. Some approaches I am thinking about:</p>

<ul>
<li><p>double buffer. There are 2 copies of the scene graph, one is used for rendering and the other for updates. The rendering graph is updated at the end of the render loop. This update can be expensive for a large graph,</p></li>
<li><p>synchronization objects, like mutices, probably unsuitable,</p></li>
<li><p>dumping updating functors into a FIFO queue while rendering, then executing the functors at the end of the rendering loop. Updating the queue may block.</p></li>
</ul>

<p>Is there something better and which approach is best?</p>

CC BY-SA 4.0
2019-06-11T21:24:16.517Z
You should probably implement a push pull graph if you are cpu bound
joojaa
CC BY-SA 4.0
2019-06-12T04:25:50.117Z
Never heard of it. Are there examples or articles?
user1095108
CC BY-SA 4.0
2019-06-12T05:16:19.680Z
A push pull graph does not actually update on changes. It pushes a flag that marks the graph element as needing to update (maya for example calls this flag a dirty bit, since the node attribute is dirty and needs washing). Instead the actual computation is pulled from the final nodes if needed. Causing the nodes to compute only when the downstream thing is needed. Thisway the graph self optimizes since it does not evaluate stuff that does not need to be updated.
joojaa
<rendering><multithreading><synchronization>
how to update my scene graph?
user1095108
# how to update my scene graph?

(Asked by: username_0 on 2019-06-10)

I am updating my scene graph in response to user input and the network. What is the best way to do this? The updating threads are separate. Some approaches I am thinking about:

* double buffer. There are 2 copies of the scene graph, one is used for rendering and the other for updates. The rendering graph is updated at the end of the render loop. This update can be expensive for a large graph,
* synchronization objects, like mutices, probably unsuitable,
* dumping updating functors into a FIFO queue while rendering, then executing the functors at the end of the rendering loop. Updating the queue may block.

Is there something better and which approach is best?

**Tags:** rendering, multithreading, synchronization

> **Comments:**
> **username_1**: You should probably implement a push pull graph if you are cpu bound  
> **username_0**: Never heard of it. Are there examples or articles?  
> **username_1**: A push pull graph does not actually update on changes. It pushes a flag that marks the graph element as needing to update (maya for example calls this flag a dirty bit, since the node attribute is dirty and needs washing). Instead the actual computation is pulled from the final nodes if needed. Causing the nodes to compute only when the downstream thing is needed. Thisway the graph self optimizes since it does not evaluate stuff that does not need to be updated.  

---

## 1 answers

### Answer by username_2 on 2019-06-11. Score: 2

A few more options:

4. don't use a scenegraph. They don't map well to the data a gpu needs for rendering. A flat array of object tends to work much better for the cache as well
5. separate the scenegraph into render-related data and non-render-related data. Then only double buffer the render-related data.

   The render related data would end up in a flat array containing per rendered object: reference to the mesh, the final model matrix, a reference to the texture

Flat arrays are much easier to double buffer than node-based data structures.

> **Comments:**
> **username_0**: Is batching outdated? It uses a queue after all. I was thinking about abusing the batching queue for state updates?  
> **username_2**: Batching is still recommended, however a scenegraph hinders efficient batching more than it helps. With a flat array of objects you can sort it so similar render commands end up next to each other.  

---

