Download

What is the RHI thread?What is the difference between RHI thread and rendering thread

Hi,all,
currently ,I am trying to read the source code of UE4.6.1. when I gone through the code regarding rendering, beside the rendering thread,I have found there is a thread called RHI thread with its own command list.I have read the document about the “graphic programming”.but it say nothing about it,is there some one can tell me the role of RHI thread and difference between RHI thread and Rendering Thread?
Thanks in advance!

RHI = Render Hardware Interface. So if running on windows, the current RHI would be d3d11 or opengl.

The RHI thread is a new development so hasn’t been documented yet. Some part of the renderer’s work is visibility and scene traversal, and the rest of the work is submitting RHI commands (sending commands to the graphics hardware). With the parallel rendering work, we’re trying to split that work onto as many cores as possible. Visibility stays on the rendering thread. Scene traversal has been moved onto multiple threads with a task system.

But here’s the problem - d3d11 has botched parallel command submission. It’s much faster to submit all commands from one thread, and this thread used to be the rendering thread. This is where the RHI thread comes in, it allows us split Visibility and RHI command submission onto two different threads in d3d11.

Thank you for reply,but how to compile the source code make the RHIThread actually work.is there any preprocessor macro defined to enable the feature?

Will the RHI threading be more useful in DX12? I notice that DX12 mentions some optimisations provide a ten-fold increase in the number of polygons that can be handled - would that be related to fixing that botched threading?

It is used by default, in fact you have to launch with ‘-norhithread’ to disable it.

D3D12 will allow parallel command list building, which D3D11 did not (efficiently). Ideally the engine will do less and less work on the RHI thread and more work in command list building tasks. This can enable massive parallelization of rendering. However, a huge amount of work has to be done to refactor the renderer to get those gains.

In summary, the RHI thread is a temporary measure to get graphics API overhead off of the rendering thread, until graphics API’s come around (like Vulkan and D3D12) that can properly support parallel command list creation.