How to toggle between DX10, DX11, DX12 and via Blueprint?

To understand how to do it you need to understand how renderer is structured. UE4 for sake of code compatibility has common rendering interface Rendering Hardware Interface (RHI) for graphical libraries, similar concept to OnlineSubsystems if you seen that. Each library has it’s own RHI implmentation, in Windows you have D3D11 D3D12, OpenGL and Vulcan.

Now switch between them on runtime is kind of imposssible as if you look in this code:

https://github.com/EpicGames/UnrealEngine/blob/f794321ffcad597c6232bc706304c0c9b4e154b2/Engine/Source/Runtime/RHI/Private/Windows/WindowsDynamicRHI.cpp

RHI is decided on start up and thats it. But as you can see in there you can override RHI used by adding command line options on start up of your game

-d3d12, -d3d11, -d3d10, -, -opengl, -opengl3, -opengl4

So easiest way is to just create BAT files to run specific option and make user run proper one. You could technically make game run another instance of it self and then exit, so new instance of the game runs in selected RHI, but problem here is how to save this option, you would need to make some external aplication that would manage that.

Either way your options are quite limited in blueprints because by defaut (or else you get some plugin that can do so) you can exec external applications via blueprints to even do this engine restart trick. So your best bet is BATs or maybe make a game launcher which will run game with proper option, you can use anything here. Maybe submit feature request in feedback forum to have even ability to include preferable RHI options in config, then you would just need to do console command, as it really seems like a missing option to have.

Also impotent thing whatever you do, in order for RHI code modules to be included in your package game and even have a option to run game on specific one you need to mark them as targeted RHIs. To do so go to Project Settings-> Platfrom->Windows and there you will have a list of avable RHI which you want to be packaged with the game.

Also note that command line options work in editor too, you can start up editor in any RHI avable for Windows

2 Likes