When I told the net friends that I am reading the Blender source code, they were very excited, they immediately threw out many known issues and hoped I could solve them. One of them, use Blender for video editing, the final export is single-threaded and cannot take advantage of multi-core.
They hope I can change the sequence rendering to multi-threaded, but I didn’t start working right away. I think about several different solutions, if on 4-core machine:
- Pre-process 4 frames of the movie with 4 threads and cache the result. When the main thread processes each frame, it directly takes out the part about movie from the cache. This solution does not pre-process the 3d scene. It only preprocesses the movie, which sounds more conservative, but I finally gave up on this solution because I think it will increase future maintenance costs.
- Render the left 4 frames of the timeline with 4 threads, and the main thread sorts the rendering results. I think the advantage of this strategy is that if the user stops rendering in the middle, you can get all the frames that are sorted by the main thread. but, it may not be friendly to the cache, because the rendering result of the previous frame cannot be obtained when the current frame is rendering.
- Divide the timeline into 4 slices, each thread processes a slice, and the main thread sorts the results, If some slices are time consuming, the main thread can trigger resharding when it detects this condition. Obviously, if the user stops rendering in the middle, the rendered result is useless to the user, just some scattered frames. But it is cache friendly because each frame is processe sequentially with in the time slice.
I saw that Blender has a lib for multi-thread. I am still learning these lib. I am currently preparing to implement the third strategy above.
I hope that you will be involved in the discussion.