DXGI_SWAP_EFFECT_DISCARD vs FLIP_DISCARD Explained
In DirectX Graphics Infrastructure (DXGI),
DXGI_SWAP_EFFECT_DISCARD and
DXGI_SWAP_EFFECT_FLIP_DISCARD determine how back-buffer
presentation is handled by the graphics subsystem. While both options
instruct the runtime to discard the contents of the back buffer after
presenting a frame, they use fundamentally different presentation models
under the hood. DXGI_SWAP_EFFECT_DISCARD relies on the
legacy bit-block transfer (BitBlt) model that copies buffer data,
whereas DXGI_SWAP_EFFECT_FLIP_DISCARD utilizes the modern
flip model, swapping surface pointers directly with the Desktop Window
Manager (DWM) to significantly reduce latency, lower memory overhead,
and support modern display features.
Presentation Mechanism
The core technical difference lies in how image data transitions from the rendering pipeline to the display:
- DXGI_SWAP_EFFECT_DISCARD (BitBlt Model): The runtime copies pixel data from the back buffer to the front buffer (or redirection surface managed by the DWM in windowed mode). Because the pixels must be physically copied across memory surfaces, it introduces redundant memory bandwidth consumption and rendering latency.
- DXGI_SWAP_EFFECT_FLIP_DISCARD (Flip Model): Instead of copying pixel data, the application shares its back-buffer surfaces directly with the DWM. Presenting a frame simply switches the internal pointer to the newly rendered buffer. Once the DWM finishes displaying the buffer, it is returned to the application to be reused, eliminating unnecessary copy operations.
Performance and Latency
DXGI_SWAP_EFFECT_FLIP_DISCARD provides substantial
performance gains over the legacy discard effect. In windowed and
borderless full-screen modes, the flip model bypasses the extra DWM
redirection copy step via a mechanism known as "Independent Flip" (or
True Immediate Independent Flip). This allows windowed applications to
achieve performance and input latency parity with traditional exclusive
full-screen mode without locking out the operating system's desktop
composition.
Hardware and Modern Feature Support
The flip model is required to access contemporary graphics innovations:
- Variable Refresh Rate (VRR): Features like G-SYNC,
FreeSync, and screen tearing toggles (using
DXGI_PRESENT_ALLOW_TEARING) in windowed applications require flip-model swap chains. - HDR (High Dynamic Range): Outputting wide-color-gamut and high-dynamic-range content properly requires DXGI flip presentation paths.
- DirectX Version Support: DirectX 12 strictly
enforces the use of modern flip swap effects;
DXGI_SWAP_EFFECT_DISCARDis invalid in DX12. DirectX 11 applications can use either, but Microsoft strongly recommends transitioning to the flip model.
Buffer Requirements and Compatibility
Implementing these two models requires slightly different swap chain configurations:
- Buffer Count:
DXGI_SWAP_EFFECT_DISCARDfunctions with a single back buffer (a total of one back buffer plus the front buffer). In contrast,DXGI_SWAP_EFFECT_FLIP_DISCARDrequires at least two back buffers (BufferCountset to 2 or greater) because the presentation engine holds onto one buffer while displaying it, requiring an additional buffer for concurrent rendering. - Operating System Support:
DXGI_SWAP_EFFECT_DISCARDis universally compatible with legacy platforms down to Windows Vista and Windows 7.DXGI_SWAP_EFFECT_FLIP_DISCARDwas introduced in DXGI 1.4 and requires Windows 10 or later (or Windows 8.1 usingDXGI_SWAP_EFFECT_FLIP_SEQUENTIAL).
Unless targeting legacy Windows platforms before Windows 10,
developers should always choose
DXGI_SWAP_EFFECT_FLIP_DISCARD for optimal frame pacing,
lower latency, and compatibility with modern display hardware.