Developer knowledge network · moderated exchange

مجتمع الكود غير الموثوق به

أبحاث المطورين، مجتمع الهندسة العكسية والترميز

Knowledge indexيعيش
4Categories
919Threads
2.8Kدعامات
Guide

Handling DirectX 11 ResizeBuffers & Device Reset on Alt-Tab fullscreen switches

dx12_render_dev
DX12 Master
MEMBER
مندوب: 55
تاريخ الانضمام: Oct 2020
دعامات: 9
شكرًا: 65
1 months ago · Jul 13, 2026 4:00 AM
#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 months ago · Jul 13, 2026 6:22 AM
#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 months ago · Jul 13, 2026 11:36 PM
#3

Essential hook for any reliable internal DirectX overlay.