C++11 lock-free command buffer implementation for multi-thread rendering

C++11 lock-free command buffer implementation for multi-thread rendering

In this post I will present a C++ lock-free and API agnostic command buffer implementation that can be used for multi-threaded rendering and reducing overhead (state changes, depth sorting) on the main thread. It also includes a configurable draw key class (via bitfields), implementation of some basic GL commands and supports multiple material passes. Commands will be dispatched into one or more of the command buffers from multiple threads (main thread can also participate as it shouldn’t be idle waiting), after which you’ll have to wait until all commands are dispatched and it’s safe to sort and submit the commands (to the graphics driver) on the main thread:

Note that in some cases certain command buffers dont require frequent updates (for example the post processing command buffer) as they only need to be updated when something changes.

Source: alinloghin.com