找回密码
 立即注册
查看: 340|回复: 0

Unreal Engine中的RHI线程

[复制链接]
发表于 2020-11-25 09:19 | 显示全部楼层 |阅读模式
1.专家解答
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.
2.为什么要搞个RHI线程
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.
3.总结
最开始UE是没有RHI线程的,只有游戏线程和渲染线程,游戏线程主要做游戏逻辑运算,渲染线程主要做场景遍历和可见性剔除,并且还要提交渲染命令到GPU中。后来为了加快渲染线程的计算能力,把场景遍历放到了task system中的其他线程上了,可见性剔除则继续留在渲染线程中。
这个时候产生了一个新问题,提交渲染命令这些工作放到哪里呢?
本来提交渲染命令是不耗时的,大多数平台支持并行化提交渲染命令,即CPU提交完渲染命令后不会卡顿,但是在某些平台上比如d3d11,提交渲染命令不支持并行化。为了解决这个问题,提交渲染命令是最初是放到渲染线程的,后来为了加快渲染线程的计算,把提交渲染命令单独抽到了一个线程,这个线程就是RHI线程。
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-19 11:45 , Processed in 0.098970 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表