Search code examples
directx-12windows-11directxtk

DirectX 12 application is crashing in Windows 11


I'm quite a ways into a DirectX 12 desktop x64 application built upon several of the DirectX Tool Kit examples, but now also supports custom shaders for directional and omnidirectional shadows, dynamic reflections, a hardware-instanced particle effect system, FBX model skeletal animation, and depth of field post-processing.

On Halloween, Windows Update upgraded my system (Intel Core i7[8th Gen]/GeForce GTX1050) to Windows 11. When I ran my project, I received a spooky surprise in the form of the following 'Source Not Available' window:

enter image description here

After stopping the debug, the application was crashing at the Present() call in DeviceResources.cpp and generating the following error:

D3D12 ERROR: ID3D12CommandQueue::Present: Resource state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) (promoted from COMMON state) of resource (0x0000011BD5330080:'Render target 0') (subresource: 0) must be in COMMON state when transitioning to use in a different Command List type, because resource state on previous Command List type : D3D12_COMMAND_LIST_TYPE_COPY, is actually incompatible and different from that on the next Command List type : D3D12_COMMAND_LIST_TYPE_DIRECT. [ RESOURCE_MANIPULATION ERROR #990: RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE]
D3D12: **BREAK** enabled for the previous message, which was: [ ERROR RESOURCE_MANIPULATION #990: RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE ]
Exception thrown at 0x00007FFA0F6A466C (KernelBase.dll) in DXTK12 Game.exe: 0x0000087A (parameters: 0x0000000000000001, 0x00000014297FC640, 0x00000014297FE420).
Unhandled exception at 0x00007FFA0F6A466C (KernelBase.dll) in DXTK12 Game.exe: 0x0000087A (parameters: 0x0000000000000001, 0x00000014297FC640, 0x00000014297FE420).

This never occurred in Windows 10 and what's more, this crash is unstable. My game is configured to start in borderless fullscreen mode, and can sometimes run for a few seconds before crashing. If I have time to Alt+Enter to windowed mode, the app will still crash.

I've updated my Nvidia driver and have pointed the project to the latest Windows 11 SDK version (10.0.22000.0) but the problem persists.

After some googling, there's evidence to suggest there's a known issue concerning erratic DXGI/WDM behaviour on Windows 11 that's been reported by users running games in emulated fullscreen (i.e. borderless windowed) mode. I was also experiencing faulty Alt+Tab window switching behaviour following a crash, but this seems to have been fixed by the graphics driver update.

Have any other developers been experiencing stability and/or performance issues with DirectX 12 on Windows 11? Or should I just sit tight and wait for future Windows updates to stabilise the new OS?


Solution

  • This is a bug in the DXGI Debug Layer interaction with the DX12 Debug Layer w/ Windows 11. There's a simple workaround which is to suppress D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE. The bug itself will be fixed in a future Windows update.

    The Debug Layer has always had quirks when it comes to dealing with 'hybrid graphics' systems (i.e. laptops with both Intel Integrated and discrete GPUs), so I have a few suppressions in the DeviceResources implementation related to it:

    DXGI_INFO_QUEUE_MESSAGE_ID hide[] =
    {
        80 /* IDXGISwapChain::GetContainingOutput: The swapchain's adapter does not control the output on which the swapchain's window resides. */,
    };
    DXGI_INFO_QUEUE_FILTER filter = {};
    filter.DenyList.NumIDs = static_cast<UINT>(std::size(hide));
    filter.DenyList.pIDList = hide;
    dxgiInfoQueue->AddStorageFilterEntries(DXGI_DEBUG_DXGI, &filter);
    
    D3D12_MESSAGE_ID hide[] =
    {
        D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE,
        D3D12_MESSAGE_ID_UNMAP_INVALID_NULLRANGE,
        // Workarounds for debug layer issues on hybrid-graphics systems
        D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE,
        D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE,
    };
    D3D12_INFO_QUEUE_FILTER filter = {};
    filter.DenyList.NumIDs = static_cast<UINT>(std::size(hide));
    filter.DenyList.pIDList = hide;
    d3dInfoQueue->AddStorageFilterEntries(&filter);
    

    The workaround is included in the October 2021 release of my Direct3D Game template VSIX. See this commit

    The D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE error can trigger during "lost device" handling on hybrid-graphics systems. This issue was introduced in Windows 10 (18363). It should be fixed now, so in theory you can remove that suppression for Windows 11. Added suppression in this commit.

    The "IDXGISwapChain::GetContainingOutput" DXGI warning was introduced in Windows 10 (17134). Added suppression in this commit.