Developer knowledge network · moderated exchange

Сообщество UnreliableCode

Сообщество разработчиков, обратного проектирования и кодирования

Guide

Handling DirectX 11 ResizeBuffers & Device Reset on Alt-Tab fullscreen switches [v2.4 Technical Discussion]

dx12_render_dev
DX12 Master
MEMBER
Представитель: 55
Дата присоединения: Oct 2020
Сообщения: 9
Спасибо: 65
1 месяцев назад · Jul 3, 2026 4:08 PM
#1

Why internal DirectX 11 overlays crash when the user Alt-Tabs or changes display resolution:

When resolution changes, the game calls IDXGISwapChain::ResizeBuffers. If your overlay still holds references to the ID3D11RenderTargetView, ResizeBuffers fails with DXGI_ERROR_INVALID_CALL and crashes!

The Fix:
Hook ResizeBuffers (VTable index 13):

CPP
HRESULT __stdcall hkResizeBuffers(IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags) {
    if (g_pRenderTargetView) {
        g_pContext->OMSetRenderTargets(0, nullptr, nullptr);
        g_pRenderTargetView->Release();
        g_pRenderTargetView = nullptr;
    }
    HRESULT hr = oResizeBuffers(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
    CreateRenderTarget(pSwapChain); // Recreate RTV for new backbuffer
    return hr;
}
imgui_artisan
UI Designer
MEMBER
Представитель: 202
Дата присоединения: Apr 2019
Сообщения: 54
Спасибо: 28
1 месяцев назад · Jul 3, 2026 8:20 PM
#2

Releasing the render target view in hkResizeBuffers before calling original completely eliminates Alt-Tab crashes!

ptr_arithmetic
C++ Wizard
MEMBER
Представитель: 162
Дата присоединения: May 2018
Сообщения: 73
Спасибо: 42
1 месяцев назад · Jul 4, 2026 5:59 AM
#3

Essential hook for any reliable internal DirectX overlay.