This project is read-only.

About views and multithreading.

Jan 11, 2013 at 7:24 AM

Sorry for starting 2 discussions at once,I was just wondering for some advice on using render views.In my framework,I didn't really have multithreading,but I liked your idea on the render views,however I'm wondering about 2 things:

1.How do you ensure the workload is evenly split on the cores?I imagine the best way to do it is to split the bigger views into as many smaller ones as possible so that way you reduce the chance of dumping a big one on 1 payload and leaving the rest empty?

2.Would it be better if NUM_THREADS was dynamically created at start(via checking how many cores the machine has) or does large scale multithreading not scale so well?(in the Frostbite 2 tech pdf they said that most drivers right now don't handle that very well yet)

Jan 11, 2013 at 2:20 PM

No problem - you can ask as many questions as you want to :)  Here are my answers:

1. I currently don't explicitly do this in the engine - it is more or less assumed that when you build the scene that it will include only the render views that are needed, and each render view can have very different performance behavior depending on the contents of the scene.  This makes it really hard to try to come up with an algorithm that could effectively sort out which ones should be done in parallel.

2. This is certainly a possibility, and it almost certainly should be defined to create the number of threads that exist on the machine that the engine is running on.  I haven't done this yet, but at some point it should get implemented.  The main point though is that you should not have more threads than you have hardware cores, otherwise you are just going to be doing extra context switching that doesn't add any benefit.  You want each core to be operating independently, doing as much CPU related work as possible, all in parallel.  That is the only goal of doing the MT rendering submission - to reduce the amount of overall time needed to get your CPU related work done!

Does that help clarify the issue a little bit?

Jan 11, 2013 at 7:38 PM
Edited Jan 11, 2013 at 8:50 PM

Yeah,I was thinking of making a ViewPostProcess and then having in it as many View>insert post process effect name here< this way

I'll also try to use the views to group entities with similar states,to reduce state changes