This is a question that perhaps a seasoned engine programmer could asnwer for me. In a single threaded renderer, a possible approach would be something like this:
- Collect visible drawable objects
- Create DrawCall instances, containing everything that the renderer needs to visually describe this object, including a sort key.
- Sort those instances based on the sort key
- Go through them all and render them
Roughly...
However, with a commandlist approach (D3D12/Vulkan), I can see some problems. So, we want to record commandlists from multiple threads; let's say we have a task scheduler which we feed it rendering tasks. We also have a pool of commandlists and we get the next available. So far so good, we can record our commands. How would the drawcalls be ordered?
Thanks!