Original Post
Hi all As the title says I'm curious as to what peoples experiences are of rendering in task-based multithreaded environment. I've been putting together a plan for a new framework (eventual goal is for a flight sim if that makes any difference) using advice gleamed from various discussions on task based multithreading and entity/component systems, and I plan to use DX11 multi-threaded capabilities. However I'm undecided on the best way forward when it actually comes to implementing the rendering. As far as the entity system is concerned I'm going for a "pure" system where each component is just data, and each component type has a system/manager which contains the functionality. Each components data will also be double buffered so that reads are consistent, and writes will be made live with a sync phase after all processing by all systems is done. From a threading point of view there'll be: - WndProc/Rendering thread (with the DX11 immediate context) - Simulation thread - main loop which issues tasks for component system processing etc (the systems themselves will then issue more tasks as required) - 1..n task processing threads (each also having a DX11 deferred context) Rendering wise I see 3 choices: 1 - Simulation thread generates DX calls using tasks/deferred contexts and then dispatches all the Command Lists to the rendering thread for execution with the immediate context 2 - WndProc/Rendering thread renders world state as it is at that time, but breaks the process down and issues tasks for generating the DX calls as appropriate 3 - WndProc/Rendering does all the work within its own thread Obviously each has pro's and cons. I'm thinking: 1 would limit the frame rate to a the update frequency of the simulation loop. 2 would allow unlimited (or a fixed) frame rate, but as far as I can tell would probably warrant triple buffering the component state since when rendering you'd ideally want two sets of live data and interpolate between them (rather than extrapolating from one). Also potential for the frame rate to be affected by tasks it generates being caught in congestion on the task processing threads. 3 doesn't take advantage of multi-cores, more chance of overrunning the render time budget if scene is more complex but avoids potential congestion on task processing threads. And theres bound to be other things I've not considered yet. What does anyone else think on the subject? Cheers