r.InstanceUpdateTaskDebugDelay

r.InstanceUpdateTaskDebugDelay

#Overview

name: r.InstanceUpdateTaskDebugDelay

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.InstanceUpdateTaskDebugDelay is to introduce a deliberate delay in the instance update task for debugging purposes. This setting variable is part of the rendering system, specifically related to instanced static meshes.

This setting variable is primarily used in the Engine module, particularly within the instanced static mesh system. Based on the callsites, it’s utilized in the ISMInstanceDataManager.cpp file, which is responsible for managing instance data for instanced static meshes.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of 0.0f, meaning no delay by default.

The associated variable CVarInstanceUpdateTaskDebugDelay interacts directly with r.InstanceUpdateTaskDebugDelay. They share the same value and purpose.

Developers must be aware that using this variable will introduce artificial delays in the instance update process, which can significantly impact performance. It should only be used for debugging purposes and not in production builds.

Best practices when using this variable include:

  1. Only enable it when actively debugging instance update issues.
  2. Use small delay values to minimize performance impact.
  3. Always remember to disable it after debugging is complete.
  4. Be cautious when using it in multiplayer scenarios, as it may cause synchronization issues.

Regarding the associated variable CVarInstanceUpdateTaskDebugDelay:

The purpose of CVarInstanceUpdateTaskDebugDelay is the same as r.InstanceUpdateTaskDebugDelay - to introduce a debug delay in the instance update task.

It’s used in the Engine module, specifically in the instanced static mesh system within the ISMInstanceDataManager.cpp file.

The value is set when the TAutoConsoleVariable is created, with a default of 0.0f. It can be modified at runtime through console commands.

This variable directly interacts with r.InstanceUpdateTaskDebugDelay, as they represent the same console variable.

Developers should be aware that this is the actual C++ variable that holds the value of the console variable. When accessing the value in code, they should use CVarInstanceUpdateTaskDebugDelay.GetValueOnAnyThread() for thread-safe access.

Best practices for using CVarInstanceUpdateTaskDebugDelay are the same as those for r.InstanceUpdateTaskDebugDelay, with the addition of using the appropriate getter methods when accessing its value in C++ 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:26

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarInstanceUpdateTaskDebugDelay(
	TEXT("r.InstanceUpdateTaskDebugDelay"),
	0.0f,
	TEXT("Instance update debug delay in seconds."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarInstanceDataResetTrackingOnRegister(
	TEXT("r.InstanceData.ResetTrackingOnRegister"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh/ISMInstanceDataManager.cpp:25

Scope: file

Source code excerpt:

#endif

static TAutoConsoleVariable<float> CVarInstanceUpdateTaskDebugDelay(
	TEXT("r.InstanceUpdateTaskDebugDelay"),
	0.0f,
	TEXT("Instance update debug delay in seconds."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarInstanceDataResetTrackingOnRegister(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/InstancedStaticMesh/ISMInstanceDataManager.cpp:391

Scope (from outer to inner):

file
function     void FPrimitiveInstanceDataManager::BeginUpdateTask
lambda-function

Source code excerpt:

	auto OuterTaskFunc = [TaskLambda = MoveTemp(TaskLambda)]() mutable
	{
		const float DebugDelay = CVarInstanceUpdateTaskDebugDelay.GetValueOnAnyThread();
		if (DebugDelay != 0.0f)
		{
			UE_LOG(LogTemp, Warning, TEXT("Instance update debug delay %5.1fs (CVar r.InstanceUpdateTaskDebugDelay)"), DebugDelay);
			FPlatformProcess::Sleep(DebugDelay);
		}