r.SupportAllShaderPermutations

r.SupportAllShaderPermutations

#Overview

name: r.SupportAllShaderPermutations

This variable is created as a Console Variable (cvar).

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.SupportAllShaderPermutations is to force all shader permutation features on, acting as a local user config override. This variable is primarily used in the rendering system of Unreal Engine 5.

The Unreal Engine subsystems that rely on this setting variable are mainly within the Renderer module and RenderCore module. It’s used in various parts of the rendering pipeline, particularly in base pass rendering, shadow depth rendering, and lightmap rendering.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s off by default. The variable can be changed at runtime through console commands.

This variable interacts with several other variables in the rendering system. It’s often used in conjunction with other specific feature support variables to determine whether certain shader permutations should be compiled or used.

Developers must be aware that enabling this variable (setting it to non-zero) will force the compilation and potential use of all shader permutations. This can significantly increase shader compilation time and memory usage, and should generally only be used for debugging or development purposes.

Best practices when using this variable include:

  1. Keep it disabled (set to 0) for normal development and shipping builds to optimize performance and resource usage.
  2. Use it sparingly and only when necessary for debugging shader issues or when developing new shader features.
  3. Be aware of the performance implications when enabling it, especially on lower-end hardware.

Regarding the associated variable CVarSupportAllShaderPermutations:

This is essentially the same variable as r.SupportAllShaderPermutations, just accessed through a different method. It’s used in the same way and for the same purpose. The difference is that CVarSupportAllShaderPermutations is typically used within C++ code to directly access the console variable’s value, while r.SupportAllShaderPermutations is the string used to set or query the variable through console commands.

The best practices and considerations for CVarSupportAllShaderPermutations are the same as for r.SupportAllShaderPermutations. Developers should treat them as two ways to access the same underlying setting.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:77

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarSupportAllShaderPermutations(
	TEXT("r.SupportAllShaderPermutations"),
	0,
	TEXT("Local user config override to force all shader permutation features on."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarParallelBasePass(
	TEXT("r.ParallelBasePass"),

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:65

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const auto CVarSupportLowQualityLightmaps = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportLowQualityLightmaps"));
	const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
	const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));	
	const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));	
	const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
	const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
	
	const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
	const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:294

Scope (from outer to inner):

file
class        class TBasePassVS : public TBasePassVertexShaderBaseType<LightMapPolicyType>
function     static bool ShouldCompilePermutation

Source code excerpt:

	static bool ShouldCompilePermutation(const FMeshMaterialShaderPermutationParameters& Parameters)
	{
		static const auto SupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
		const bool bForceAllPermutations = SupportAllShaderPermutations && SupportAllShaderPermutations->GetValueOnAnyThread() != 0;
		bool bShouldCache = Super::ShouldCompilePermutation(Parameters) || bForceAllPermutations;
		return bShouldCache && (IsFeatureLevelSupported(Parameters.Platform, ERHIFeatureLevel::SM5));
	}

	static void ModifyCompilationEnvironment(const FMeshMaterialShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:445

Scope (from outer to inner):

file
class        class TBasePassCS : public TBasePassComputeShaderBaseType<LightMapPolicyType>
function     static bool ShouldCompilePermutation

Source code excerpt:

		// Only compile skylight version for lit materials, and if the project allows them.
		static const auto SupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
		static const auto SupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));

		const bool IsSingleLayerWater = Parameters.MaterialParameters.ShadingModels.HasShadingModel(MSM_SingleLayerWater);

		const bool bTranslucent = IsTranslucentBlendMode(Parameters.MaterialParameters);
		const bool bForceAllPermutations = SupportAllShaderPermutations && SupportAllShaderPermutations->GetValueOnAnyThread() != 0;
		const bool bProjectSupportsStationarySkylight = !SupportStationarySkylight || SupportStationarySkylight->GetValueOnAnyThread() != 0 || bForceAllPermutations;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.h:584

Scope (from outer to inner):

file
class        class TBasePassPS : public TBasePassPixelShaderBaseType<LightMapPolicyType>
function     static bool ShouldCompilePermutation

Source code excerpt:

		// Only compile skylight version for lit materials, and if the project allows them.
		static const auto SupportStationarySkylight = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportStationarySkylight"));
		static const auto SupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));

		const bool IsSingleLayerWater = Parameters.MaterialParameters.ShadingModels.HasShadingModel(MSM_SingleLayerWater);

		const bool bTranslucent = IsTranslucentBlendMode(Parameters.MaterialParameters);
		const bool bForceAllPermutations = SupportAllShaderPermutations && SupportAllShaderPermutations->GetValueOnAnyThread() != 0;
		const bool bProjectSupportsStationarySkylight = !SupportStationarySkylight || SupportStationarySkylight->GetValueOnAnyThread() != 0 || bForceAllPermutations;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/LightMapRendering.cpp:49

Scope (from outer to inner):

file
function     bool LightMapPolicyImpl::ShouldCompilePermutation

Source code excerpt:

{
	static const auto CVarProjectCanHaveLowQualityLightmaps = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportLowQualityLightmaps"));
	static const auto CVarSupportAllShadersPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
	const bool bForceAllPermutations = CVarSupportAllShadersPermutations && CVarSupportAllShadersPermutations->GetValueOnAnyThread() != 0;

	// if GEngine doesn't exist yet to have the project flag then we should be conservative and cache the LQ lightmap policy
	const bool bProjectCanHaveLowQualityLightmaps = bForceAllPermutations || (!CVarProjectCanHaveLowQualityLightmaps) || (CVarProjectCanHaveLowQualityLightmaps->GetValueOnAnyThread() != 0);

	const bool bShouldCacheQuality = (LightmapQuality != ELightmapQuality::LQ_LIGHTMAP) || bProjectCanHaveLowQualityLightmaps;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:316

Scope (from outer to inner):

file
class        class TShadowDepthVS : public FShadowDepthVS
function     static bool ShouldCompilePermutation

Source code excerpt:

		const EShaderPlatform Platform = Parameters.Platform;

		static const auto SupportAllShaderPermutationsVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));
		const bool bForceAllPermutations = SupportAllShaderPermutationsVar && SupportAllShaderPermutationsVar->GetValueOnAnyThread() != 0;
		const bool bSupportPointLightWholeSceneShadows = CVarSupportPointLightWholeSceneShadows.GetValueOnAnyThread() != 0 || bForceAllPermutations;

		// Mobile only needs OutputDepth, and optionally PerspectiveCorrect
		if (!IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5) &&
			!(ShaderMode == VertexShadowDepth_OutputDepth || 

#Associated Variable and Callsites

This variable is associated with another variable named CVarSupportAllShaderPermutations. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:65

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const auto CVarSupportLowQualityLightmaps = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportLowQualityLightmaps"));
	const auto CVarSupportPointLightWholeSceneShadows = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportPointLightWholeSceneShadows"));
	const auto CVarSupportAllShaderPermutations = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportAllShaderPermutations"));	
	const auto CVarVertexFoggingForOpaque = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VertexFoggingForOpaque"));	
	const auto CVarAllowStaticLighting = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.AllowStaticLighting"));
	const auto CVarSupportSkyAtmosphere = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.SupportSkyAtmosphere"));
	
	const auto CVarMobileHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
	const auto CVarMobileAllowMovableDirectionalLights = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.AllowMovableDirectionalLights"));

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ReadOnlyCVARCache.cpp:79

Scope (from outer to inner):

file
function     void FReadOnlyCVARCache::Initialize

Source code excerpt:

	const auto CVarMobileSupportGPUScene = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Mobile.SupportGPUScene"));
	
	const bool bForceAllPermutations = CVarSupportAllShaderPermutations && CVarSupportAllShaderPermutations->GetValueOnAnyThread() != 0;

	bEnableStationarySkylight = !CVarSupportStationarySkylight || CVarSupportStationarySkylight->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bEnablePointLightShadows = !CVarSupportPointLightWholeSceneShadows || CVarSupportPointLightWholeSceneShadows->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bEnableLowQualityLightmaps = !CVarSupportLowQualityLightmaps || CVarSupportLowQualityLightmaps->GetValueOnAnyThread() != 0 || bForceAllPermutations;
	bAllowStaticLighting = CVarAllowStaticLighting->GetValueOnAnyThread() != 0;
	bSupportSkyAtmosphere = !CVarSupportSkyAtmosphere || CVarSupportSkyAtmosphere->GetValueOnAnyThread() != 0 || bForceAllPermutations;

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:76

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarSupportAllShaderPermutations(
	TEXT("r.SupportAllShaderPermutations"),
	0,
	TEXT("Local user config override to force all shader permutation features on."),
	ECVF_ReadOnly | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarParallelBasePass(