Is there a function that I can call so that the Direct3D12 device doesn't get removed for taking too long?

189 Views Asked by At

I am currently building a Direct3D12 game engine in C++ and I'm currently implementing PBR. I attempted to compute an irradiance map for ambient lighting but I keep getting a TDR delay. I do not yet understand compute shaders so instead, I render each face of the skybox individually into a texture and then I copy that into a face of the cubemap. After generating each face, I wait for the operation to complete before doing the next face. Unless the pixel shader just returns a solid color or if only do one face, then the device always gets removed for taking too long.

I tried not waiting for the commands to complete but then it just crashes on present. I tried copying my opengl shader from a previous project that never caused a TDR delay but that didn't work.

Is there some way to let windows know that my app isn't frozen? Do I have to use compute shaders or multiple threads? The full source can be found here

2

There are 2 best solutions below

3
Chuck Walbourn On

Creating a command queue using D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT will prevent the "an individual DMA transfer is taking more than 2 seconds" TDR timeouts.

This does not suppress TDRs from the graphics queue or compute queue being tied up too long for multi-tasking to work. See DXGI_ADAPTER_DESC2.GraphicsPreemptionGranularity and DXGI_ADAPTER_DESC2.ComputePreemptionGranularity.

Otherwise, for the local machine you can modify the regkeys that controls TDR timeouts.

0
Lucas Jorgenson On

I found the solution! My mistake was that I had the transformation matrix and sampleCount constant buffers bound to the same register and so the sample count was probably getting set very high accidentally. I just changed the register of the sampleCount and it works now