r.CullBeforeFetch
r.CullBeforeFetch
#Overview
name: r.CullBeforeFetch
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable Cull-Before-Fetch optimization for platforms that support it.\n 0: Disable (default)\n 1: Enable
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.CullBeforeFetch is to enable or disable the Cull-Before-Fetch optimization for platforms that support it. This setting is used in the shader compilation process to optimize rendering performance.
The r.CullBeforeFetch variable is primarily used in the shader compiler subsystem of Unreal Engine. It affects how shaders are compiled and optimized for certain platforms.
The value of this variable is set through the engine’s configuration system. It is defined as a console variable (CVar) with two possible values: 0: Disable (default) 1: Enable
This variable interacts with the shader compilation process. When enabled (set to 1), it adds the CFLAG_CullBeforeFetch compiler flag to the shader environment. This flag instructs the shader compiler to apply the Cull-Before-Fetch optimization.
Developers should be aware that:
- This optimization is platform-specific and may not be supported on all platforms.
- Enabling this feature can potentially improve rendering performance on supported platforms.
- The effect of this optimization may vary depending on the specific rendering scenario and hardware.
Best practices when using this variable include:
- Testing the performance impact on target platforms before enabling it globally.
- Considering platform-specific behavior when enabling or disabling this feature.
- Documenting the use of this optimization in project-specific rendering guidelines.
- Monitoring for any visual artifacts or inconsistencies that may arise from enabling this optimization.
It’s important to note that this setting is part of the shader compilation process and changing it may require recompilation of shaders to take effect.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:2281
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarCullBeforeFetch(
TEXT("r.CullBeforeFetch"),
0,
TEXT("Enable Cull-Before-Fetch optimization for platforms that support it.\n")
TEXT(" 0: Disable (default)\n")
TEXT(" 1: Enable"),
ECVF_ReadOnly);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ShaderCompiler/ShaderCompiler.cpp:7986
Scope (from outer to inner):
file
function void GlobalBeginCompileShader
Source code excerpt:
SET_SHADER_DEFINE(Input.Environment, USE_SCENE_DEPTH_AUX, MobileRequiresSceneDepthAux(ShaderPlatform) ? 1 : 0);
static FShaderPlatformCachedIniValue<bool> EnableCullBeforeFetchIniValue(TEXT("r.CullBeforeFetch"));
if (EnableCullBeforeFetchIniValue.Get((EShaderPlatform)Target.Platform) == 1)
{
Input.Environment.CompilerFlags.Add(CFLAG_CullBeforeFetch);
}
static FShaderPlatformCachedIniValue<bool> EnableWarpCullingIniValue(TEXT("r.WarpCulling"));
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/Shader.cpp:1745
Scope (from outer to inner):
file
function void ShaderMapAppendKeyString
Source code excerpt:
{
static FShaderPlatformCachedIniValue<bool> EnableCullBeforeFetchIniValue(TEXT("r.CullBeforeFetch"));
if (EnableCullBeforeFetchIniValue.Get(Platform) == 1)
{
KeyString += TEXT("_CBF");
}
static FShaderPlatformCachedIniValue<bool> EnableWarpCullingIniValue(TEXT("r.WarpCulling"));
if (EnableWarpCullingIniValue.Get(Platform) == 1)