r.Streaming.DefragDynamicBounds

r.Streaming.DefragDynamicBounds

#Overview

name: r.Streaming.DefragDynamicBounds

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 r.Streaming.DefragDynamicBounds is to control the defragmentation of dynamic bounds in the texture streaming system. This setting variable is part of Unreal Engine’s rendering and streaming subsystem.

The Unreal Engine subsystem that relies on this setting variable is the texture streaming system, specifically the dynamic texture instance management component. This can be inferred from the file names where the variable is referenced: “TextureStreamingHelpers.cpp” and “DynamicTextureInstanceManager.cpp”.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning the feature is enabled by default. Developers can change this value at runtime using console commands or through configuration files.

The associated variable CVarStreamingDefragDynamicBounds interacts directly with r.Streaming.DefragDynamicBounds. They share the same value and purpose.

Developers must be aware that this variable affects the performance and memory usage of the texture streaming system. When enabled (value > 0), it removes unused dynamic bounds from the update loop, which can potentially improve performance by reducing unnecessary processing.

Best practices when using this variable include:

  1. Leave it enabled (default value of 1) unless specific performance issues are observed.
  2. If disabling it, carefully monitor the impact on memory usage and streaming performance.
  3. Consider adjusting this variable in different scenarios (e.g., development vs. shipping builds) to find the optimal balance between performance and memory usage.

Regarding the associated variable CVarStreamingDefragDynamicBounds:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp:230

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarStreamingDefragDynamicBounds(
	TEXT("r.Streaming.DefragDynamicBounds"),
	1,
	TEXT("If non-zero, unused dynamic bounds will be removed from the update loop"),
	ECVF_Default);

// Don't split small mips as the overhead of 2 load is significant.
TAutoConsoleVariable<int32> CVarStreamingMinMipForSplitRequest(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/DynamicTextureInstanceManager.cpp:156

Scope (from outer to inner):

file
function     void FDynamicRenderAssetInstanceManager::OnRefreshVisibilityDone

Source code excerpt:


	// Move the last valid bound to the first empty place, trying to free the tail.
	if (CVarStreamingDefragDynamicBounds.GetValueOnGameThread() > 0)
	{
		if (FirstFreeBound < LastUsedBound)
		{
			PendingDefragDstBoundIndex = FirstFreeBound;
			PendingDefragSrcBoundIndex = LastUsedBound;
		}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.cpp:229

Scope: file

Source code excerpt:

	ECVF_Default);

TAutoConsoleVariable<int32> CVarStreamingDefragDynamicBounds(
	TEXT("r.Streaming.DefragDynamicBounds"),
	1,
	TEXT("If non-zero, unused dynamic bounds will be removed from the update loop"),
	ECVF_Default);

// Don't split small mips as the overhead of 2 load is significant.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/TextureStreamingHelpers.h:64

Scope: file

Source code excerpt:

extern TAutoConsoleVariable<int32> CVarStreamingUseMaterialData;
extern TAutoConsoleVariable<int32> CVarStreamingNumStaticComponentsProcessedPerFrame;
extern TAutoConsoleVariable<int32> CVarStreamingDefragDynamicBounds;
extern TAutoConsoleVariable<float> CVarStreamingMaxTextureUVDensity;
extern TAutoConsoleVariable<int32> CVarStreamingLowResHandlingMode;

struct FRenderAssetStreamingSettings
{
	// How to handle assets with too many missing MIPs or LODs