r.InstanceData.ResetTrackingOnRegister
r.InstanceData.ResetTrackingOnRegister
#Overview
name: r.InstanceData.ResetTrackingOnRegister
This variable is created as a Console Variable (cvar).
- type:
Var - help:
Chicken switch to disable the new code to reset tracking & instance count during OnRegister, if this causes problems.\nTODO: Remove.
It is referenced in 3 C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.InstanceData.ResetTrackingOnRegister is to control the behavior of instance data tracking and instance count resetting during the OnRegister process for instanced static meshes. It serves as a safety switch to disable new code that resets tracking and instance count during registration if problems arise.
This setting variable is primarily used in the Engine module, specifically in the Instanced Static Mesh (ISM) subsystem. It’s referenced in the ISMInstanceDataManager.cpp file, which is part of the engine’s rendering and optimization systems for instanced static meshes.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning the new reset tracking code is enabled by default.
The associated variable CVarInstanceDataResetTrackingOnRegister directly interacts with r.InstanceData.ResetTrackingOnRegister. They share the same value and purpose.
Developers must be aware that this variable is intended as a temporary measure, as indicated by the “TODO: Remove” comment in the code. It’s a “chicken switch” to quickly disable potentially problematic new functionality if issues are encountered.
Best practices when using this variable include:
- Monitoring performance and stability when the variable is set to 1 (enabled).
- If problems occur with instanced static meshes, try setting it to 0 to see if it resolves the issues.
- Reporting any problems that necessitate disabling this feature to the Unreal Engine development team.
- Keeping in mind that this is a temporary solution and preparing for its eventual removal.
Regarding the associated variable CVarInstanceDataResetTrackingOnRegister:
The purpose of CVarInstanceDataResetTrackingOnRegister is identical to r.InstanceData.ResetTrackingOnRegister. It’s the actual console variable that controls the behavior described earlier.
This variable is used in the Engine module, specifically in the ISMInstanceDataManager class, which is part of the instanced static mesh rendering system.
The value is set through the TAutoConsoleVariable template, initializing it with a value of 1.
It directly interacts with the r.InstanceData.ResetTrackingOnRegister setting, as they represent the same console variable.
Developers should be aware that this variable is checked on the game thread (GetValueOnGameThread()), which means changes to this variable will take effect on the next game frame.
Best practices include using this variable for debugging and optimization purposes, and being prepared for its eventual removal as indicated by the TODO comment in the code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh/ISMInstanceDataManager.cpp:32
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarInstanceDataResetTrackingOnRegister(
TEXT("r.InstanceData.ResetTrackingOnRegister"),
1,
TEXT("Chicken switch to disable the new code to reset tracking & instance count during OnRegister, if this causes problems.\nTODO: Remove."));
static TAutoConsoleVariable<int32> CVarInstanceDataMinInstanceCountToOptimize(
TEXT("r.InstanceData.MinInstanceCountToOptimize"),
2,
#Associated Variable and Callsites
This variable is associated with another variable named CVarInstanceDataResetTrackingOnRegister. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh/ISMInstanceDataManager.cpp:31
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarInstanceDataResetTrackingOnRegister(
TEXT("r.InstanceData.ResetTrackingOnRegister"),
1,
TEXT("Chicken switch to disable the new code to reset tracking & instance count during OnRegister, if this causes problems.\nTODO: Remove."));
static TAutoConsoleVariable<int32> CVarInstanceDataMinInstanceCountToOptimize(
TEXT("r.InstanceData.MinInstanceCountToOptimize"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh/ISMInstanceDataManager.cpp:1057
Scope (from outer to inner):
file
function void FPrimitiveInstanceDataManager::OnRegister
Source code excerpt:
LOG_INST_DATA(TEXT("OnRegister(InNumInstances : %d) NumInstances: %d"), InNumInstances, NumInstances);
if (CVarInstanceDataResetTrackingOnRegister.GetValueOnGameThread())
{
if (InNumInstances != NumInstances)
{
ClearIdTracking(InNumInstances);
}
}