LumaPictures / maya-to-hydra

This repo is no longer updated. Please see https://github.com/Autodesk/maya-usd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimizing and cleaning out the callback hell

sirpalee opened this issue · comments

At the moment we rely heavily on callbacks to get the scene updates propagated, but it's causing significant slowdowns with many (5000+) animated objects, which can be easily the case in production.

The issue is easy to reproduce, create a small hierarchy with a few animated transforms (5 or 6 nodes), then duplicate the hierarchy 1000 times and keep the input connections. Hydra draws objects very fast (faster than VP2), but once animation is played back, the framerate drops to ~3fps compared to 30. Though VP2 is doing some sort of caching (the first playback is slower than the second one), but we should still be able to do better than 3 fps. I suspect simplifying the transform related callbacks could be an easy win. While there are simpler ways to track transform (MDagMessage's world matrix changed callback) changes than tracking parameter changes, we still need to deal with visibility in an efficient way.

The idea is to move tracking changes on transform matrices to the SceneDelegate and pass dirtied bits to the adapters for further processing. This way we can share callbacks and avoid duplicating them, and have cheaper options to build the transformation matrices than using MDagPath::inclusiveMatrix.

The reason we still need the adapters for marking prims dirty, rprim types can have their unique set of dirty bits, or you need to do additional processing / pre-calculating data (like shadow matrices for lights).