microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.5k stars 395 forks source link

GenerateMips is causing TDR #132

Closed venki-thiyag closed 1 year ago

venki-thiyag commented 2 years ago

When using GenerateMips API, driver is resulting in TDR. Not sure of what is actually causing this problem.

Debug layers were enabled, following is the output which was received:

D3D12 ERROR: ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_DEVICE_HUNG: The Device took an unreasonable amount of time to execute its commands, or the hardware crashed/hung. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when the hang occurred. The application may want to respawn and fallback to less aggressive use of the display hardware). [ EXECUTION ERROR #232: DEVICE_REMOVAL_PROCESS_AT_FAULT]

Any idea on how to proceed further?

venki-thiyag commented 2 years ago

To provide more details: 1) Format is DXGI_FORMAT_R8G8B8A8_UNORM 2) Image size is 640x360 3) Number of mips to be generated is 4 4) TypedUAVLoadAdditionalFormats is supported and StandardSwizzle64KBSupported is not supported

Sometime mipmap generation works and sometimes it doesn't

walbourn commented 2 years ago

What GPU are you using?

venki-thiyag commented 2 years ago

DxDiag output:

[DxDiag.txt](https://github.com/microsoft/DirectXTK12/files/8896869/DxDiag.txt)

Another observation, I have 2 monitor setup:

Primary monitor: 3840x2400 Secondary monitor: 1920x1080

Issue is seem when application window is moved to secondary monitor, whereas not observed when application window is in primary monitor.

Application architecture: 1) WinUI3, rendering using D3D11 integrated using composition 2) Camera capture using D3D11 device manager -> background blur using WinML (D3D12) -> Mipmap generation -> merge of camera output + WinML output + mipmap blur

We have other blur algorithms, which works perfectly fine.

walbourn commented 2 years ago

Sorry, the attachment is missing.

It's likely a driver bug, but you could try D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT.

venki-thiyag commented 2 years ago

Added D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT, since all processing is happening using D3D12. With this change, MipMap generation is working, also I had to wait for execution completion after ExecuteCommandLists API is called.

Any concerns with respect to using the timeout flag?

Upon further testing, I see that sometimes, MipMap generation works and sometimes it doesn't work, but TDR is gone. Also when debug is enabled, then it seems to work consistently.

Any further ideas?

walbourn commented 2 years ago

I suggest reporting this as a driver bug to Intel.