bStripShaderReflection

bStripShaderReflection

#Overview

name: bStripShaderReflection

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bStripShaderReflection is to control whether shader reflection information is stripped when compiling shaders for Android platforms. This setting is part of the rendering system, specifically related to shader compilation and optimization for Android devices.

This setting variable is primarily used in the Android runtime settings and shader compilation modules of Unreal Engine. It is referenced in the AndroidRuntimeSettings class and utilized in the ShaderCompiler and RenderCore subsystems.

The value of this variable is set in the Android Runtime Settings, which can be configured through the Unreal Engine project settings or directly in the configuration files.

bStripShaderReflection interacts with shader compilation arguments and shader map key generation. When set to false, it adds a compilation argument “STRIP_REFLECT_ANDROID” set to false and appends “_NoStripReflect” to the shader map key string.

Developers must be aware that changing this setting requires a restart of the engine to take effect, as indicated by the ConfigRestartRequired flag. Additionally, this setting specifically affects Android builds and may impact shader performance and file size.

Best practices when using this variable include:

  1. Keep it enabled (true) for release builds to reduce shader file sizes and potentially improve performance.
  2. Consider disabling it (false) during development if you need shader reflection information for debugging or analysis purposes.
  3. Be mindful of the performance and storage implications when disabling shader reflection stripping, especially for large projects or those targeting lower-end Android devices.
  4. Ensure that any changes to this setting are properly propagated to all team members and build systems to maintain consistency across development and deployment environments.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:3087, section: [/Script/AndroidRuntimeSettings.AndroidRuntimeSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Android/AndroidRuntimeSettings/Classes/AndroidRuntimeSettings.h:468

Scope (from outer to inner):

file
class        class UAndroidRuntimeSettings : public UObject

Source code excerpt:

	ToolTip = "If true, strip shader reflection information under Android",
	ConfigRestartRequired = true))
	bool bStripShaderReflection;

	// If selected, the checked architectures will be split into separate .apk files [CURRENTLY FOR FULL SOURCE GAMES ONLY]
	// @todo android fat binary: Currently, there isn't much utility in merging multiple .so's into a single .apk except for debugging,
	// but we can't properly handle multiple GPU architectures in a single .apk, so we are disabling the feature for now
	// The user will need to manually select the apk to run in their Visual Studio debugger settings (see Override APK in TADP, for instance)
// 	UPROPERTY(GlobalConfig, EditAnywhere, Category = Build)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:8002

Scope (from outer to inner):

file
function     void GlobalBeginCompileShader

Source code excerpt:

	{
		bool bIsStripReflect = true;
		GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bStripShaderReflection"), bIsStripReflect, GEngineIni);
		if (!bIsStripReflect)
		{
			Input.Environment.SetCompileArgument(TEXT("STRIP_REFLECT_ANDROID"), false);
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1861

Scope (from outer to inner):

file
function     void ShaderMapAppendKeyString

Source code excerpt:

	{
		bool bStripReflect = true;
		GConfig->GetBool(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("bStripShaderReflection"), bStripReflect, GEngineIni);
		if (!bStripReflect)
		{
			KeyString += TEXT("_NoStripReflect");
		}
	}