Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Shader TDR timeout issue

Discussion in 'Shaders' started by TOES, Dec 6, 2018.

  1. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    I have an issue with a shader that has a loop that purposedly takes more than 2 seconds to complete (it is a tool for generating data for a game, too time consuming to do on the CPU), and it is detected like it is hanging and the Windows TDR system shuts it down.

    I assume this is a problem for anyone doing heavy Compute shader work on the GPU.

    If you code DirectX applications it is supposedly possible to disable TDR, by using D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT when generating the graphics device.

    How to achieve this with Unity?

    BTW, I also tried to edit the registry using this info:

    https://docs.microsoft.com/en-gb/windows-hardware/drivers/display/tdr-registry-keys

    But it looks like the page is outdated, as I could not find any of the keys mentioned. Also, it is too hackish and not future proof.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,387
    Have you tried using asycn compute with a background priority?
    https://docs.unity3d.com/ScriptReference/Graphics.ExecuteCommandBufferAsync.html
    https://docs.unity3d.com/ScriptReference/Rendering.ComputeQueueType.Background.html

    TDR is going to kill a process that isn't responsive, and if it's the CPU is stalling waiting for a compute shader to complete it'll appear unresponsive. If you issue a compute shader as an async background process, it might take a little bit longer to finish, but the application will not become unresponsive, and TDR shouldn't notice anything.

    edit: except ... this might cause a problem here:
    https://docs.unity3d.com/ScriptReference/SystemInfo-supportsAsyncCompute.html
     
    Last edited: Dec 6, 2018
  3. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    Thank you for your reply. I'm not sure if the above would work, however, I did find a solution. In NVIDIAs Nsight Monitor you can both set a custom TDR timeout, or even disable it completely (if you feel lucky):

    http://developer.download.nvidia.co...e/HTML/Content/Timeout_Detection_Recovery.htm

    This resolved the problem for me. :)

    The only drawback is someone with Admin priveliges has to manually do the above on the computer running the tool, but in our case that is not an issue since it is just an internal tool anyway.