An implementation of thread-safe swap chains for the
surfman surface manager.
The role of a swap chain is to allow surfaces to be communicated between contexts, often in different threads. Each swap chain has a producer context, responsible for creating and destroying surfaces, and a number of consumer contexts, (usually just one) which take surfaces from the swap chain, and return them for recycling.
Each swap chain has a back buffer, that is the current surface that the producer context may draw to. Each swap chain has a front buffer, that is the most recent surface the producer context finished drawing to.
The producer may swap these buffers when it has finished drawing and has a surface ready to display.
The consumer may take the front buffer, display it, then recycle it.
Each producer context has one attached swap chain, whose back buffer is the current surface of the context. The producer may change the attached swap chain, attaching a currently unattached swap chain, and detatching the currently attached one.
A thread-safe swap chain.
A thread-safe collection of swap chains.
The consumer’s view of a swap chain
The consumer’s view of a collection of swap chains