Jump to content

Nodes streaming with minimal stalls


photo

Recommended Posts

Hello,

I am trying to load some node hierarchies and create instances of it (clone them and transform various nodes inside the hierarchy, enable/disable them etc). And I need to do this during rendering (application is live doing other stuff + rendering), with minimal frame stalls.

- My first attempt was just to call World::loadNode but seems that most (if not all operations) are done on place, in the main thread (create nodes in hierarchy, create the objects for them (e.g. ObjectMeshStatic), create the meshes (e.g. D3D11MeshStatic) and update their vertex buffers, create and update the textures). So while it returns the full node hierarchy right away, it creates stalls. Can you confirm that this approach doesn’t use any background streaming at all?

- My next variant will be to use the AsyncQueue::loadNode. Can you confirm that this will move all the above operation on a background thread? Probably I need to setup a callback to be announced when the node is fully loaded so any operations done until then (as I need to move, enable/disable node hierarchies right away) I will probably need to record somehow and apply later (after receiving the callback that node is indeed fully streamed in)?

- My approach will be to use AsyncQueue::loadNode to load a copy of the hierarchy, call this “template copy”. And then for each instance call Node::clone so I can manipulate the individual nodes. Is there a better way to be able to apply different transforms on the same set of resource (meshes)? Or can I just use AsyncQueue::loadNode with the same file name and the system will just return a cached copy?

Also from what I can figure out there is no equivalent of clone for AyncQueue as Node::clone itself does minimal work on the main thread (create the nodes and some objects) while most of the GPU updates are done in an async task, can you confirm this?

- Plus, are there any other measures to take to avoid stalls per frame? I believe some operations (like creating the mesh vertex buffers and fetching the shaders) are done at runtime, in the main thread, at first rendering no matter how to load your nodes. Is there a way to avoid this (force some of these in a background thread)?

Regards,
Adrian

Link to comment

Hi Adrian,

Quote

create the meshes (e.g. D3D11MeshStatic) and update their vertex buffers, create and update the textures). So while it returns the full node hierarchy right away, it creates stalls. Can you confirm that this approach doesn’t use any background streaming at all?

All the highlighted operations are done in background.

 

AsyncQueue::loadNode differs from regular loadNode mostly by that fact that hierarchy creation is also done in background here.

Regarding your different approaches and stalls - I guess the only way to find out what is to examine the microprofile dumps, they will show all the spikes and what causing them.

Also if you will do intersection tests before created node will appear in spatial you will also have spikes: https://developer.unigine.com/forum/topic/7710-worldgetintersection-lag-spike

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...