Because some of my graphics settings depend on it I want to be able to choose between DX11, DX12 and Vulkan from inside the game. As far as I know, this choice is stored simply as a string per platform:
How does UE4 / UE5 handle RHI these days? Is it still advised to let the end user set this mode manually, or can / should the engine get the most optimal mode automatically, based on for example the features (raytracing etc) + hardware compatibility + performance estimation? What is the correct RHI library to call for these things?
RHI is chosen by the project settings (first DefaultGraphicsRHI, then TargetedRHIs are consulted, Default maps to D3D12). After this, a separate game-only setting (does not affect editor) bPreferD3D12InGame selects between D3D12 or D3D11 (but will not have any effect if Vulkan or OpenGL are chosen). Commandline switches apply after this and can force an arbitrary RHIs. If RHI isn’t supported, the game will refuse to start.
If you set a breakpoint on that call, you can see the call chain to get there.
and it’s a complex thing. It sure doesn’t look like it is meant to be modified later on.
I’m pretty sure some games allow swapping DX versions during gameplay without a restart but I can think of quite a few which don’t.
I assume this means I should just implement a user friendly way to notify that the game needs a restart.