0

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 Answers2

1

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.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • It does not work. I set the flag of the command queue desc to D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT but it still gives me the error 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 command queue creation is at https://github.com/LucoseGlucose/DragonEngine/blob/master/Engine/Graphics/CommandQueue.cpp – Lucas Jorgenson Mar 02 '23 at 04:53
  • Have you submitted any work to the queue? – Chuck Walbourn Mar 02 '23 at 05:12
  • Yes, I submit all commands, like generating mipmaps, and uploading vertex buffers, to the queue. I only have one command queue – Lucas Jorgenson Mar 02 '23 at 11:45
0

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