example_win32_directx12 crashes at startup in debug mod #9084
Replies: 13 comments
-
|
Hmm, maybe @RT2Code would know? |
Beta Was this translation helpful? Give feedback.
-
|
It's not exactly a crash : In the imgui D3D12 example, the debug layer is configured to trigger an exception on warnings, that's why it works if you remove this line :
Can you double check that you are indeed using the latest imgui commit to rule that out? I can't reproduce this on my end, but the only explanation I can think of for this warning to still appear after #8961 is that resizing is being triggered before the first frame is drawn, which would cause WaitForPendingOperations to run while the fence value is still 0. Could you try the following fix? In if (g_fenceLastSignaledValue == 0)
return;Then in if (bd->FenceLastSignaledValue == 0)
return;Let me know if this resolves the issue. |
Beta Was this translation helpful? Give feedback.
-
|
I just cloned again https://github.com/ocornut/imgui.git to be sure and I switched to docking, so yes I think I'm at the latest. I added at the start of WaitForPendingOperations this code and indeed it showed that it returned. I also added the return if bd->FenceLastSignaledValue is 0 inside imgui_impl_dx12.cpp, but it was not called before the crash. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for trying my suggestion. I’m really puzzled by your issue because, after carefully re-reading the synchronization code, I can’t find any path where
The only theoretical way to end up with a fence value of 0 is if it overflowed after reaching UINT64_MAX. But that would require running the program for an absurd amount of time (around 4.8 billion years at 120 FPS), so we can safely rule that out as well. 😛 Could you try adding assert(fence_value > 0) immediately before each call to SetEventOnCompletion and see if any of them trigger (Don’t forget to remove the checks I asked you to add earlier)? That would confirm the warning and give us a starting point to track down the issue. A copy of your callstack would also be very useful. |
Beta Was this translation helpful? Give feedback.
-
|
I hope I did it right, I added two asserts, but none of them triggered. Only the first one was called only once with "1" for g_fenceLastSignaledValue The full stack trace is (before modifying the code) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I just cloned at the latest 1.9.5 version in docking branch, to be sure. Here are the dll versions I have in Visual Studio |
Beta Was this translation helpful? Give feedback.
-
|
After looking into this further, I found this discussion on the Unreal Engine developer forum: https://forums.unrealengine.com/t/running-a-game-with-d3ddebug-spams-with-fence-zero-wait/2618843/2 I had the same suspicion, that this is a bug in the D3D12 SDK layer. As I explained in my previous post, with the new synchronization logic it’s impossible for I'd like you to try the following fix: In main.cpp, disable breaking on the // [DEBUG] Setup debug interface to break on any warnings/errors
#ifdef DX12_ENABLE_DEBUG_LAYER
if (pdx12Debug != nullptr)
{
ID3D12InfoQueue* pInfoQueue = nullptr;
g_pd3dDevice->QueryInterface(IID_PPV_ARGS(&pInfoQueue));
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, true);
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_CORRUPTION, true);
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true);
pInfoQueue->SetBreakOnID(D3D12_MESSAGE_ID_FENCE_ZERO_WAIT, false); // Add this line to disable breaking on this specific warning
pInfoQueue->Release();
pdx12Debug->Release();
}
#endifThis should fix your issue. If it does, I'll submit a new PR with this change. |
Beta Was this translation helpful? Give feedback.
-
|
I just tested tested your proposed solution to add |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for testing. I wrongly assumed this would be enough to disable breaking on this warning, but this is clearly not. Try this instead: // [DEBUG] Setup debug interface to break on any warnings/errors
#ifdef DX12_ENABLE_DEBUG_LAYER
if (pdx12Debug != nullptr)
{
ID3D12InfoQueue* pInfoQueue = nullptr;
g_pd3dDevice->QueryInterface(IID_PPV_ARGS(&pInfoQueue));
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, true);
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_CORRUPTION, true);
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true);
D3D12_MESSAGE_ID disabledMessages[] = { D3D12_MESSAGE_ID_FENCE_ZERO_WAIT };
D3D12_INFO_QUEUE_FILTER filter = {};
filter.DenyList.NumIDs = 1;
filter.DenyList.pIDList = disabledMessages;
pInfoQueue->AddStorageFilterEntries(&filter);
pInfoQueue->Release();
pdx12Debug->Release();
}
#endif |
Beta Was this translation helpful? Give feedback.
-
|
yes ! it works |
Beta Was this translation helpful? Give feedback.
-
|
Awesome. The PR is up : #9093 Thanks for reporting this and for helping to fix the issue. |
Beta Was this translation helpful? Give feedback.
-
|
Pushed fix f0699ef. I forgot to include the changelog blurb it'll come in a next commit. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the docking branch on commit eae6e96 Nov 19, 2025.
When I compile the example_win32_directx12 in debug mode x64 on my Windows 11 with Visual Studio 22, and then try to run the generated exe, the GUI appears as a white window that seems to try to load for 5-10 secs, and then it closes unexpetedly without showing any error.
If I start the debugger inside Visual Studio for this example, it shows the following in the output
D3D12 WARNING: ID3D12Fence1::SetEventOnCompletion: Fence values can never be less than zero, so waiting for a fence value of zero will always be satisfied [ EXECUTION WARNING #1424: FENCE_ZERO_WAIT]
D3D12: BREAK enabled for the previous message, which was: [ WARNING EXECUTION #1424: FENCE_ZERO_WAIT ]
Exception thrown at 0x00007FFA261380DA (KernelBase.dll) in example_win32_directx12.exe: 0x0000087A (parameters: 0x0000000000000002, 0x000000956ADDBDE8, 0x000000956ADDCB90).
and at the same time it shows that the exception occured at this line of code
HRESULT result = g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), desc.Format, desc.Flags);
I found out that if I comment out this line
pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true);
it no longer crashes.
Beta Was this translation helpful? Give feedback.
All reactions