I have a material that is based on lots of data stored on the disk (over 100mb compressed). At present, I load this data in the constructor of the material but this is creating a bit of a bottleneck when I start-up a networked render. It goes something like this:
- Local luxrender client loads all the files
- Sends scene to first server and waits while it loads all the files
- Sends scene to second server and waits while it loads
- etc.
All this waiting while the servers are loading the data seems inefficient and makes for a long startup time. I'm wondering if I could just do it somewhere else in the material class so that it doesn't happen while the server is receiving commands from the client. If it could wait and happen after the client finishes sending the scene and has moved to the next server (or started rendering itself) that would be super. Perhaps it could just wait until the material is used in some way but I don't know where in the code I could recognize this situation. Perhaps things need to happen in the BxDF class that drives this material instead of the material class but I'm just guessing and could use some guidance.
I thought about doing the data loading inside of GetBSDF() but I quickly noticed that this function is const and naturally I need to modify the object when I load the data. I'm also concerned about threading here. My thought was just to protect this data loading code with a mutex (and also some flag to make sure it doesn't try and load it twice).
Right now, the material object stores all the data and passes a pointer to all this data into the BxDF as it gets created in GetBSDF(). I allocate a new BxDF every time GetBSDF() gets called but reuse the data stored in the Material object. This was based on looking at other material classes and their GetBSDF() functions so if there's a better way to do it that would help my situation (i.e. make the BxDF once, maybe the first time GetBSDF() is called then send the same one on subsequent GetBSDF() calls) I'm all for it! This would allow me to read the data in the BxDF instead of the material and likely solve my problem. It's a significant change though and intuition says it will F-up the whole material class/BSDF hierarchy if they are all using the same BxDF instead of independent instances. So I'm asking first rather than trying first.
Thanks!
Seth
