DXGI Flip Model Upgrade
Forces the DXGI flip model and tearing support in Direct3D 11 and 12 games, so windowed/borderless games can reach Independent Flip and run uncapped with VSync off
Author: tria
Important: restart the game after this mod gets disabled, updated or
reloaded while the game runs. The game keeps its upgraded swap chains, which
need the mod for resizing and for keeping its render targets bound, so it may
show a frozen or black picture, or fail. That includes mod updates that
Windhawk installs automatically in the background. If you play with this mod
enabled, consider turning off automatic updates for it.
Many Direct3D 11 games present with the legacy blt model
(DXGI_SWAP_EFFECT_DISCARD or SEQUENTIAL): in a window or borderless window,
every frame is copied and composed by DWM, which adds latency and blocks
Independent Flip. PresentMon reports them as Composed: Copy with GPU GDI.
Many games also never enable tearing, so with VSync off they're still capped
at the refresh rate in a window.
This mod changes the swap chains the game creates:
- Force flip model: blt model swap chains of Direct3D 11 games use the flip
model instead (
FLIP_DISCARD or FLIP_SEQUENTIAL). Once the game window
covers the whole screen, DWM can promote it to Independent Flip.
- Force allow tearing: flip model swap chains of Direct3D 11 and 12 games
allow tearing, and frames presented with VSync off show immediately.
- Maximum frame latency, Waitable swap chain and Force borderless
are off by default, see their descriptions in the settings.
Windows 11 has a similar system-wide option, "Optimizations for windowed
games", for Direct3D 10 and 11. This mod applies per game, also works on
Windows 10, and adds tearing.
How to enable the mod for a program
This mod doesn't target any process by default. In Windhawk, go to the mod's
"Advanced" tab and scroll down to "Custom process inclusion list". In that box,
put the filename of the game's .exe, then click "Save" and (re)start the game.
Only swap chains created while the mod is loaded are changed.
How to verify
Use PresentMon (or an overlay that
shows the presentation mode, such as RTSS). With the flip model, the game should
show Hardware: Independent Flip or Hardware Composed: Independent Flip in
borderless fullscreen, and Composed: Flip in a smaller window. With tearing
and VSync off, the frame rate can go above the refresh rate. The log says what
was changed for each swap chain, and why something wasn't.
Known limitations
- Not changed to the flip model: swap chains with a multisampled back buffer,
swap chains created in exclusive fullscreen (those already get flip
presentation through Fullscreen Optimizations), Direct3D 10 games, and back
buffer formats the flip model doesn't support.
- sRGB back buffers aren't supported by the flip model, so their format becomes
the non-sRGB one. Render target views the game creates for them still get the
sRGB format, but a game that reads the back buffer format sees the other one.
- The flip model only shows what the game renders with Direct3D. Anything drawn
into the game window with GDI disappears.
- Tearing doesn't apply in exclusive fullscreen.
- With Force borderless, the game runs at the desktop resolution, and its
picture is stretched if it renders at another one. The game is told it's in
fullscreen. Alt+Enter is turned off for those swap chains, as it would switch
to exclusive fullscreen behind the mod's back.
- With Waitable swap chain, games that already use a waitable swap chain
keep their own settings.
- If the game loads
dxgi.dll only after it started, the mod's hooks are
installed a moment after that, and a swap chain the game creates right away
may keep the blt model. The log then shows no "Hooked" lines before that swap
chain.
Anti-cheat
Don't use this mod in online games protected by anti-cheat. It loads code
into the game and hooks DXGI and Direct3D 11 functions:
CreateDXGIFactory, CreateDXGIFactory1 and CreateDXGIFactory2,
IDXGIFactory::CreateSwapChain and IDXGIFactory2::CreateSwapChainForHwnd,
IDXGISwapChain::Present, Present1, ResizeBuffers, ResizeBuffers1,
SetFullscreenState, GetFullscreenState and ResizeTarget,
IDXGIDevice1::SetMaximumFrameLatency and
ID3D11Device::CreateRenderTargetView. It hooks no Windows loader or kernel
functions, such as LoadLibraryExW in kernelbase.dll: if dxgi.dll isn't
loaded yet when the mod starts, the mod learns about it through a Windows DLL
load notification, and a thread of the mod installs the hooks. With Force
borderless, another thread changes the game window. Present hooks are also
how cheats draw overlays, so anti-cheat software may block the game, kick you
or ban your account. There are no guarantees for any game.
Enable the mod's logging (Advanced → Debug logging) to see what happens.