r.D3D12.ExperimentalShaderModels
r.D3D12.ExperimentalShaderModels
#Overview
name: r.D3D12.ExperimentalShaderModels
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls whether D3D12 experimental shader models should be allowed. Not available in shipping builds. (default = 0).
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.D3D12.ExperimentalShaderModels is to control whether D3D12 experimental shader models should be allowed in non-shipping builds of the Unreal Engine.
This setting variable is primarily used in the D3D12RHI (Direct3D 12 Rendering Hardware Interface) module of Unreal Engine, specifically for Windows platforms. It’s part of the rendering system, focusing on shader model support for DirectX 12.
The value of this variable is set through a console variable (CVarExperimentalShaderModels) defined in the WindowsD3D12Device.cpp file. It’s initialized with a default value of 0, meaning experimental shader models are disabled by default.
The associated variable CVarExperimentalShaderModels interacts directly with r.D3D12.ExperimentalShaderModels. They share the same value and purpose.
Developers must be aware of several important points when using this variable:
- It’s only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
- It’s marked as ECVF_ReadOnly, meaning its value should not be changed at runtime.
- Enabling this feature (setting to 1) allows the use of experimental shader models, which may not be fully stable or supported on all hardware.
Best practices for using this variable include:
- Only enable it when specifically testing or developing features that require experimental shader models.
- Ensure thorough testing on various hardware configurations when enabled, as experimental features may have different levels of support across GPUs.
- Always disable it for final releases or when submitting to the marketplace, as it’s not available in shipping builds.
Regarding the associated variable CVarExperimentalShaderModels:
This is the actual console variable that controls the r.D3D12.ExperimentalShaderModels setting. It’s used in the FD3D12DynamicRHIModule::FindAdapter() function to determine whether to enable experimental features, specifically D3D12ExperimentalShaderModels.
When using this variable, developers should:
- Access its value using CVarExperimentalShaderModels.GetValueOnAnyThread() to ensure thread-safe access.
- Be aware that enabling experimental shader models may have performance implications or cause instability on some hardware.
- Use it in conjunction with other D3D12-specific optimizations and features for best results.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp:114
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarExperimentalShaderModels(
TEXT("r.D3D12.ExperimentalShaderModels"),
0,
TEXT("Controls whether D3D12 experimental shader models should be allowed. Not available in shipping builds. (default = 0)."),
ECVF_ReadOnly
);
#endif // !UE_BUILD_SHIPPING
#Associated Variable and Callsites
This variable is associated with another variable named CVarExperimentalShaderModels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp:113
Scope: file
Source code excerpt:
#if !UE_BUILD_SHIPPING
static TAutoConsoleVariable<int32> CVarExperimentalShaderModels(
TEXT("r.D3D12.ExperimentalShaderModels"),
0,
TEXT("Controls whether D3D12 experimental shader models should be allowed. Not available in shipping builds. (default = 0)."),
ECVF_ReadOnly
);
#endif // !UE_BUILD_SHIPPING
#Loc: <Workspace>/Engine/Source/Runtime/D3D12RHI/Private/Windows/WindowsD3D12Device.cpp:828
Scope (from outer to inner):
file
function void FD3D12DynamicRHIModule::FindAdapter
Source code excerpt:
#if !UE_BUILD_SHIPPING
if (CVarExperimentalShaderModels.GetValueOnAnyThread() == 1)
{
// Experimental features must be enabled before doing anything else with D3D.
UUID ExperimentalFeatures[] =
{
D3D12ExperimentalShaderModels