r.InstancedStaticMeshes.GpuLod
r.InstancedStaticMeshes.GpuLod
#Overview
name: r.InstancedStaticMeshes.GpuLod
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to enable GPU LOD selection on InstancedStaticMesh.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.InstancedStaticMeshes.GpuLod is to control whether GPU LOD selection is enabled for Instanced Static Meshes in Unreal Engine 5. This setting is primarily used in the rendering system, specifically for optimizing the rendering of multiple instances of static meshes.
This setting variable is utilized by the Engine module, particularly in the Instanced Static Mesh rendering subsystem. It’s referenced in the InstancedStaticMesh.cpp file, which is part of the core rendering pipeline for instanced static meshes.
The value of this variable is set through a console variable (CVarGpuLodSelection) with a default value of 1, meaning it’s enabled by default. It can be changed at runtime through console commands or programmatically.
The associated variable CVarGpuLodSelection directly interacts with r.InstancedStaticMeshes.GpuLod. They share the same value and purpose. When the value of this variable changes, it triggers a recreation of the render state context, which ensures that the changes are properly applied to the rendering pipeline.
Developers must be aware that changing this variable will impact performance and visual quality. Enabling GPU LOD selection can improve performance by offloading LOD calculations to the GPU, but it may have different impacts depending on the specific hardware and scene complexity.
Best practices when using this variable include:
- Testing performance with it enabled and disabled to determine the optimal setting for your specific project.
- Considering the target hardware capabilities when deciding whether to use GPU LOD selection.
- Being cautious when changing this value at runtime, as it triggers a render state recreation which can be costly.
Regarding the associated variable CVarGpuLodSelection:
- Its purpose is the same as r.InstancedStaticMeshes.GpuLod - to control GPU LOD selection for Instanced Static Meshes.
- It’s used in the Engine module, specifically in the Instanced Static Mesh rendering system.
- Its value is set at initialization and can be changed through console commands.
- It directly controls the bUseGpuLodSelection flag in the FInstancedStaticMeshSceneProxy class, which determines whether GPU LOD selection is used for a specific instanced static mesh.
- Developers should be aware that this variable has render thread safety implications, as indicated by the ECVF_RenderThreadSafe flag.
- Best practices include using this variable consistently with r.InstancedStaticMeshes.GpuLod and considering its impact on performance and visual quality in different scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:83
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarGpuLodSelection(
TEXT("r.InstancedStaticMeshes.GpuLod"),
1,
TEXT("Whether to enable GPU LOD selection on InstancedStaticMesh."),
FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable) { FGlobalComponentRecreateRenderStateContext Context; }),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarAllowCreateEmptyISMs(
#Associated Variable and Callsites
This variable is associated with another variable named CVarGpuLodSelection
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:82
Scope: file
Source code excerpt:
IMPLEMENT_GLOBAL_SHADER_PARAMETER_STRUCT(FInstancedStaticMeshVFLooseUniformShaderParameters, "InstancedVFLooseParameters");
TAutoConsoleVariable<int32> CVarGpuLodSelection(
TEXT("r.InstancedStaticMeshes.GpuLod"),
1,
TEXT("Whether to enable GPU LOD selection on InstancedStaticMesh."),
FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable) { FGlobalComponentRecreateRenderStateContext Context; }),
ECVF_RenderThreadSafe);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh.cpp:1416
Scope (from outer to inner):
file
function void FInstancedStaticMeshSceneProxy::SetupProxy
Source code excerpt:
const bool bUseGPUScene = UseGPUScene(GetScene().GetShaderPlatform(), GetScene().GetFeatureLevel());
const bool bEnableGpuLodSelection = CVarGpuLodSelection.GetValueOnAnyThread() != 0;
bUseGpuLodSelection = InProxyDesc.bUseGpuLodSelection && bUseGPUScene && bEnableGpuLodSelection;
if (bUseGPUScene)
{
if (PlatformGPUSceneUsesUniformBufferView(GetScene().GetShaderPlatform()))
{