r.ShaderPrint.MaxCharacters

r.ShaderPrint.MaxCharacters

#Overview

name: r.ShaderPrint.MaxCharacters

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.ShaderPrint.MaxCharacters is to set the maximum number of characters that can be stored in the ShaderPrint output buffer. This setting is used in the rendering system, specifically for the ShaderPrint functionality.

This setting variable is primarily used in the Renderer module of Unreal Engine, as evidenced by its location in the ShaderPrint.cpp file within the Runtime/Renderer/Private directory.

The value of this variable is set through a console variable (CVarMaxCharacterCount) with a default value of 2000 characters. It can be modified at runtime using console commands or through engine configuration files.

The associated variable CVarMaxCharacterCount directly interacts with r.ShaderPrint.MaxCharacters. They share the same value and purpose.

Developers should be aware that this variable affects the size of the ShaderPrint output buffer. Setting it too low might result in truncated output, while setting it too high might unnecessarily consume more memory.

Best practices when using this variable include:

  1. Only increase the value if you’re experiencing truncated ShaderPrint output.
  2. Monitor performance impact when increasing this value significantly.
  3. Use in conjunction with other ShaderPrint-related settings for optimal configuration.

Regarding the associated variable CVarMaxCharacterCount:

The purpose of CVarMaxCharacterCount is to provide a programmatic way to access and modify the r.ShaderPrint.MaxCharacters setting within the C++ code.

It’s used in the Renderer module, specifically in the ShaderPrint namespace.

The value is set when the console variable is initialized, but can be modified at runtime using the GetValueOnAnyThread() method.

It interacts directly with r.ShaderPrint.MaxCharacters and is used in the GetMaxCharacterCount() function to determine the actual maximum character count, taking into account any additional requests (GCachedShaderPrintMaxRequest.CharacterCount).

Developers should be aware that changes to CVarMaxCharacterCount will directly affect the ShaderPrint output buffer size.

Best practices for using CVarMaxCharacterCount include:

  1. Use GetValueOnAnyThread() to access the current value safely from any thread.
  2. Consider thread safety when modifying the value, as it’s marked with ECVF_RenderThreadSafe.
  3. Use in conjunction with GetMaxCharacterCount() for the most up-to-date and accurate maximum character count.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:48

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarMaxCharacterCount(
		TEXT("r.ShaderPrint.MaxCharacters"),
		2000,
		TEXT("ShaderPrint output buffer size.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxWidgetCount(
		TEXT("r.ShaderPrint.MaxWidget"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:47

Scope (from outer to inner):

file
namespace    ShaderPrint

Source code excerpt:

		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxCharacterCount(
		TEXT("r.ShaderPrint.MaxCharacters"),
		2000,
		TEXT("ShaderPrint output buffer size.\n"),
		ECVF_Cheat | ECVF_RenderThreadSafe);

	static TAutoConsoleVariable<int32> CVarMaxWidgetCount(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShaderPrint.cpp:145

Scope (from outer to inner):

file
namespace    ShaderPrint
function     static uint32 GetMaxCharacterCount

Source code excerpt:

	static uint32 GetMaxCharacterCount()
	{
		return FMath::Max(CVarMaxCharacterCount.GetValueOnAnyThread() + int32(GCachedShaderPrintMaxRequest.CharacterCount), 0);
	}

	static uint32 GetMaxWidgetCount()
	{
		return FMath::Max(CVarMaxWidgetCount.GetValueOnAnyThread() + int32(GCachedShaderPrintMaxRequest.WidgetCount), 0);
	}