p.SkipDesyncTest

p.SkipDesyncTest

#Overview

name: p.SkipDesyncTest

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.SkipDesyncTest is to control the desynchronization test in the Chaos physics system of Unreal Engine 5. It is used to skip the hard desync test, which assumes all particles are clean except for those spawning at different times. This variable is primarily used for performance testing and is not intended for correct simulation behavior.

This setting variable is primarily used in the Chaos physics subsystem, which is part of the Experimental module in Unreal Engine 5. It’s specifically utilized in the rewind and resimulation functionality of the physics system.

The value of this variable is set through a console variable (CVar) named “p.SkipDesyncTest”. It’s initialized to 0 by default, meaning the desync test is not skipped.

The SkipDesyncTest variable interacts directly with the associated variable of the same name. They share the same value and are used interchangeably in the code.

Developers must be aware that:

  1. This variable is meant for performance testing and not for accurate physics simulation.
  2. Setting this variable to a non-zero value will skip important synchronization checks, which could lead to incorrect physics behavior.
  3. It’s part of the experimental Chaos physics system, so its behavior may change in future engine versions.

Best practices when using this variable include:

  1. Only use it for performance profiling or debugging purposes.
  2. Always reset it to 0 for final builds or when accurate physics simulation is required.
  3. Be cautious when interpreting results from simulations where this variable is set to skip the desync test.

Regarding the associated variable SkipDesyncTest:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:517

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


CHAOS_API int32 SkipDesyncTest = 0;
FAutoConsoleVariableRef CVarSkipDesyncTest(TEXT("p.SkipDesyncTest"), SkipDesyncTest, TEXT("Skips hard desync test, this means all particles will assume to be clean except spawning at different times. This is useful for a perf lower bound, not actually correct"));

void FRewindData::AdvanceFrameImp(IResimCacheBase* ResimCache)
{
	FramesSaved = FMath::Min(FramesSaved + 1, static_cast<int32>(Managers.Capacity()));

	const int32 EarliestFrame = CurFrame - FramesSaved;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:392

Scope (from outer to inner):

file
namespace    Chaos
function     void FRewindData::DesyncIfNecessary

Source code excerpt:

	if (Handle->SyncState() == ESyncState::InSync && !History.template IsInSync<bSkipDynamics>(*Handle, FrameAndPhase, PropertiesPool))
	{
		if (!SkipDesyncTest)
		{
			//first time desyncing so need to clear history from this point into the future
			DesyncObject(Info, FrameAndPhase);
		}
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:516

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

}

CHAOS_API int32 SkipDesyncTest = 0;
FAutoConsoleVariableRef CVarSkipDesyncTest(TEXT("p.SkipDesyncTest"), SkipDesyncTest, TEXT("Skips hard desync test, this means all particles will assume to be clean except spawning at different times. This is useful for a perf lower bound, not actually correct"));

void FRewindData::AdvanceFrameImp(IResimCacheBase* ResimCache)
{
	FramesSaved = FMath::Min(FramesSaved + 1, static_cast<int32>(Managers.Capacity()));

	const int32 EarliestFrame = CurFrame - FramesSaved;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:550

Scope (from outer to inner):

file
namespace    Chaos
function     void FRewindData::AdvanceFrameImp
lambda-function

Source code excerpt:

				}

				if (IsResim() && Handle->SyncState() != ESyncState::InSync && !SkipDesyncTest)
				{
					Handle->SetEnabledDuringResim(true);	//for now just mark anything out of sync as resim enabled. TODO: use bubble
					DesyncFunc(Handle);
				}

				AdvanceDirtyFunc(Info, Handle);

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/RewindData.h:1366

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

};

extern CHAOS_API int32 SkipDesyncTest;

class FPBDRigidsSolver;

class FRewindData
{
public: