p.GeometryCollectionSingleThreadedBoundsCalculation

p.GeometryCollectionSingleThreadedBoundsCalculation

#Overview

name: p.GeometryCollectionSingleThreadedBoundsCalculation

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.GeometryCollectionSingleThreadedBoundsCalculation is to control the threading behavior of bounds calculation for geometry collections in Unreal Engine 5.

This setting variable is primarily used in the Geometry Collection subsystem, which is part of the Experimental GeometryCollectionEngine module in Unreal Engine 5. It specifically affects the bounds calculation process for geometry collections.

The value of this variable is set through a console variable (CVar) system. It’s initialized as false by default, meaning multi-threaded bounds calculation is the default behavior.

The associated variable bGeometryCollectionSingleThreadedBoundsCalculation directly interacts with p.GeometryCollectionSingleThreadedBoundsCalculation. They share the same value, with bGeometryCollectionSingleThreadedBoundsCalculation being the actual boolean variable used in the code logic.

Developers must be aware that this variable is marked as “[Debug Only]” in the code comments, suggesting it’s primarily intended for debugging purposes and not for use in production environments.

When using this variable, developers should consider the following best practices:

  1. Use it primarily for debugging and performance analysis.
  2. Be aware that enabling single-threaded bounds calculation may impact performance, especially for complex geometry collections.
  3. Test thoroughly when changing this setting, as it may affect the behavior and performance of geometry collections in the game.

Regarding the associated variable bGeometryCollectionSingleThreadedBoundsCalculation:

Its purpose is to directly control the execution flow in the bounds calculation functions for geometry collections.

It’s used in the GeometryCollectionComponent.cpp file, specifically in the ComputeBoundsFromGeometryBoundingBoxes and ComputeBoundsFromTransformBoundingBoxes functions.

The value is set through the console variable system, linked to p.GeometryCollectionSingleThreadedBoundsCalculation.

This variable interacts with bChaos_BoxCalcBounds_ISPC_Enabled, another performance-related flag. When bGeometryCollectionSingleThreadedBoundsCalculation is true, it overrides the ISPC-enabled optimization.

Developers should be aware that this variable directly impacts the performance of bounds calculations for geometry collections. When set to true, it forces single-threaded execution, which may be slower but potentially more predictable or easier to debug.

Best practices for using this variable include:

  1. Use it in conjunction with profiling tools to understand its impact on performance.
  2. Consider it as a temporary debug tool rather than a long-term configuration option.
  3. Be cautious about enabling it in performance-critical scenarios, as it may introduce unnecessary bottlenecks.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:467

Scope: file

Source code excerpt:

// Single-Threaded Bounds
bool bGeometryCollectionSingleThreadedBoundsCalculation = false;
FAutoConsoleVariableRef CVarGeometryCollectionSingleThreadedBoundsCalculation(TEXT("p.GeometryCollectionSingleThreadedBoundsCalculation"), bGeometryCollectionSingleThreadedBoundsCalculation, TEXT("[Debug Only] Single threaded bounds calculation. [def:false]"));

FName UGeometryCollectionComponent::DefaultCollisionProfileName("InternalGCDefaultCollision");

FGeomComponentCacheParameters::FGeomComponentCacheParameters()
	: CacheMode(EGeometryCollectionCacheType::None)
	, TargetCache(nullptr)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:466

Scope: file

Source code excerpt:


// Single-Threaded Bounds
bool bGeometryCollectionSingleThreadedBoundsCalculation = false;
FAutoConsoleVariableRef CVarGeometryCollectionSingleThreadedBoundsCalculation(TEXT("p.GeometryCollectionSingleThreadedBoundsCalculation"), bGeometryCollectionSingleThreadedBoundsCalculation, TEXT("[Debug Only] Single threaded bounds calculation. [def:false]"));

FName UGeometryCollectionComponent::DefaultCollisionProfileName("InternalGCDefaultCollision");

FGeomComponentCacheParameters::FGeomComponentCacheParameters()
	: CacheMode(EGeometryCollectionCacheType::None)
	, TargetCache(nullptr)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:840

Scope (from outer to inner):

file
namespace    anonymous
function     inline FBox ComputeBoundsFromGeometryBoundingBoxes

Source code excerpt:

		if constexpr (bIsMatrixType)
		{
			if (bChaos_BoxCalcBounds_ISPC_Enabled && !bGeometryCollectionSingleThreadedBoundsCalculation)
			{
				ensure(BoundingBoxes.Num() > 0);
				ensure(TransformIndices.Num() == BoundingBoxes.Num());
				ensure(TransformToGeometryIndex.Num() > 0);
				ensure(TransformToGeometryIndex.Num() == GlobalMatrices.Num());

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:891

Scope (from outer to inner):

file
namespace    anonymous
function     inline FBox ComputeBoundsFromTransformBoundingBoxes

Source code excerpt:

		if constexpr (bIsMatrixType)
		{
			if (bChaos_BoxCalcBounds_ISPC_Enabled && !bGeometryCollectionSingleThreadedBoundsCalculation)
			{
#if INTEL_ISPC
				ispc::BoxCalcBoundsFromTransformGroup(
					(int32*)&TransformToGeometryIndex[0],
					(ispc::FMatrix*)&GlobalMatrices[0],
					(ispc::FBox*)&BoundingBoxes[0],