#surfman #swap #chain #context #surface #back #double-buffered

surfman-chains

An implementation of double-buffered swap chains for surfman

11 releases (7 breaking)

0.8.0 Jun 16, 2023
0.7.0 Feb 28, 2023
0.6.0 Mar 5, 2021
0.5.1 Aug 7, 2020
0.1.1 Nov 8, 2019

#37 in #surface

Download history 303/week @ 2024-06-10 85/week @ 2024-09-23

85 downloads per month

MPL-2.0 license

33KB
633 lines

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.

Dependencies

~1–16MB
~143K SLoC