p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce

p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce

#Overview

name: p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce

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 p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce is to control the behavior of the acceleration structure update in the Chaos physics system of Unreal Engine 5. Specifically, it sets a threshold for the maximum size of the update queue before time slicing is disabled, and the acceleration structure is built all at once.

This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental physics framework. Based on the callsites, it’s implemented in the PBDRigidsEvolution.cpp file, which is part of the Chaos module.

The value of this variable is set to 1000 by default, as seen in the source code. It’s exposed as a console variable, allowing developers to adjust it at runtime or through configuration files.

The associated variable AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce directly interacts with this setting. They share the same value and purpose.

Developers must be aware that this variable affects the performance and behavior of the physics system. If the update queue for the acceleration structure exceeds this threshold, the system will switch from a time-sliced update to a full, immediate build. This can potentially cause frame rate hitches if the full build takes a significant amount of time.

Best practices when using this variable include:

  1. Monitor performance when adjusting this value, as it can impact frame rates.
  2. Consider the nature of your game or simulation when setting this value. Games with many dynamic objects might benefit from a higher threshold to avoid frequent full builds.
  3. Use in conjunction with other Chaos physics settings for optimal performance.
  4. Profile your game to determine if the default value is suitable or if adjustments are needed.

Regarding the associated variable AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce:

This variable is an integer that holds the actual value used by the system. It’s defined in the Chaos namespace and is used directly in the FPBDRigidsEvolutionBase::ComputeIntermediateSpatialAcceleration function to determine whether to force a full build of the acceleration structure.

The purpose and considerations for this variable are the same as those for the console variable. It’s the internal representation of the setting that the engine code actually checks against during execution.

Developers should note that modifying this variable directly in code would override the console variable setting. In most cases, it’s preferable to use the console variable for runtime adjustments and debugging.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolution.cpp:50

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	CHAOS_API int32 AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce = 1000;
	FAutoConsoleVariableRef CVarAccelerationStructureTimeSlicingMaxQueueSizeBeforeForce(TEXT("p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce"), AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce, TEXT("If the update queue reaches this limit, time slicing will be disabled, and the acceleration structure will be built at once"));

	CHAOS_API int32 AccelerationStructureTimeSlicingMaxBytesCopy = 100000;
	FAutoConsoleVariableRef CVarAccelerationStructureTimeSlicingMaxBytesCopy(TEXT("p.Chaos.AccelerationStructureTimeSlicingMaxBytesCopy"), AccelerationStructureTimeSlicingMaxBytesCopy, TEXT("The Maximum number of bytes to copy to the external acceleration structure during Copy Time Slicing"));

	CHAOS_API FBroadPhaseConfig BroadPhaseConfig;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolution.cpp:49

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarAccelerationStructureCacheOverlappingLeaves(TEXT("p.Chaos.AccelerationStructureCacheOverlappingLeaves"), GAccelerationStructureCacheOverlappingLeaves, TEXT("Set to 1: Cache the overlapping leaves for faster overlap query, any other value will disable the feature"));

	CHAOS_API int32 AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce = 1000;
	FAutoConsoleVariableRef CVarAccelerationStructureTimeSlicingMaxQueueSizeBeforeForce(TEXT("p.Chaos.AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce"), AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce, TEXT("If the update queue reaches this limit, time slicing will be disabled, and the acceleration structure will be built at once"));

	CHAOS_API int32 AccelerationStructureTimeSlicingMaxBytesCopy = 100000;
	FAutoConsoleVariableRef CVarAccelerationStructureTimeSlicingMaxBytesCopy(TEXT("p.Chaos.AccelerationStructureTimeSlicingMaxBytesCopy"), AccelerationStructureTimeSlicingMaxBytesCopy, TEXT("The Maximum number of bytes to copy to the external acceleration structure during Copy Time Slicing"));

	CHAOS_API FBroadPhaseConfig BroadPhaseConfig;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolution.cpp:732

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsEvolutionBase::ComputeIntermediateSpatialAcceleration

Source code excerpt:

		CHAOS_SCOPED_TIMER(ComputeIntermediateSpatialAcceleration);

		bool ForceFullBuild = InternalAccelerationQueue.Num() > AccelerationStructureTimeSlicingMaxQueueSizeBeforeForce;

		if (!AccelerationStructureTaskComplete)
		{
			//initial frame so make empty structures

			InternalAcceleration = GetFreeSpatialAcceleration_Internal();