While the current TaskManager does its job, I somehow feel that a more elegant solution would be to use Priority Queues.
My idea for that would be:
- 3 Lists: Current pass, Next pass, Done
- All three are Priority Queues, the priority of a tile is calculated based on the tile ordering (e.g. the distance from the center)
- When rendering starts, all tiles are pushed into the "Current pass" queue
- acquire_tile pops the highest-priority tile from the "Current pass" queue
- Once a tile is finished, it gets returned to the TileManager
- For final renders, these tiles just are pushed into the "Done" queue
- For preview/progressive renders, the tiles are pushed to "Next pass" if they've not received the desired sample count, and "Done" otherwise
- Once the "Current pass" is empty, the "Next pass" is moved to "Current pass" if non-empty, otherwise rendering stops
The biggest advantage is that it makes more advanced tile strategies easier: D808 already uses a priority queue, another example is rendering a quick preview pass before each tile is fully rendered.
Are there any obvious problems with this approach? If not, would a patch that implements it have a chance?