r.Streaming.AmortizeCPUToGPUCopy

r.Streaming.AmortizeCPUToGPUCopy

#Overview

name: r.Streaming.AmortizeCPUToGPUCopy

The value of this variable can be defined or overridden in .ini config files. 5 .ini config files referencing this setting variable.

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.Streaming.AmortizeCPUToGPUCopy is to control the amortization of texture streaming from CPU memory to GPU memory. It is specifically designed for the texture streaming system within Unreal Engine’s rendering subsystem.

This setting variable is primarily used by the Engine’s texture streaming module, as evidenced by its location in the StreamingManagerTexture.cpp file. It works in conjunction with another variable, r.Streaming.MaxNumTexturesToStreamPerFrame, to limit the number of 2D textures streamed from CPU to GPU memory each frame.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with an initial value of 0, which means the feature is disabled by default.

The associated variable CVarTextureStreamingAmortizeCPUToGPUCopy directly interacts with this setting. It’s used in the ShouldAmortizeMipCopies() function to determine whether mip copies should be amortized.

Developers must be aware that this variable only takes effect when r.Streaming.MaxNumTexturesToStreamPerFrame is set to a value greater than 0. When both conditions are met, it limits the number of 2D textures streamed from CPU to GPU memory each frame.

Best practices when using this variable include:

  1. Only enable it when you need to control the texture streaming load on a per-frame basis.
  2. Use it in conjunction with r.Streaming.MaxNumTexturesToStreamPerFrame for effective control.
  3. Monitor performance impact, as limiting texture streaming might affect visual quality or loading times.

Regarding the associated variable CVarTextureStreamingAmortizeCPUToGPUCopy:

The purpose of CVarTextureStreamingAmortizeCPUToGPUCopy is to provide direct access to the r.Streaming.AmortizeCPUToGPUCopy setting within the C++ code.

This variable is used within the Engine’s texture streaming subsystem, specifically in the StreamingManagerTexture module.

Its value is set automatically by the console variable system to match r.Streaming.AmortizeCPUToGPUCopy.

It interacts directly with CVarTextureStreamingMaxNumTexturesToStreamPerFrame in the ShouldAmortizeMipCopies() function.

Developers should be aware that this variable is used internally by the engine and should not be modified directly. Instead, they should use the r.Streaming.AmortizeCPUToGPUCopy console variable to control this setting.

Best practices include using the GetValueOnGameThread() method to access its value, as shown in the ShouldAmortizeMipCopies() function, to ensure thread-safe access to the variable’s current value.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseScalability.ini:557, section: [TextureQuality@0]

Location: <Workspace>/Engine/Config/BaseScalability.ini:568, section: [TextureQuality@1]

Location: <Workspace>/Engine/Config/BaseScalability.ini:579, section: [TextureQuality@2]

Location: <Workspace>/Engine/Config/BaseScalability.ini:590, section: [TextureQuality@3]

Location: <Workspace>/Engine/Config/BaseScalability.ini:601, section: [TextureQuality@Cine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:1418

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarTextureStreamingAmortizeCPUToGPUCopy(
	TEXT("r.Streaming.AmortizeCPUToGPUCopy"),
	0,
	TEXT("If set and r.Streaming.MaxNumTexturesToStreamPerFrame > 0, limit the number of 2D textures ")
	TEXT("streamed from CPU memory to GPU memory each frame"),
	ECVF_Scalability | ECVF_ExcludeFromPreview);

static TAutoConsoleVariable<int32> CVarTextureStreamingMaxNumTexturesToStreamPerFrame(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:1417

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<int32> CVarTextureStreamingAmortizeCPUToGPUCopy(
	TEXT("r.Streaming.AmortizeCPUToGPUCopy"),
	0,
	TEXT("If set and r.Streaming.MaxNumTexturesToStreamPerFrame > 0, limit the number of 2D textures ")
	TEXT("streamed from CPU memory to GPU memory each frame"),
	ECVF_Scalability | ECVF_ExcludeFromPreview);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Streaming/StreamingManagerTexture.cpp:1433

Scope (from outer to inner):

file
function     static bool ShouldAmortizeMipCopies

Source code excerpt:

static FORCEINLINE bool ShouldAmortizeMipCopies()
{
	return CVarTextureStreamingAmortizeCPUToGPUCopy.GetValueOnGameThread()
		&& CVarTextureStreamingMaxNumTexturesToStreamPerFrame.GetValueOnGameThread() > 0;
}

/**
 * Stream textures/meshes in/out, based on the priorities calculated by the async work.
 * @param bProcessEverything	Whether we're processing all textures in one go