Multithreaded Rendering in Hieroglyph 3
Posted by Jason Z, 25 July 2010 · 209 views
After some serious debugging, I have true multithreaded rendering working in Hieroglyph 3 now. It is always astonishing to me how much more difficult it is to debug a program when it is multithreaded as opposed to single threaded... Its like the difference between understanding Newtonian physics compared with Relativistic physics - they aren't even in the same league. Even so, when you properly work out the designs ahead of time, the complexity is manageable and you can really come out with a win in the end.
Another interesting part of working with D3D11 Deferred Contexts is the use of PIX. Since each context has a different address, you can clearly see in PIX which thread is executing which statements in which order - which is sometimes very helpful in figuring out if your sequencing is incorrect on the CPU side or if there is something wrong on the pipeline state of the GPU side. At the same time, using deferred contexts robs you of seeing the live render target results in PIX after each draw call (it also doesn't update after each command list is executed... that would be nice...). This is a nice feature to use, but in the end it isn't that important I guess. Perhaps in a later version of PIX more support will be added for this type of debugging.
Next up is to set up the renderer to handle an unlimited number of render views in a single frame. This will more or less just take the number of views to execute and do them in batches of NUM_THREADS. Once this is complete, I'll be adding a sample program to the Hieroglyph 3 repository that creates a couple different types of scenes, and then do some comparisons on how the scenes run on both my laptop (dual core, 8600M GT) and my desktop (quad core, 5700 series Radeon). Also interesting will be seeing how various rendering work loads play into the performance - if the GPU is too busy already then all the multithreading in the world won't help out very much... I'll post again once I get some preliminary results and see how the timing works out.