Currently, all rendering happens on the main thread. Rendering should be moved to another thread to take advantage of multicore performance.
Prerequisite #29
One complication to creating command buffers in multiple threads is how to manage resource creation and destruction across threads. Each thread can create new resources and therefore needs new IDs generated for the resources. Threads can also destroy existing resources and the resources can be accessed at the same time from other threads.
- Creation of IDs should happen locally on the thread. Each thread should have a thread-local store for created IDs that will be merged to the main ID store at the end of the frame. Main ID store is otherwise read-only during the frame.
- Newly created resources can only be accessed from the thread that created it. This guarantees that there are no other threads trying to access the resource while its ID is only registered to the thread-local ID store. I still need to think about how to make sure the created ID can't be passed to another thread.
- Destruction of resources should be deferred to the end of the frame. This guarantees that any thread can still access the resource while one of the threads might have requested to destroy the resource.
- Each thread should have a thread-local store of resources that have been requested to be destroyed. All the requests are merged and destroyed at the end of the frame.
Currently, all rendering happens on the main thread. Rendering should be moved to another thread to take advantage of multicore performance.
Prerequisite #29
One complication to creating command buffers in multiple threads is how to manage resource creation and destruction across threads. Each thread can create new resources and therefore needs new IDs generated for the resources. Threads can also destroy existing resources and the resources can be accessed at the same time from other threads.